Map<String, PropertyDefinition> propDefs = cd.getPropertyDefinitions();
assert propDefs.size() == 4 : "Expected to see 4 <list-property>s in v1, but got " + propDefs.size();
for (PropertyDefinition def : propDefs.values()) {
assert def instanceof PropertyDefinitionList : "PropertyDefinition " + def.getName()
+ " is no list-property in v1";
PropertyDefinitionList pdl = (PropertyDefinitionList) def;
PropertyDefinition member = pdl.getMemberDefinition();
if (pdl.getName().equals("myList1")) {
assert pdl.getDescription().equals("Just a simple list");
assert member instanceof PropertyDefinitionSimple : "Expected the member of myList1 to be a simple property in v1";
PropertyDefinitionSimple pds = (PropertyDefinitionSimple) member;
assert pds.getName().equals("foo");
} else if (pdl.getName().equals("myList2")) {
assert member instanceof PropertyDefinitionList : "Expected the member of myList2 to be a list property in v1";
} else if (pdl.getName().equals("myList3")) {
assert member instanceof PropertyDefinitionSimple : "Expected the member of myList3 to be a simple property in v1";
PropertyDefinitionSimple pds = (PropertyDefinitionSimple) member;
assert pds.getName().equals("baz");
} else if (pdl.getName().equals("rec1")) {
assert member instanceof PropertyDefinitionList : "Expected the member of rc1 to be a list property in v1";
PropertyDefinitionList pdl2 = (PropertyDefinitionList) member;
// TODO check min/max for the lists on the way. Commented out. See JBNADM-1595
assert pdl2.getName().equals("rec2");
// assert pdl2.getMin()==2 : "Expected rec2:min to be 2, but it was " + pdl2.getMin();
// assert pdl2.getMax()==20;
pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
assert pdl2.getName().equals("rec3");
// assert pdl2.getMin()==3;
// assert pdl2.getMax()==30;
pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
assert pdl2.getName().equals("rec4");
// assert pdl2.getMin()==4;
// assert pdl2.getMax()==40;
assert pdl2.getMemberDefinition() instanceof PropertyDefinitionSimple;
PropertyDefinitionSimple pds = (PropertyDefinitionSimple) pdl2.getMemberDefinition();
assert pds.getName().equals("rec5");
assert pds.getDescription().equals("Deeply nested");
List<PropertyDefinitionEnumeration> options = pds.getEnumeratedValues();
assert options.size() == 4;
int found = 0;
String[] optionVals = new String[] { "a", "b", "c", "d" };
for (PropertyDefinitionEnumeration option : options) {
if (containedIn(option.getValue(), optionVals)) {
found++;
}
}
assert found == 4;
Set<Constraint> constraints = pds.getConstraints();
assert constraints.size() == 1;
} else {
assert true == false : "Unknown list-definition in v1: " + pdl.getName();
}
}
getTransactionManager().rollback();
/*
* Deploy v2 of the plugin
*/
registerPlugin("propertyList-v2.xml");
platform = getResourceType("myPlatform6");
getTransactionManager().begin();
em = getEntityManager();
platform = em.find(ResourceType.class, platform.getId());
cd = platform.getResourceConfigurationDefinition();
propDefs = cd.getPropertyDefinitions();
assert propDefs.size() == 4 : "Expected to see 4 <list-property>s in v2, but got " + propDefs.size();
for (PropertyDefinition def : propDefs.values()) {
assert def instanceof PropertyDefinitionList : "PropertyDefinition " + def.getName()
+ " is no list-property in v2";
PropertyDefinitionList pdl = (PropertyDefinitionList) def;
PropertyDefinition member = pdl.getMemberDefinition();
if (pdl.getName().equals("myList2")) {
assert member instanceof PropertyDefinitionList : "Expected the member of myList2 to be a list property in v2";
} else if (pdl.getName().equals("myList3")) {
assert member instanceof PropertyDefinitionList : "Expected the member of myList3 to be a list property in v2";
PropertyDefinitionList pds = (PropertyDefinitionList) member;
assert pds.getName().equals("baz");
assert pds.getDescription().equals("myList3:baz");
assert pds.getMemberDefinition() instanceof PropertyDefinitionSimple : "Expected the member of list3:baz to be a simple property in v2";
} else if (pdl.getName().equals("myList4")) {
assert pdl.getDescription().equals("Just a simple list");
assert member instanceof PropertyDefinitionSimple : "Expected the member of myList4 to be a simple property in v2";
PropertyDefinitionSimple pds = (PropertyDefinitionSimple) member;
assert pds.getName().equals("foo");
} else if (pdl.getName().equals("rec1")) {
assert member instanceof PropertyDefinitionList : "Expected the member of rec1 to be a list property in v2";
PropertyDefinitionList pdl2 = (PropertyDefinitionList) member;
assert pdl2.getName().equals("rec2");
/*
* PropertyDefinitionList.getMin()/getMax() are commented out. See JBNADM1595
*/
// assert pdl2.getMin()==12 : "Expected rec2:min to be 12, but it was " + pdl2.getMin();
// assert pdl2.getMax()==200;
pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
assert pdl2.getName().equals("rec3+");
// assert pdl2.getMin()==13;
// assert pdl2.getMax()==300;
pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
assert pdl2.getName().equals("rec4");
// assert pdl2.getMin()==14;
// assert pdl2.getMax()==400;
assert pdl2.getMemberDefinition() instanceof PropertyDefinitionSimple;
PropertyDefinitionSimple pds = (PropertyDefinitionSimple) pdl2.getMemberDefinition();
assert pds.getName().equals("rec5");
assert pds.getDescription().equals("Nested deeply");
List<PropertyDefinitionEnumeration> options = pds.getEnumeratedValues();
assert options.size() == 5;
int found = 0;