use of org.opennms.netmgt.config.threshd.Threshold in project opennms by OpenNMS.
the class ThresholdEvaluatorHighLowTest method testConstructorThresholdNoDsName.
@Test
public void testConstructorThresholdNoDsName() {
ThrowableAnticipator ta = new ThrowableAnticipator();
ta.anticipate(new IllegalArgumentException("threshold must have a 'ds-name' value set"));
Threshold threshold = new Threshold();
threshold.setType(ThresholdType.HIGH);
threshold.setDsType("node");
threshold.setValue(1.0);
threshold.setRearm(0.5);
threshold.setTrigger(3);
ThresholdConfigWrapper wrapper = new ThresholdConfigWrapper(threshold);
try {
new ThresholdEvaluatorStateHighLow(wrapper);
} catch (Throwable t) {
ta.throwableReceived(t);
}
ta.verifyAnticipated();
}
use of org.opennms.netmgt.config.threshd.Threshold in project opennms by OpenNMS.
the class ThresholdEvaluatorHighLowTest method testIsRearmExceededHighTriggeredEqual.
@Test
public void testIsRearmExceededHighTriggeredEqual() {
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("rearm should be exceeded", item.isRearmExceeded(0.5));
}
use of org.opennms.netmgt.config.threshd.Threshold in project opennms by OpenNMS.
the class ThresholdEvaluatorHighLowTest method testIsRearmExceededLowTriggeredAbove.
@Test
public void testIsRearmExceededLowTriggeredAbove() {
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);
assertTrue("rearm should be exceeded", item.isRearmExceeded(1.0));
}
use of org.opennms.netmgt.config.threshd.Threshold in project opennms by OpenNMS.
the class ThresholdEvaluatorRelativeChangeTest method testEvaluateOnce.
@Test
public void testEvaluateOnce() {
Threshold threshold = new Threshold();
threshold.setType(ThresholdType.RELATIVE_CHANGE);
threshold.setDsName("ds-name");
threshold.setDsType("node");
threshold.setValue(0.9);
threshold.setRearm(0.5);
threshold.setTrigger(3);
ThresholdConfigWrapper wrapper = new ThresholdConfigWrapper(threshold);
ThresholdEvaluatorStateRelativeChange evaluator = new ThresholdEvaluatorStateRelativeChange(wrapper);
assertEquals("should not trigger", Status.NO_CHANGE, evaluator.evaluate(10.0));
}
use of org.opennms.netmgt.config.threshd.Threshold in project opennms by OpenNMS.
the class ThresholdEvaluatorRelativeChangeTest method testEvaluateTwiceNoTriggerHighBelow.
@Test
public void testEvaluateTwiceNoTriggerHighBelow() {
Threshold threshold = new Threshold();
threshold.setType(ThresholdType.RELATIVE_CHANGE);
threshold.setDsName("ds-name");
threshold.setDsType("node");
threshold.setValue(1.1);
threshold.setRearm(0.5);
threshold.setTrigger(3);
ThresholdConfigWrapper wrapper = new ThresholdConfigWrapper(threshold);
ThresholdEvaluatorStateRelativeChange evaluator = new ThresholdEvaluatorStateRelativeChange(wrapper);
assertEquals("should not trigger", Status.NO_CHANGE, evaluator.evaluate(10.0));
assertEquals("should not trigger", Status.NO_CHANGE, evaluator.evaluate(10.5));
}
Aggregations