-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[HHQ-3422] Add support for ControlAction and OpenNMSAction for AlertD…
…efinitions.
- Loading branch information
Ryan Morgan
committed
Sep 30, 2009
1 parent
5fe44ec
commit 528e1b8
Showing
6 changed files
with
554 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
src/org/hyperic/hq/hqapi1/test/AlertDefinitionSyncActions_test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package org.hyperic.hq.hqapi1.test; | ||
|
||
import org.hyperic.hq.hqapi1.HQApi; | ||
import org.hyperic.hq.hqapi1.AlertDefinitionApi; | ||
import org.hyperic.hq.hqapi1.MetricApi; | ||
import org.hyperic.hq.hqapi1.AlertDefinitionBuilder; | ||
import org.hyperic.hq.hqapi1.types.Resource; | ||
import org.hyperic.hq.hqapi1.types.MetricsResponse; | ||
import org.hyperic.hq.hqapi1.types.Metric; | ||
import org.hyperic.hq.hqapi1.types.AlertDefinition; | ||
import org.hyperic.hq.hqapi1.types.AlertAction; | ||
import org.hyperic.hq.hqapi1.types.AlertDefinitionsResponse; | ||
|
||
import java.util.List; | ||
import java.util.ArrayList; | ||
|
||
public class AlertDefinitionSyncActions_test extends AlertDefinitionTestBase { | ||
|
||
public AlertDefinitionSyncActions_test(String name) { | ||
super(name); | ||
} | ||
public void testEmptyAlertAction() throws Exception { | ||
HQApi api = getApi(); | ||
AlertDefinitionApi defApi = api.getAlertDefinitionApi(); | ||
MetricApi metricApi = api.getMetricApi(); | ||
|
||
Resource platform = getLocalPlatformResource(false, false); | ||
|
||
MetricsResponse metricsResponse = metricApi.getMetrics(platform); | ||
hqAssertSuccess(metricsResponse); | ||
assertTrue("No metrics found for " + platform.getName(), | ||
metricsResponse.getMetric().size() > 0); | ||
Metric m = metricsResponse.getMetric().get(0); | ||
|
||
AlertDefinition d = generateTestDefinition(); | ||
d.setResource(platform); | ||
d.getAlertCondition().add( | ||
AlertDefinitionBuilder.createChangeCondition(true, m.getName())); | ||
|
||
AlertAction action = new AlertAction(); | ||
d.getAlertAction().add(action); | ||
|
||
List<AlertDefinition> definitions = new ArrayList<AlertDefinition>(); | ||
definitions.add(d); | ||
AlertDefinitionsResponse response = defApi.syncAlertDefinitions(definitions); | ||
hqAssertSuccess(response); | ||
|
||
AlertDefinition def = response.getAlertDefinition().get(0); | ||
validateDefinition(def); | ||
assertEquals("Wrong number of actions found", 0, def.getAlertAction().size()); | ||
|
||
// Cleanup | ||
cleanup(response.getAlertDefinition()); | ||
} | ||
|
||
public void testBadClassName() throws Exception { | ||
|
||
HQApi api = getApi(); | ||
AlertDefinitionApi defApi = api.getAlertDefinitionApi(); | ||
MetricApi metricApi = api.getMetricApi(); | ||
|
||
Resource platform = getLocalPlatformResource(false, false); | ||
|
||
MetricsResponse metricsResponse = metricApi.getMetrics(platform); | ||
hqAssertSuccess(metricsResponse); | ||
assertTrue("No metrics found for " + platform.getName(), | ||
metricsResponse.getMetric().size() > 0); | ||
Metric m = metricsResponse.getMetric().get(0); | ||
|
||
AlertDefinition d = generateTestDefinition(); | ||
d.setResource(platform); | ||
d.getAlertCondition().add( | ||
AlertDefinitionBuilder.createChangeCondition(true, m.getName())); | ||
|
||
AlertAction action = new AlertAction(); | ||
action.setClassName("org.hyperic.bad.AlertAction"); | ||
d.getAlertAction().add(action); | ||
|
||
List<AlertDefinition> definitions = new ArrayList<AlertDefinition>(); | ||
definitions.add(d); | ||
AlertDefinitionsResponse response = defApi.syncAlertDefinitions(definitions); | ||
hqAssertSuccess(response); | ||
|
||
AlertDefinition def = response.getAlertDefinition().get(0); | ||
validateDefinition(def); | ||
assertEquals("Wrong number of actions found", 0, def.getAlertAction().size()); | ||
|
||
// Cleanup | ||
cleanup(response.getAlertDefinition()); | ||
} | ||
} |
Oops, something went wrong.