From: <rm...@hy...> - 2009-01-16 03:36:13
|
Author: rmorgan Date: 2009-01-15 19:36:07 -0800 (Thu, 15 Jan 2009) New Revision: 465 URL: http://svn.hyperic.org/?view=rev&root=HQApi&revision=465 Modified: trunk/src/org/hyperic/hq/hqapi1/test/AlertDefinitionSync_test.java Log: Add multi-condition sync test. Modified: trunk/src/org/hyperic/hq/hqapi1/test/AlertDefinitionSync_test.java =================================================================== --- trunk/src/org/hyperic/hq/hqapi1/test/AlertDefinitionSync_test.java 2009-01-16 03:28:23 UTC (rev 464) +++ trunk/src/org/hyperic/hq/hqapi1/test/AlertDefinitionSync_test.java 2009-01-16 03:36:07 UTC (rev 465) @@ -182,6 +182,38 @@ cleanup(response.getAlertDefinition()); } + public void testSyncManyConditions() throws Exception { + AlertDefinitionApi api = getApi().getAlertDefinitionApi(); + Resource platform = getLocalPlatformResource(false, false); + + AlertDefinition d = generateTestDefinition(); + d.setResource(platform); + + final int NUM_CONDITIONS = 10; + for (int i = 0; i < NUM_CONDITIONS; i++) { + AlertCondition c = AlertDefinitionBuilder.createPropertyCondition(false, "prop" + i); + d.getAlertCondition().add(c); + } + List<AlertDefinition> definitions = new ArrayList<AlertDefinition>(); + definitions.add(d); + + AlertDefinitionsResponse response = api.syncAlertDefinitions(definitions); + hqAssertSuccess(response); + assertEquals(response.getAlertDefinition().size(), 1); + for (AlertDefinition def : response.getAlertDefinition()) { + validateDefinition(def); + assertEquals(def.getAlertCondition().size(), NUM_CONDITIONS); + // Ordering here is important + for (int i = 0; i < NUM_CONDITIONS; i++) { + assertEquals(def.getAlertCondition().get(i).getProperty(), + "prop" + i); + } + } + + // Cleanup + cleanup(response.getAlertDefinition()); + } + // TODO: test sync multi broken with type alerts public void testSyncMulti() throws Exception { |