@Test(enabled = ENABLED)
public void testAddDeleteTemplate() throws Exception {
try {
ResourceType platform;
ConfigurationTemplate defaultTemplate;
ConfigurationDefinition cd;
Map<String, ConfigurationTemplate> templateMap;
ConfigurationTemplate template;
PropertySimple ps;
registerPlugin("addDeleteTemplate1.xml");
platform = getResourceType("myPlatform7");
getTransactionManager().begin();
platform = em.find(ResourceType.class, platform.getId());
cd = platform.getResourceConfigurationDefinition();
defaultTemplate = cd.getDefaultTemplate();
assert defaultTemplate != null;
templateMap = cd.getTemplates();
assert templateMap.size() == 1 : "Expected only the 1 default template but got " + templateMap.size();
getTransactionManager().rollback();
System.out.println("Done with v1");
registerPlugin("addDeleteTemplate2.xml");
platform = getResourceType("myPlatform7");
getTransactionManager().begin();
em = getEntityManager();
platform = em.find(ResourceType.class, platform.getId());
cd = platform.getResourceConfigurationDefinition();
defaultTemplate = cd.getDefaultTemplate();
templateMap = cd.getTemplates();
assert defaultTemplate != null;
assert templateMap.size() == 2 : "Expected 2 templates but got " + templateMap;
template = templateMap.get("additional");
assert template != null;
ps = template.getConfiguration().getSimple("second_one");
assert ps.getStringValue().equals("Bart") : "Expected 'Bart', but got " + ps.getStringValue();
getTransactionManager().rollback();
System.out.println("Done with v2");
registerPlugin("addDeleteTemplate3.xml");
platform = getResourceType("myPlatform7");
getTransactionManager().begin();
em = getEntityManager();
platform = em.find(ResourceType.class, platform.getId());
cd = platform.getResourceConfigurationDefinition();
defaultTemplate = cd.getDefaultTemplate();
templateMap = cd.getTemplates();
assert defaultTemplate != null;
assert templateMap.size() == 2 : "Expected 2 templates but got " + templateMap;
template = templateMap.get("additional");
assert template != null;
ps = template.getConfiguration().getSimple("second_one");
assert ps.getStringValue().equals("Bart Simpson") : "Expected 'Bart Simpson', but got "
+ ps.getStringValue();
getTransactionManager().rollback();
System.out.println("Done with v3");