use of org.opennms.netmgt.config.threshd.Threshold in project opennms by OpenNMS.
the class ThresholdEvaluatorAbsoluteChangeTest method testEvaluateTwiceTriggerLowBelow.
@Test
public void testEvaluateTwiceTriggerLowBelow() {
Threshold threshold = new Threshold();
threshold.setType(ThresholdType.ABSOLUTE_CHANGE);
threshold.setDsName("ds-name");
threshold.setDsType("node");
threshold.setValue(-1.0);
threshold.setRearm(0.5);
threshold.setTrigger(3);
ThresholdConfigWrapper wrapper = new ThresholdConfigWrapper(threshold);
ThresholdEvaluatorStateAbsoluteChange evaluator = new ThresholdEvaluatorStateAbsoluteChange(wrapper);
assertEquals("should not trigger", Status.NO_CHANGE, evaluator.evaluate(10.0));
assertEquals("should trigger", Status.TRIGGERED, evaluator.evaluate(8.0));
}
use of org.opennms.netmgt.config.threshd.Threshold in project opennms by OpenNMS.
the class ThresholdEvaluatorAbsoluteChangeTest method testEvaluateTwiceNoTriggerHighBelow.
@Test
public void testEvaluateTwiceNoTriggerHighBelow() {
Threshold threshold = new Threshold();
threshold.setType(ThresholdType.ABSOLUTE_CHANGE);
threshold.setDsName("ds-name");
threshold.setDsType("node");
threshold.setValue(1.0);
threshold.setRearm(0.5);
threshold.setTrigger(3);
ThresholdConfigWrapper wrapper = new ThresholdConfigWrapper(threshold);
ThresholdEvaluatorStateAbsoluteChange evaluator = new ThresholdEvaluatorStateAbsoluteChange(wrapper);
assertEquals("should not trigger", Status.NO_CHANGE, evaluator.evaluate(10.0));
assertEquals("should not trigger", Status.NO_CHANGE, evaluator.evaluate(10.5));
}
use of org.opennms.netmgt.config.threshd.Threshold in project opennms by OpenNMS.
the class ThresholdEvaluatorHighLowTest method testIsTriggerCountExceededNotAfterReArm.
@Test
public void testIsTriggerCountExceededNotAfterReArm() {
Threshold threshold = new Threshold();
threshold.setType(ThresholdType.HIGH);
threshold.setDsName("ds-name");
threshold.setDsType("node");
threshold.setValue(99.0);
threshold.setRearm(0.5);
threshold.setTrigger(1);
ThresholdConfigWrapper wrapper = new ThresholdConfigWrapper(threshold);
ThresholdEvaluatorStateHighLow item = new ThresholdEvaluatorStateHighLow(wrapper);
assertFalse("trigger count should not be exeeded before exceeding value", item.isTriggerCountExceeded());
Status status = item.evaluate(100.0);
assertEquals("first threshold evaluation status", Status.TRIGGERED, status);
assertTrue("trigger count should be exeeded after exceeding value", item.isTriggerCountExceeded());
status = item.evaluate(0.0);
assertEquals("first threshold evaluation status", Status.RE_ARMED, status);
assertFalse("trigger count should be reset after being rearmed", item.isTriggerCountExceeded());
}
use of org.opennms.netmgt.config.threshd.Threshold in project opennms by OpenNMS.
the class ThresholdEvaluatorHighLowTest method testEvaluateHighNoTriggerTwice.
@Test
public void testEvaluateHighNoTriggerTwice() {
Threshold threshold = new Threshold();
threshold.setType(ThresholdType.HIGH);
threshold.setDsName("ds-name");
threshold.setDsType("node");
threshold.setValue(99.0);
threshold.setRearm(0.5);
threshold.setTrigger(2);
ThresholdConfigWrapper wrapper = new ThresholdConfigWrapper(threshold);
ThresholdEvaluatorState item = new ThresholdEvaluatorStateHighLow(wrapper);
Status status = item.evaluate(100.0);
assertEquals("threshold evaluation status", Status.NO_CHANGE, status);
}
use of org.opennms.netmgt.config.threshd.Threshold in project opennms by OpenNMS.
the class ThresholdEvaluatorHighLowTest method testEvaluateHighTriggerRearm.
@Test
public void testEvaluateHighTriggerRearm() {
Threshold threshold = new Threshold();
threshold.setType(ThresholdType.HIGH);
threshold.setDsName("ds-name");
threshold.setDsType("node");
threshold.setValue(99.0);
threshold.setRearm(0.5);
threshold.setTrigger(1);
ThresholdConfigWrapper wrapper = new ThresholdConfigWrapper(threshold);
ThresholdEvaluatorState item = new ThresholdEvaluatorStateHighLow(wrapper);
Status status = item.evaluate(100.0);
assertEquals("first threshold evaluation status", Status.TRIGGERED, status);
status = item.evaluate(0.0);
assertEquals("second threshold evaluation status", Status.RE_ARMED, status);
}
Aggregations