### Question:
GenericReportUnitResourceConverter extends DataSourceHolderResourceConverter<ServerReportUnitType, ClientReportUnitType> { protected Map<String, ResourceReference> getServerResourcesAsMap(List<ResourceReference> list) { final HashMap<String, ResourceReference> result = new HashMap<String, ResourceReference>(); if (list != null) { for (ResourceReference reference : list) { final String name = reference.isLocal() ? reference.getLocalResource().getName() : getResourceNameForReference(reference); result.put(name, reference); } } return result; }    }### Answer:
@Test public void getServerResourcesAsMap_nullProducesEmptyMap(){ final Map<String, ResourceReference> serverResourcesAsMap = converter.getServerResourcesAsMap(null); assertNotNull(serverResourcesAsMap); assertTrue(serverResourcesAsMap.isEmpty()); }
@Test public void getServerResourcesAsMap_emptyListProducesEmptyMap(){ final Map<String, ResourceReference> serverResourcesAsMap = converter.getServerResourcesAsMap(new ArrayList<ResourceReference>()); assertNotNull(serverResourcesAsMap); assertTrue(serverResourcesAsMap.isEmpty()); }
@Test public void getServerResourcesAsMap(){ final ArrayList<ResourceReference> list = new ArrayList<ResourceReference>(); final String expectedReferenceName = "expectedReferenceName"; final String expectedReferenceUri = "/test/resource/" + expectedReferenceName; final ResourceReference expectedReference = new ResourceReference(expectedReferenceUri); list.add(expectedReference); final FileResource localFile = new FileResourceImpl(); final String expectedLocalFileName = "expectedLocalFileName"; localFile.setName(expectedLocalFileName); final ResourceReference expectedRefereceWithLocalResource = new ResourceReference(localFile); list.add(expectedRefereceWithLocalResource); final FileResourceImpl expectedLocalFileReference = new FileResourceImpl(); final String expectedLocalFileReferenceName = "expectedLocalFileReferenceName"; expectedLocalFileReference.setName(expectedLocalFileReferenceName); final ResourceReference expectedReferenceWithFileReference = new ResourceReference(expectedLocalFileReference); list.add(expectedReferenceWithFileReference); final Map<String, ResourceReference> serverResourcesAsMap = converter.getServerResourcesAsMap(list); assertNotNull(serverResourcesAsMap); assertEquals(serverResourcesAsMap.size(), list.size()); for(String currentResourceName : serverResourcesAsMap.keySet()){ final ResourceReference resourceReference = serverResourcesAsMap.get(currentResourceName); if(expectedReferenceName.equals(currentResourceName)){ assertSame(resourceReference, expectedReference); assertEquals(resourceReference.getReferenceURI(), expectedReferenceUri); } else if(expectedLocalFileName.equals(currentResourceName)){ assertSame(resourceReference, expectedRefereceWithLocalResource); assertSame(resourceReference.getLocalResource(), localFile); } else if(expectedLocalFileReferenceName.equals(currentResourceName)){ assertSame(resourceReference, expectedReferenceWithFileReference); assertEquals(resourceReference.getLocalResource(), expectedLocalFileReference); } else{ assertTrue(false); } } }