assert definitions1.size() == 1;
/*
* Create a Fake Resource and a MeasurementSchedule
*/
Resource testResource = new Resource("-test-", "-test resource", platform);
testResource.setUuid("" + new Random().nextInt());
em.persist(testResource);
setUpAgent(testResource);
getTransactionManager().commit();
} catch (Exception e) {
getTransactionManager().rollback();
fail("Setup of v1 failed: " + e);
}
// Set up done, now replace the plugin with a new one.
System.out.println("Done with v1");
try {
registerPlugin("update7-2.xml");
} catch (Throwable t) {
System.err.println(t);
}
ResourceType platform = getResourceType("myPlatform7");
Set<MeasurementDefinition> definitions2 = platform.getMetricDefinitions();
assert definitions2.size() == 2;
Subject overlord = LookupUtil.getSubjectManager().getOverlord();
ResourceCriteria c = new ResourceCriteria();
c.addFilterResourceTypeId(platform.getId());
c.addFilterInventoryStatus(InventoryStatus.NEW);
c.fetchSchedules(true);
List<Resource> resources = LookupUtil.getResourceManager().findResourcesByCriteria(overlord, c);
assert resources != null;
assertEquals(1, resources.size());
Resource res = resources.get(0);
Set<MeasurementSchedule> schedules = res.getSchedules();
assert schedules != null;
/*
* We only expect one schedule for the freshly created metric, as the resource we
* created earlier has no schedule attached yet (in the test).
* In the "real world" it would get its schedules on inventory sync time.