### Question:
MapAdapter extends XmlAdapter<ConfigProperties, Map<String, String>> { @Override public ConfigProperties marshal(Map<String, String> map) throws Exception { if (map == null) return null; ConfigProperties configProperties = new ConfigProperties(); for (Map.Entry<String, String> entry : map.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); JAXBElement<String> element = new JAXBElement<>(new QName(key), String.class, value); configProperties.getProperties().add(element); } return configProperties; }  @Override Map<String, String> unmarshal(ConfigProperties configProperties); @Override ConfigProperties marshal(Map<String, String> map);  }### Answer:
@Test public void marshalEmpty() throws Exception { Map<String, String> map = new HashMap<>(); ConfigProperties outcome = adapter.marshal(map); assertThat(outcome.getProperties()).isEmpty(); }
@Test public void marshalNull() throws Exception { assertThat(adapter.marshal(null)).isNull(); }
@Test public void marshal() throws Exception { Map<String, String> map = new LinkedHashMap<>(); map.put("message", "I love sparrows!!"); map.put("greeting", "Hellow"); ConfigProperties outcome = adapter.marshal(map); assertThat(outcome.getProperties()).hasSize(2); List<String> names = outcome.getProperties().stream() .map(JAXBElement::getName) .map(QName::getLocalPart) .collect(Collectors.toList()); assertThat(names).containsExactly("message", "greeting"); List<String> values = outcome.getProperties().stream().map(JAXBElement::getValue).collect(Collectors.toList()); assertThat(values).containsExactly("I love sparrows!!", "Hellow"); }