Search in sources :

Example 16 with ThresholdEvaluatorStateRelativeChange

use of org.opennms.netmgt.threshd.ThresholdEvaluatorRelativeChange.ThresholdEvaluatorStateRelativeChange in project opennms by OpenNMS.

the class ThresholdEvaluatorRelativeChangeTest method testNegativeNumberTriggers.

@Test
public void testNegativeNumberTriggers() {
    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 trigger", Status.TRIGGERED, evaluator.evaluate(-12.0));
}
Also used : ThresholdEvaluatorStateRelativeChange(org.opennms.netmgt.threshd.ThresholdEvaluatorRelativeChange.ThresholdEvaluatorStateRelativeChange) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Example 17 with ThresholdEvaluatorStateRelativeChange

use of org.opennms.netmgt.threshd.ThresholdEvaluatorRelativeChange.ThresholdEvaluatorStateRelativeChange in project opennms by OpenNMS.

the class ThresholdEvaluatorRelativeChangeTest method testNegativeValueNoChange.

@Test
public void testNegativeValueNoChange() {
    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(1);
    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.0));
}
Also used : ThresholdEvaluatorStateRelativeChange(org.opennms.netmgt.threshd.ThresholdEvaluatorRelativeChange.ThresholdEvaluatorStateRelativeChange) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Example 18 with ThresholdEvaluatorStateRelativeChange

use of org.opennms.netmgt.threshd.ThresholdEvaluatorRelativeChange.ThresholdEvaluatorStateRelativeChange in project opennms by OpenNMS.

the class ThresholdEvaluatorRelativeChangeTest method testEvaluateTwiceTriggerHighEqual.

@Test
public void testEvaluateTwiceTriggerHighEqual() {
    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 trigger", Status.TRIGGERED, evaluator.evaluate(11.0));
}
Also used : ThresholdEvaluatorStateRelativeChange(org.opennms.netmgt.threshd.ThresholdEvaluatorRelativeChange.ThresholdEvaluatorStateRelativeChange) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Example 19 with ThresholdEvaluatorStateRelativeChange

use of org.opennms.netmgt.threshd.ThresholdEvaluatorRelativeChange.ThresholdEvaluatorStateRelativeChange in project opennms by OpenNMS.

the class ThresholdEvaluatorRelativeChangeTest method testGetEventForStateNoChange.

@Test
public void testGetEventForStateNoChange() {
    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);
    assertNull("should not have created an event", evaluator.getEventForState(Status.NO_CHANGE, new Date(), 10.0, null));
}
Also used : ThresholdEvaluatorStateRelativeChange(org.opennms.netmgt.threshd.ThresholdEvaluatorRelativeChange.ThresholdEvaluatorStateRelativeChange) Date(java.util.Date) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)19 ThresholdEvaluatorStateRelativeChange (org.opennms.netmgt.threshd.ThresholdEvaluatorRelativeChange.ThresholdEvaluatorStateRelativeChange)19 Threshold (org.opennms.netmgt.config.threshd.Threshold)18 Date (java.util.Date)4 Event (org.opennms.netmgt.xml.event.Event)3 ThrowableAnticipator (org.opennms.test.ThrowableAnticipator)1