use of org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow in project opennms by OpenNMS.
the class ThresholdEvaluatorHighLowTest method testIsTriggerCountExceededNotAtTriggerValueTwo.
@Test
public void testIsTriggerCountExceededNotAtTriggerValueTwo() {
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);
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.NO_CHANGE, status);
assertFalse("trigger count should not be exeeded after only exceeding value once", item.isTriggerCountExceeded());
}
use of org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow in project opennms by OpenNMS.
the class ThresholdEvaluatorHighLowTest method testEvaluateHighTriggerOnce.
@Test
public void testEvaluateHighTriggerOnce() {
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("threshold evaluation status", Status.TRIGGERED, status);
}
use of org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow in project opennms by OpenNMS.
the class ThresholdEvaluatorHighLowTest method testIsThresholdExceededBogusType.
@Test
public void testIsThresholdExceededBogusType() {
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(98.0);
} catch (Throwable t) {
ta.throwableReceived(t);
}
ta.verifyAnticipated();
}
use of org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow in project opennms by OpenNMS.
the class ThresholdEvaluatorHighLowTest method testIsThresholdExceededLowNotTriggeredAbove.
@Test
public void testIsThresholdExceededLowNotTriggeredAbove() {
Threshold threshold = new Threshold();
threshold.setType(ThresholdType.LOW);
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("threshold should not be exceeded", item.isThresholdExceeded(100.0));
}
use of org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow in project opennms by OpenNMS.
the class ThresholdEvaluatorHighLowTest method testIsThresholdExceededHighTriggeredAbove.
@Test
public void testIsThresholdExceededHighTriggeredAbove() {
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(100.0));
}
Aggregations