@Test(enabled = ENABLED)
public void testOperationAndArtifactUpdates() throws Exception {
System.out.println("= testOperationAndArtifactUpdates");
try {
registerPlugin("update3-v1_0.xml");
ResourceType platform1 = getResourceType("myPlatform3");
getTransactionManager().begin();
platform1 = em.find(ResourceType.class, platform1.getId());
Set<PackageType> packageTypes = platform1.getPackageTypes();
assert packageTypes.size() == 3 : "Did not find the three expected package types in v1";
Set<OperationDefinition> ops = platform1.getOperationDefinitions();
assert ops.size() == 3 : "Did not find three expected operations in v1";
getTransactionManager().rollback();
/*
* Now deploy the changed version of the plugin
*/
registerPlugin("update3-v2_0.xml");
ResourceType platform2 = getResourceType("myPlatform3");
getTransactionManager().begin();
platform2 = em.find(ResourceType.class, platform2.getId());
Set<PackageType> packageTypes2 = platform2.getPackageTypes();
assert packageTypes2.size() == 3 : "Did not find the expected three package types in v2";
Set<OperationDefinition> opDefs = platform2.getOperationDefinitions();
assert opDefs.size() == 3 : "Did not find the three expected operations in v2";
// now that the basics are tested, go for the details...
boolean ubuFound = false;
for (PackageType pt : packageTypes2) {
// System.out.println(at.getName());
assert !(pt.getName().equals("rpm")) : "RPM should be gone in v2";
if (pt.getName().equals("ubu")) {
ubuFound = true;
}
}
assert ubuFound == true : "Ubu should be in v2";
boolean startFound = false;
for (OperationDefinition opDef : opDefs) {
// System.out.println(opDef.getName());
assert !(opDef.getName().equals("restart")) : "Restart should be gone in v2";
if (opDef.getName().equals("start")) {
startFound = true;
}
if (opDef.getName().equals("status")) {
assert opDef.getDescription().equals("Yadda!") : "Description for 'start' should be 'Yadda!', but was "
+ opDef.getDescription();
}
}
assert startFound == true : "Start should be in v2";
getTransactionManager().rollback();
/*
* Now try the other way round
*/
registerPlugin("update3-v1_0.xml", "3.0");
ResourceType platform3 = getResourceType("myPlatform3");
getTransactionManager().begin();
platform3 = em.find(ResourceType.class, platform3.getId());
Set<PackageType> packageTypes3 = platform3.getPackageTypes();
assert packageTypes3.size() == 3 : "Did not find the three package types in v3";
Set<OperationDefinition> ops3 = platform3.getOperationDefinitions();
assert ops3.size() == 3 : "Did not find three expected operations in v3";
// we should have rpm, deb, mpkg. ubu from v2 should be gone again.
boolean rpmFound = false;
for (PackageType pt : packageTypes3) {