Item implements Identifiable, Serializable { @Transient public String getItemFieldContent(ItemField itemField) { if (itemFieldMap.containsKey(itemField)) { LocalisedText localisedText = itemFieldMap.get(itemField).getPrimaryDetail(); if (localisedText != null) { return localisedText.getContent(); } } return null; } Item(); Long getId(); void setId(Long id); String getSKU(); void setSKU(String sku); String getGTIN(); void setGTIN(String gtin); double getTaxRate(); void setTaxRate(double taxRate); boolean isDeleted(); void setDeleted(boolean deleted); String getReasonForDelete(); void setReasonForDelete(String reasonForDelete); Set<CartItem> getCartItems(); void setCartItems(Set<CartItem> cartItems); BigMoney getLocalPrice(); void setLocalPrice(BigMoney localPrice); Map<ItemField, ItemFieldDetail> getItemFieldMap(); void setItemFieldMap(Map<ItemField, ItemFieldDetail> itemFieldMap); @Transient String getItemFieldContent(ItemField itemField); @Transient String getItemFieldContent(ItemField itemField, String localeKey); @Transient ItemFieldDetail getItemFieldDetail(ItemField itemField); @Transient void setItemFieldDetail(ItemField itemField, ItemFieldDetail itemFieldDetail); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }
@Test public void testItemFieldDetailSummary() { Item testObject= ItemBuilder.newInstance() .withSKU("abc123") .withPrimaryFieldDetail(ItemField.SUMMARY, "English", "en") .withSecondaryFieldDetail(ItemField.SUMMARY, "French french", "fr_FR") .withSecondaryFieldDetail(ItemField.SUMMARY, "British english", "en_GB") .withSecondaryFieldDetail(ItemField.SUMMARY, "Thai with native script", "th_TH_TH") .withPrimaryFieldDetail(ItemField.TITLE, "English title", "en") .withSecondaryFieldDetail(ItemField.TITLE, "French title", "fr_FR") .build(); Assert.assertEquals("Primary failed", "English", testObject.getItemFieldContent(ItemField.SUMMARY)); Assert.assertEquals("Specific locale (UK) failed", "British english", testObject.getItemFieldContent(ItemField.SUMMARY, "en_GB")); Assert.assertEquals("Specific locale (FRANCE) failed", "French french", testObject.getItemFieldContent(ItemField.SUMMARY, "fr_FR")); Assert.assertEquals("Specific locale (THAILAND) failed", "Thai with native script", testObject.getItemFieldContent(ItemField.SUMMARY, "th_TH_TH")); Assert.assertEquals("Primary failed", "English title", testObject.getItemFieldContent(ItemField.TITLE)); Assert.assertEquals("Specific locale (FRANCE) failed", "French title", testObject.getItemFieldContent(ItemField.TITLE, "fr_FR")); }