}
assert def instanceof PropertyDefinitionMap : "Not all properties are maps in v1";
if (def.getName().equals("map4")) {
PropertyDefinitionMap map = (PropertyDefinitionMap) def;
Map<String, PropertyDefinition> children = map.getMap();
assert children.size() == 1 : "Map4 should have 1 child";
children = map.getMap();
map = (PropertyDefinitionMap) children.get("map4:2");
assert map != null : "Child map4:2 not found";
children = map.getMap();
map = (PropertyDefinitionMap) children.get("map4:2:3");
assert map != null : "Child map4:2:3 not found";
children = map.getMap();
PropertyDefinitionSimple simple = (PropertyDefinitionSimple) children.get("simple");
assert simple != null : "Child simple not found";
}
if (def.getName().equals("map5")) {
PropertyDefinitionMap map = (PropertyDefinitionMap) def;
Map<String, PropertyDefinition> children = map.getMap();
assert children.size() == 1 : "Map4 should have 1 child";
children = map.getMap();
PropertyDefinitionSimple simple = (PropertyDefinitionSimple) children.get("hugo");
assert simple.getDescription().equals("foo");
}
}
assert found == 5 : "Did not find the 5 desired maps in v1";
getTransactionManager().rollback();
}
System.out.println("Done with v1");
/*
* Now deploy v2
*/
{ // extra block for variable scoping purposes
registerPlugin("propertyMap-v2.xml");
ResourceType platform = getResourceType("myPlatform7");
getTransactionManager().begin();
platform = em.find(ResourceType.class, platform.getId());
ConfigurationDefinition cd = platform.getResourceConfigurationDefinition();
Map<String, PropertyDefinition> propDefs = cd.getPropertyDefinitions();
assert propDefs.size() == 5 : "Expected to find 5 properties in v2, but got " + propDefs.size();
int found = 0;
for (PropertyDefinition def : propDefs.values()) {
if (containedIn(def.getName(), new String[] { "map1", "map2", "map3", "map4", "map5" })) {
found++;
}
if (def.getName().equals("map1")) {
assert def instanceof PropertyDefinitionSimple : "Map 1 should be a simple-property in v2";
} else {
assert def instanceof PropertyDefinitionMap : "Not all properties are maps in v2";
}
if (def.getName().equals("map3")) {
assert def.isRequired() == false : "Map 3 should not be false in v2";
}
if (def.getName().equals("map4")) {
PropertyDefinitionMap map = (PropertyDefinitionMap) def;
Map<String, PropertyDefinition> children = map.getMap();
assert children.size() == 1 : "Map4 should have 1 child, but has " + children.size();
children = map.getMap();
map = (PropertyDefinitionMap) children.get("map4:2+");
assert map != null : "Child map4:2 not found";
children = map.getMap();
assert children.size() == 1 : "Map4:2 should have 1 child, but has " + children.size();
map = (PropertyDefinitionMap) children.get("map4:2:3");
assert map != null : "Child map4:2:3 not found";
children = map.getMap();
assert children.size() == 2 : "Map4:2:3 should have 1 child, but has " + children.size();
PropertyDefinitionList list = (PropertyDefinitionList) children.get("list");
assert list != null : "Child list not found";
PropertyDefinitionSimple simple = (PropertyDefinitionSimple) children.get("simple2");
assert simple != null : "Child simple2 not found";
}
if (def.getName().equals("map5")) {
PropertyDefinitionMap map = (PropertyDefinitionMap) def;
Map<String, PropertyDefinition> children = map.getMap();
assert children.size() == 1 : "Map5 should have 1 child";
children = map.getMap();
PropertyDefinitionSimple simple = (PropertyDefinitionSimple) children.get("hugo");
assert simple.getDescription().equals("bar") : "Map5:hugo should have 'bar' in v2";
}
}