assertEquals("Wrong Category Path", cp, ca.getCategoryPath());
}
@Test
public void testProperties() throws FacetException {
CategoryAttribute ca = new CategoryAttributeImpl();
assertNull("Attribute should be null", ca
.getProperty(DummyProperty.class));
assertNull("Attribute classes should be null", ca.getPropertyClasses());
ca.addProperty(new DummyProperty());
assertEquals("DummyProperty should be in properties",
new DummyProperty(), ca.getProperty(DummyProperty.class));
assertEquals("Attribute classes should contain 1 element", 1, ca
.getPropertyClasses().size());
boolean failed = false;
try {
ca.addProperty(new DummyProperty());
} catch (UnsupportedOperationException e) {
failed = true;
}
if (!failed) {
fail("Two DummyAttributes added to the same CategoryAttribute");
}
ca.clearProperties();
assertNull("Attribute classes should be null", ca.getPropertyClasses());
ca.addProperty(new DummyProperty());
assertEquals("DummyProperty should be in properties",
new DummyProperty(), ca.getProperty(DummyProperty.class));
ca.remove(DummyProperty.class);
assertEquals("DummyProperty should not be in properties", null, ca
.getProperty(DummyProperty.class));
assertNull("Attribute classes should be null", ca.getPropertyClasses());
ca.addProperty(new DummyProperty());
List<Class<? extends CategoryProperty>> propertyClasses = new ArrayList<Class<? extends CategoryProperty>>();
assertEquals("No property expected when no classes given", null, ca
.getProperty(propertyClasses));
propertyClasses.add(DummyProperty.class);
assertEquals("DummyProperty should be in properties",
new DummyProperty(), ca.getProperty(propertyClasses));
propertyClasses.add(OrdinalProperty.class);
assertEquals("DummyProperty should be in properties",
new DummyProperty(), ca.getProperty(propertyClasses));
propertyClasses.clear();
propertyClasses.add(OrdinalProperty.class);
assertEquals("No ordinal property expected", null, ca
.getProperty(propertyClasses));
}