### Question:
FilesMapXmlAdapter extends XmlAdapter<ClientReportUnitResourceListWrapper, Map<String, ClientReferenceableFile>> { @Override public Map<String, ClientReferenceableFile> unmarshal(ClientReportUnitResourceListWrapper v) throws Exception { Map<String, ClientReferenceableFile> result = null; if(v != null && v.getFiles() != null){ result = new HashMap<String, ClientReferenceableFile>(); for(ClientReportUnitResource currentResource : v.getFiles()){ result.put(currentResource.getName(), currentResource.getFile()); } } return result; }  @Override ClientReportUnitResourceListWrapper marshal(Map<String, ClientReferenceableFile> files); @Override Map<String, ClientReferenceableFile> unmarshal(ClientReportUnitResourceListWrapper v);  }### Answer:
@Test public void unmarshal_nullProducesNull() throws Exception { assertNull(adapter.unmarshal(null)); }
@Test public void unmarshal_emtpyProducesEmpty() throws Exception { final Map<String, ClientReferenceableFile> files = adapter.unmarshal(new ClientReportUnitResourceListWrapper(new ArrayList<ClientReportUnitResource>())); assertNotNull(files); assertTrue(files.isEmpty()); }
@Test public void unmarshal() throws Exception{ final ArrayList<ClientReportUnitResource> filesList = new ArrayList<ClientReportUnitResource>(); filesList.add(new ClientReportUnitResource("file1", new ClientFile())); filesList.add(new ClientReportUnitResource("file2", new ClientReference())); filesList.add(new ClientReportUnitResource("file3", new ClientFile())); filesList.add(new ClientReportUnitResource("file4", new ClientReference())); final Map<String, ClientReferenceableFile> filesMap = adapter.unmarshal(new ClientReportUnitResourceListWrapper(filesList)); assertNotNull(filesMap); assertEquals(filesMap.size(), filesList.size()); for(ClientReportUnitResource currentResource : filesList){ assertSame(filesMap.get(currentResource.getName()), currentResource.getFile()); } }