ProductData extends CandlepinDTO implements ProductInfo { public ProductData setAttributes(Map<String, String> attributes) { if (attributes != null) { if (this.attributes == null) { this.attributes = new HashMap<>(); } else { this.attributes.clear(); } this.attributes.putAll(attributes); } else { this.attributes = null; } return this; } ProductData();  ProductData(String id, String name);  ProductData(ProductData source);  ProductData(Product source); String getUuid(); ProductData setUuid(String uuid); String getId(); ProductData setId(String id); String getName(); ProductData setName(String name); Long getMultiplier(); ProductData setMultiplier(Long multiplier); Map<String, String> getAttributes(); @XmlTransient String getAttributeValue(String key); @XmlTransient boolean hasAttribute(String key); ProductData setAttribute(String key, String value); boolean removeAttribute(String key); ProductData setAttributes(Map<String, String> attributes); Collection<ProductContentData> getProductContent(); ProductContentData getProductContent(String contentId); boolean hasContent(String contentId); boolean addProductContent(ProductContentData contentData); boolean addProductContent(ProductContent productContent); boolean addContent(ContentData contentData, boolean enabled); boolean addContent(Content content, boolean enabled); boolean removeContent(String contentId); boolean removeContent(Content content); boolean removeContent(ContentData contentData); boolean removeProductContent(ProductContent content); boolean removeProductContent(ProductContentData contentData); ProductData setProductContent(Collection<ProductContentData> content); Collection<String> getDependentProductIds(); boolean addDependentProductId(String productId); boolean removeDependentProductId(String productId); ProductData setDependentProductIds(Collection<String> dependentProductIds); Collection<Branding> getBranding(); ProductData setBranding(Collection<Branding> branding); boolean addBranding(Branding branding); boolean removeBranding(Branding branding); String getHref(); ProductData setHref(String href); @XmlTransient Boolean isLocked(); ProductData setLocked(Boolean locked); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode(); @Override Object clone(); ProductData populate(ProductData source); ProductData populate(Product source); static final long serialVersionUID; }
@Test public void testSerializeProductAttributes() throws Exception { String expectedHeader = "\"attributes\":[{"; String expectedValue1 = "\"name\":\"attrib-1\",\"value\":\"value-1\""; String expectedValue2 = "\"name\":\"attrib-2\",\"value\":\"value-2\""; String expectedValue3 = "\"name\":\"attrib-3\",\"value\":\"3\""; Map<String, String> attributes = new HashMap<>(); attributes.put("attrib-1", "value-1"); attributes.put("attrib-2", "value-2"); attributes.put("attrib-3", "3"); ProductData dto = new ProductData(); dto.setAttributes(attributes); String output = this.mapper.writeValueAsString(dto); assertTrue(output.contains(expectedHeader)); assertTrue(output.contains(expectedValue1)); assertTrue(output.contains(expectedValue2)); assertTrue(output.contains(expectedValue3)); }