Search in sources :

Example 11 with ThresholdEvaluatorStateRelativeChange

use of org.opennms.netmgt.threshd.ThresholdEvaluatorRelativeChange.ThresholdEvaluatorStateRelativeChange 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));
}
Also used : ThresholdEvaluatorStateRelativeChange(org.opennms.netmgt.threshd.ThresholdEvaluatorRelativeChange.ThresholdEvaluatorStateRelativeChange) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Example 12 with ThresholdEvaluatorStateRelativeChange

use of org.opennms.netmgt.threshd.ThresholdEvaluatorRelativeChange.ThresholdEvaluatorStateRelativeChange 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));
}
Also used : ThresholdEvaluatorStateRelativeChange(org.opennms.netmgt.threshd.ThresholdEvaluatorRelativeChange.ThresholdEvaluatorStateRelativeChange) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Example 13 with ThresholdEvaluatorStateRelativeChange

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

the class ThresholdEvaluatorRelativeChangeTest method testGetEventForStateDefaultUEIS.

@Test
public void testGetEventForStateDefaultUEIS() {
    Threshold threshold = new Threshold();
    threshold.setType(ThresholdType.RELATIVE_CHANGE);
    threshold.setDsName("ds-name");
    threshold.setDsType("node");
    threshold.setValue(99.0);
    threshold.setRearm(95.0);
    threshold.setTrigger(1);
    ThresholdConfigWrapper wrapper = new ThresholdConfigWrapper(threshold);
    ThresholdEvaluatorStateRelativeChange item = new ThresholdEvaluatorStateRelativeChange(wrapper);
    Event event = item.getEventForState(Status.TRIGGERED, new Date(), 100.0, null);
    assertEquals("UEI should be the relativeChangeThresholdTriggerd", EventConstants.RELATIVE_CHANGE_THRESHOLD_EVENT_UEI, event.getUei());
}
Also used : Event(org.opennms.netmgt.xml.event.Event) ThresholdEvaluatorStateRelativeChange(org.opennms.netmgt.threshd.ThresholdEvaluatorRelativeChange.ThresholdEvaluatorStateRelativeChange) Date(java.util.Date) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Example 14 with ThresholdEvaluatorStateRelativeChange

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

the class ThresholdEvaluatorRelativeChangeTest method testGetEventForStateCustomUEIS.

@Test
public void testGetEventForStateCustomUEIS() {
    String triggeredUEI = "uei.opennms.org/custom/relativeChangeThresholdTriggered";
    Threshold threshold = new Threshold();
    threshold.setType(ThresholdType.RELATIVE_CHANGE);
    threshold.setDsName("ds-name");
    threshold.setDsType("node");
    threshold.setValue(99.0);
    threshold.setRearm(95.0);
    threshold.setTrigger(1);
    threshold.setTriggeredUEI(triggeredUEI);
    ThresholdConfigWrapper wrapper = new ThresholdConfigWrapper(threshold);
    ThresholdEvaluatorStateRelativeChange item = new ThresholdEvaluatorStateRelativeChange(wrapper);
    Event event = item.getEventForState(Status.TRIGGERED, new Date(), 100.0, null);
    assertEquals("UEI should be the uei.opennms.org/custom/relativeChangeThresholdTriggered", triggeredUEI, event.getUei());
}
Also used : Event(org.opennms.netmgt.xml.event.Event) ThresholdEvaluatorStateRelativeChange(org.opennms.netmgt.threshd.ThresholdEvaluatorRelativeChange.ThresholdEvaluatorStateRelativeChange) Date(java.util.Date) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Example 15 with ThresholdEvaluatorStateRelativeChange

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

the class ThresholdEvaluatorRelativeChangeTest method testEvaluateTwiceTriggerLowEqual.

@Test
public void testEvaluateTwiceTriggerLowEqual() {
    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));
    assertEquals("should trigger", Status.TRIGGERED, evaluator.evaluate(9.0));
}
Also used : ThresholdEvaluatorStateRelativeChange(org.opennms.netmgt.threshd.ThresholdEvaluatorRelativeChange.ThresholdEvaluatorStateRelativeChange) 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