AllergenResponse { public Allergen map() { Allergen allergen; if (isWikiDataIdPresent) { allergen = new Allergen(uniqueAllergenID, new ArrayList<>(), wikiDataCode); for (Map.Entry<String, String> name : names.entrySet()) { allergen.getNames() .add(new AllergenName(allergen.getTag(), name.getKey(), name.getValue(), wikiDataCode)); } } else { allergen = new Allergen(uniqueAllergenID, new ArrayList<>()); for (Map.Entry<String, String> name : names.entrySet()) { allergen.getNames() .add(new AllergenName(allergen.getTag(), name.getKey(), name.getValue())); } } return allergen; } AllergenResponse(String uniqueAllergenId, Map<String, String> names, String wikiDataCode);  AllergenResponse(String uniqueAllergenId, Map<String, String> names); Allergen map(); String getUniqueAllergenID(); void setUniqueAllergenID(String uniqueAllergenID); Map<String, String> getNames(); void setNames(Map<String, String> names);  }
@Test public void map_returnsMappedAllergenWithWikiDataCode() { String wikiDataCode = "Q12345"; AllergenResponse allergenResponse = new AllergenResponse(UNIQUE_ALLERGEN_ID_1, nameMap, wikiDataCode); Allergen allergen = allergenResponse.map(); assertThat(allergen.getWikiDataId()).isEqualTo(wikiDataCode); }