@@ -0,0 +1,3090 @@
+package org.sagebionetworks.web.unitclient.widget.entity;%0A%0Aimport static org.mockito.Matchers.*;%0Aimport static org.mockito.Mockito.*;%0Aimport static junit.framework.Assert.*;%0A%0Aimport java.util.Date;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.sagebionetworks.repo.model.Entity;%0Aimport org.sagebionetworks.repo.model.EntityHeader;%0Aimport org.sagebionetworks.repo.model.Project;%0Aimport org.sagebionetworks.repo.model.UserProfile;%0Aimport org.sagebionetworks.schema.adapter.AdapterFactory;%0Aimport org.sagebionetworks.schema.adapter.JSONObjectAdapter;%0Aimport org.sagebionetworks.schema.adapter.JSONObjectAdapterException;%0Aimport org.sagebionetworks.schema.adapter.org.json.AdapterFactoryImpl;%0Aimport org.sagebionetworks.schema.adapter.org.json.JSONObjectAdapterImpl;%0Aimport org.sagebionetworks.web.client.EntityTypeProvider;%0Aimport org.sagebionetworks.web.client.GlobalApplicationState;%0Aimport org.sagebionetworks.web.client.IconsImageBundle;%0Aimport org.sagebionetworks.web.client.PlaceChanger;%0Aimport org.sagebionetworks.web.client.SynapseClientAsync;%0Aimport org.sagebionetworks.web.client.cache.ClientCache;%0Aimport org.sagebionetworks.web.client.place.Synapse;%0Aimport org.sagebionetworks.web.client.widget.entity.EntityBadge;%0Aimport org.sagebionetworks.web.client.widget.entity.EntityBadgeView;%0Aimport org.sagebionetworks.web.client.widget.entity.EntityIconsCache;%0Aimport org.sagebionetworks.web.shared.EntityType;%0Aimport org.sagebionetworks.web.shared.EntityWrapper;%0Aimport org.sagebionetworks.web.shared.KeyValueDisplay;%0Aimport org.sagebionetworks.web.test.helper.AsyncMockStubber;%0A%0Aimport com.google.gwt.resources.client.ImageResource;%0Aimport com.google.gwt.user.client.rpc.AsyncCallback;%0A%0Apublic class EntityIconsCacheTest %7B%0A%09EntityTypeProvider mockEntityTypeProvider;%0A%09IconsImageBundle mockIconsImageBundle;%0A%09EntityIconsCache entityIconsCache;%0A%09ImageResource mockProjectIcon;%0A%0A%09@Before%0A%09public void before() %7B%0A%09%09mockEntityTypeProvider = mock(EntityTypeProvider.class);%0A%09%09mockIconsImageBundle = mock(IconsImageBundle.class);%0A%09%09entityIconsCache = new EntityIconsCache(mockEntityTypeProvider, mockIconsImageBundle);%0A%09%09EntityType type = new EntityType(%22Project%22, Project.class.getName(), %22%22, null);%0A%09%09when(mockEntityTypeProvider.getEntityTypeForString(anyString())).thenReturn(type);%0A%09%09mockProjectIcon = mock(ImageResource.class);%0A%09%09when(mockIconsImageBundle.synapseProject16()).thenReturn(mockProjectIcon);%0A%09%7D%0A%09%0A%09@Test%0A%09public void testCaching() throws Exception %7B%0A%09%09//type will map to project%0A%09%09String testType = %22Project%22;%0A%09%09ImageResource result = entityIconsCache.getIconForType(testType);%0A%09%09//should have returned the mock project icon%0A%09%09assertEquals(mockProjectIcon, result);%0A%09%09//not from the cache%0A%09%09verify(mockIconsImageBundle).synapseProject16();%0A%09%09%0A%09%09//but asking for the same type again should pull from the cache...%0A%09%09reset(mockIconsImageBundle); //reset count on mock icons image bundle%0A%09%09result = entityIconsCache.getIconForType(testType);%0A%09%09//same result%0A%09%09assertEquals(mockProjectIcon, result);%0A%09%09verify(mockIconsImageBundle, times(0)).synapseProject16();%0A%09%7D%0A%7D%0A

add test for entity icons cache