ProductData extends CandlepinDTO implements ProductInfo { public Map<String, String> getAttributes() { return this.attributes != null ? new MapView(this.attributes) : null; } 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 testProductAttributeJsonDeserializationV1() throws Exception { String attributes = "\"attributes\": [ " + " {" + " \"name\" : \"attrib-1\"," + " \"value\" : \"value-1\"," + " \"created\" : \"2016-09-07T15:08:14+0000\"," + " \"updated\" : \"2016-09-07T15:08:14+0000\"" + " }," + " {" + " \"name\" : \"attrib-2\"," + " \"value\" : \"value-2\"," + " \"created\" : \"2016-09-07T15:08:14+0000\"," + " \"updated\" : \"2016-09-07T15:08:14+0000\"" + " }," + " {" + " \"name\" : 3," + " \"value\" : 3," + " \"created\" : \"2016-09-07T15:08:14+0000\"," + " \"updated\" : \"2016-09-07T15:08:14+0000\"" + " }]"; Map<String, String> expectedAttrib = new HashMap<>(); expectedAttrib.put("attrib-1", "value-1"); expectedAttrib.put("attrib-2", "value-2"); expectedAttrib.put("3", "3"); ProductData dto = this.mapper.readValue( PRODUCT_JSON_BASE + "," + attributes + "}", ProductData.class); assertEquals(expectedAttrib, dto.getAttributes()); }
@Test public void testProductAttributeJsonDeserializationV2() throws Exception { String attributes = "\"attributes\": { " + " \"attrib-1\": \"value-1\"," + " \"attrib-2\": \"value-2\"," + " \"attrib-3\": 3" + "}"; Map<String, String> expectedAttrib = new HashMap<>(); expectedAttrib.put("attrib-1", "value-1"); expectedAttrib.put("attrib-2", "value-2"); expectedAttrib.put("attrib-3", "3"); ProductData dto = this.mapper.readValue( PRODUCT_JSON_BASE + "," + attributes + "}", ProductData.class); assertEquals(expectedAttrib, dto.getAttributes()); }