use of org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow in project opennms by OpenNMS.
the class ThresholdEvaluatorHighLowTest method testIsThresholdExceededHighTriggeredEqual.
@Test
public void testIsThresholdExceededHighTriggeredEqual() {
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);
assertTrue("threshold should be exceeded", item.isThresholdExceeded(99.0));
}
use of org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow 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.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow 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.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow 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);
}
use of org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow in project opennms by OpenNMS.
the class ThresholdEvaluatorHighLowTest method testIsRearmExceededBogusType.
@Test
public void testIsRearmExceededBogusType() {
Threshold threshold = new Threshold();
threshold.setType(ThresholdType.RELATIVE_CHANGE);
threshold.setDsName("ds-name");
threshold.setDsType("node");
threshold.setValue(99.0);
threshold.setRearm(0.5);
threshold.setTrigger(1);
ThresholdConfigWrapper wrapper = new ThresholdConfigWrapper(threshold);
ThrowableAnticipator ta = new ThrowableAnticipator();
ta.anticipate(new IllegalStateException("This thresholding strategy can only be used for thresholding types of 'high' and 'low'."));
try {
ThresholdEvaluatorStateHighLow item = new ThresholdEvaluatorStateHighLow(wrapper);
item.isThresholdExceeded(0.0);
} catch (Throwable t) {
ta.throwableReceived(t);
}
ta.verifyAnticipated();
}
Aggregations