Skip to content

Commit

Permalink
[HQ-1903] Uncomment test case that fires a problem alert and then cre…
Browse files Browse the repository at this point in the history
…ates and fires a recovery alert
  • Loading branch information
pnguyen committed Dec 18, 2009
1 parent 202a704 commit 6175a74
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/org/hyperic/hq/hqapi1/test/AlertFireRecovery_test.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,27 +180,25 @@ public void testWillRecoverAddRecoveryPostCreateAndFireResourceTypeRecoveryAlert
*/
public void testFireProblemAlertAndThenCreateAndFireRecoveryAlert()
throws Exception {

// TODO: Uncomment the test code when HQ-1903 is fixed

/*
Resource platform = getLocalPlatformResource(false, false);

boolean willRecover = false;
AlertDefinition problemDef =
createAvailabilityAlertDefinition(platform, null, false, willRecover, 0);
Alert problemAlert = fireAvailabilityAlert(problemDef, willRecover, 0);

String description = "Test for HQ-1903; Recovery Alert for " + problemDef.getName();
AlertDefinition recoveryDef =
createRecoveryAlertDefinition(platform, problemDef, false);
createRecoveryAlertDefinition(platform, problemDef,
description, false);
fireRecoveryAlert(recoveryDef, problemAlert, willRecover);

// Cleanup
List<AlertDefinition> definitions = new ArrayList<AlertDefinition>();
definitions.add(problemDef);
definitions.add(recoveryDef);
cleanup(definitions);
*/
}

private void createAndFireAlerts(Escalation escalation,
Expand Down Expand Up @@ -271,20 +269,36 @@ private Alert fireRecoveryAlert(AlertDefinition recoveryDef,

return recoveryAlert;
}

private AlertDefinition createRecoveryAlertDefinition(Resource resource,
AlertDefinition problemDef,
boolean addRecoveryPostCreate)
throws Exception {

return createRecoveryAlertDefinition(resource, problemDef,
null, addRecoveryPostCreate);
}

private AlertDefinition createRecoveryAlertDefinition(Resource resource,
AlertDefinition problemDef,
String description,
boolean addRecoveryPostCreate)
throws Exception {

// Find availability metric for the passed in resource
Metric availMetric = findAvailabilityMetric(resource);

// Create recovery alert definition
boolean isResourceType = (problemDef.getResourcePrototype() != null);
String name = "Test" + (isResourceType ? " Resource Type " : " ") + "Recovery Alert";
AlertDefinition recoveryDef = generateTestDefinition(name);
recoveryDef.setDescription("Recovery Alert for " + problemDef.getName());

if (description == null) {
recoveryDef.setDescription("Recovery Alert for " + problemDef.getName());
} else {
recoveryDef.setDescription(description);
}

if (isResourceType) {
recoveryDef.setResourcePrototype(problemDef.getResourcePrototype());
} else {
Expand Down

0 comments on commit 6175a74

Please sign in to comment.