AssociationValue implements Serializable { @Deprecated @SuppressWarnings({ "rawtypes", "unchecked" }) public void setAttributes(Map<String, PrimitiveAttribute<?>> attributes) { if (!isPrimitiveOnly()) { throw new UnsupportedOperationException("Primitive API not supported for nested association values"); } this.attributes = (Map) attributes; } AssociationValue(); @SuppressWarnings({ "unchecked", "rawtypes" })  AssociationValue(PrimitiveAttribute<?> id, Map<String, PrimitiveAttribute<?>> attributes);  AssociationValue(PrimitiveAttribute<?> id, Map<String, Attribute<?>> attributes, boolean primitiveOnly); @edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "CN_IDIOM_NO_SUPER_CALL", justification = "needed for GWT") Object clone(); PrimitiveAttribute<?> getId(); void setId(PrimitiveAttribute<?> id); @Deprecated @SuppressWarnings({ "rawtypes", "unchecked" }) Map<String, PrimitiveAttribute<?>> getAttributes(); @Deprecated @SuppressWarnings({ "rawtypes", "unchecked" }) void setAttributes(Map<String, PrimitiveAttribute<?>> attributes); Map<String, Attribute<?>> getAllAttributes(); void setAllAttributes(Map<String, Attribute<?>> attributes); Object getAttributeValue(String attributeName); boolean isPrimitiveOnly(); void setPrimitiveOnly(boolean primitiveOnly); void setBooleanAttribute(String name, Boolean value); void setCurrencyAttribute(String name, String value); void setDateAttribute(String name, Date value); void setDoubleAttribute(String name, Double value); void setFloatAttribute(String name, Float value); void setImageUrlAttribute(String name, String value); void setIntegerAttribute(String name, Integer value); void setLongAttribute(String name, Long value); void setShortAttribute(String name, Short value); void setStringAttribute(String name, String value); void setUrlAttribute(String name, String value); void setManyToOneAttribute(String name, AssociationValue value); @Override String toString();  }
@Test public void testSetAttributes() { Map<String, Attribute<?>> attrs = new HashMap<String, Attribute<?>>(); attrs.put("orig", new ManyToOneAttribute()); AssociationValue value = new AssociationValue(new StringAttribute("1"), attrs, false); Map<String, PrimitiveAttribute<?>> attrs2 = new HashMap<String, PrimitiveAttribute<?>>(); attrs2.put("new", new StringAttribute("new")); try { value.setAttributes(attrs2); Assert.fail("Primitive attributes passed to mixed value"); } catch (UnsupportedOperationException uoe) { } Map<String, Attribute<?>> attrs3 = new HashMap<String, Attribute<?>>(); attrs3.put("orig", new StringAttribute("orig")); AssociationValue value2 = new AssociationValue(new StringAttribute("1"), attrs3, true); Map<String, PrimitiveAttribute<?>> attrs4 = new HashMap<String, PrimitiveAttribute<?>>(); attrs4.put("new", new StringAttribute("new")); value2.setAttributes(attrs4); Assert.assertSame(attrs4, value2.getAttributes()); }