createAlertDefinitionWithAvailDurationCondition(resource.getId(), "testAvailDurationAlertDef_2",
AlertConditionOperator.AVAIL_DURATION_DOWN, 10);
// resource has initial UNKNOWN ResourceAvailability and no Availability records. simulate an avail report
// coming from the agent and setting the initial avail to UP.
AvailabilityReport availReport = new AvailabilityReport(AGENT_NAME);
availReport.addAvailability(new Datum(resource.getId(), AvailabilityType.UP, System.currentTimeMillis()));
AvailabilityManagerLocal availManager = LookupUtil.getAvailabilityManager();
availManager.mergeAvailabilityReport(availReport);
// wait for our JMS messages to process and see if we get any alerts
Thread.sleep(4000);
PageList<Alert> alerts = getAlerts(resource.getId());
assert alerts.size() == 0 : "No alert should have fired on the initial avail reporting: " + alerts;
// Now simulate the down avail
availReport = new AvailabilityReport(AGENT_NAME);
availReport
.addAvailability(new Datum(resource.getId(), AvailabilityType.DOWN, System.currentTimeMillis() + 10));
availManager.mergeAvailabilityReport(availReport);
// wait for our JMS messages to process and see if we get any alerts
Thread.sleep(4000);