public void testRenameServer() throws Exception {
Resource testResource = null;
MeasurementSchedule sched = null;
MeasurementBaseline baseline = null;
EventDefinition eDef = null;
// Note, plugins are registered in new transactions. for tests, this means
// you can't do everything in a trans and roll back at the end. You must clean up
// manually. Still, some work can be performed transactionally, as done below.
try {
registerPlugin("update6-1.xml");
ResourceType server = getResourceType("testServer1");
getTransactionManager().begin();
getPluginId();
Set<MeasurementDefinition> definitions1 = server.getMetricDefinitions();
// for metric counts, add one for the built in AvailabilityType metric
assert definitions1.size() == 2;
/*
* Create a Fake Resource and a MeasurementSchedule
*/
testResource = new Resource("-test-", "-test resource-", server);
testResource.setUuid("" + new Random().nextInt());
em.persist(testResource);
sched = new MeasurementSchedule(definitions1.iterator().next(), testResource);
em.persist(sched);
em.flush();
baseline = new MeasurementBaseline();
baseline.setSchedule(sched);
baseline.setUserEntered(true);
em.persist(baseline);
eDef = new EventDefinition(server, "-test event definition-");
em.persist(eDef);
setUpAgent(testResource);
getTransactionManager().commit();