Search in sources :

Example 6 with ThresholdEvaluatorStateAbsoluteChange

use of org.opennms.netmgt.threshd.ThresholdEvaluatorAbsoluteChange.ThresholdEvaluatorStateAbsoluteChange in project opennms by OpenNMS.

the class ThresholdEvaluatorAbsoluteChangeTest method testGetEventForStateCustomUEIS.

@Test
public void testGetEventForStateCustomUEIS() {
    String triggeredUEI = "uei.opennms.org/custom/absoluteChangeThresholdTriggered";
    Threshold threshold = new Threshold();
    threshold.setType(ThresholdType.ABSOLUTE_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);
    ThresholdEvaluatorStateAbsoluteChange item = new ThresholdEvaluatorStateAbsoluteChange(wrapper);
    Event event = item.getEventForState(Status.TRIGGERED, new Date(), 100.0, null);
    assertEquals("UEI should be the " + triggeredUEI, triggeredUEI, event.getUei());
}
Also used : ThresholdEvaluatorStateAbsoluteChange(org.opennms.netmgt.threshd.ThresholdEvaluatorAbsoluteChange.ThresholdEvaluatorStateAbsoluteChange) Event(org.opennms.netmgt.xml.event.Event) Date(java.util.Date) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Example 7 with ThresholdEvaluatorStateAbsoluteChange

use of org.opennms.netmgt.threshd.ThresholdEvaluatorAbsoluteChange.ThresholdEvaluatorStateAbsoluteChange in project opennms by OpenNMS.

the class ThresholdEvaluatorAbsoluteChangeTest method testEvaluateTwiceTriggerHighAbove.

@Test
public void testEvaluateTwiceTriggerHighAbove() {
    Threshold threshold = new Threshold();
    threshold.setType(ThresholdType.ABSOLUTE_CHANGE);
    threshold.setDsName("ds-name");
    threshold.setDsType("node");
    threshold.setValue(1.0);
    threshold.setRearm(0.5);
    threshold.setTrigger(3);
    ThresholdConfigWrapper wrapper = new ThresholdConfigWrapper(threshold);
    ThresholdEvaluatorStateAbsoluteChange evaluator = new ThresholdEvaluatorStateAbsoluteChange(wrapper);
    assertEquals("should not trigger", Status.NO_CHANGE, evaluator.evaluate(10.0));
    assertEquals("should trigger", Status.TRIGGERED, evaluator.evaluate(12.0));
}
Also used : ThresholdEvaluatorStateAbsoluteChange(org.opennms.netmgt.threshd.ThresholdEvaluatorAbsoluteChange.ThresholdEvaluatorStateAbsoluteChange) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Example 8 with ThresholdEvaluatorStateAbsoluteChange

use of org.opennms.netmgt.threshd.ThresholdEvaluatorAbsoluteChange.ThresholdEvaluatorStateAbsoluteChange in project opennms by OpenNMS.

the class ThresholdEvaluatorAbsoluteChangeTest method testEvaluateTwiceTriggerLowBelow.

@Test
public void testEvaluateTwiceTriggerLowBelow() {
    Threshold threshold = new Threshold();
    threshold.setType(ThresholdType.ABSOLUTE_CHANGE);
    threshold.setDsName("ds-name");
    threshold.setDsType("node");
    threshold.setValue(-1.0);
    threshold.setRearm(0.5);
    threshold.setTrigger(3);
    ThresholdConfigWrapper wrapper = new ThresholdConfigWrapper(threshold);
    ThresholdEvaluatorStateAbsoluteChange evaluator = new ThresholdEvaluatorStateAbsoluteChange(wrapper);
    assertEquals("should not trigger", Status.NO_CHANGE, evaluator.evaluate(10.0));
    assertEquals("should trigger", Status.TRIGGERED, evaluator.evaluate(8.0));
}
Also used : ThresholdEvaluatorStateAbsoluteChange(org.opennms.netmgt.threshd.ThresholdEvaluatorAbsoluteChange.ThresholdEvaluatorStateAbsoluteChange) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Example 9 with ThresholdEvaluatorStateAbsoluteChange

use of org.opennms.netmgt.threshd.ThresholdEvaluatorAbsoluteChange.ThresholdEvaluatorStateAbsoluteChange in project opennms by OpenNMS.

the class ThresholdEvaluatorAbsoluteChangeTest method testEvaluateTwiceNoTriggerHighBelow.

@Test
public void testEvaluateTwiceNoTriggerHighBelow() {
    Threshold threshold = new Threshold();
    threshold.setType(ThresholdType.ABSOLUTE_CHANGE);
    threshold.setDsName("ds-name");
    threshold.setDsType("node");
    threshold.setValue(1.0);
    threshold.setRearm(0.5);
    threshold.setTrigger(3);
    ThresholdConfigWrapper wrapper = new ThresholdConfigWrapper(threshold);
    ThresholdEvaluatorStateAbsoluteChange evaluator = new ThresholdEvaluatorStateAbsoluteChange(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 : ThresholdEvaluatorStateAbsoluteChange(org.opennms.netmgt.threshd.ThresholdEvaluatorAbsoluteChange.ThresholdEvaluatorStateAbsoluteChange) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Example 10 with ThresholdEvaluatorStateAbsoluteChange

use of org.opennms.netmgt.threshd.ThresholdEvaluatorAbsoluteChange.ThresholdEvaluatorStateAbsoluteChange in project opennms by OpenNMS.

the class ThresholdEvaluatorAbsoluteChangeTest method testConstructor.

@Test
public void testConstructor() {
    Threshold threshold = new Threshold();
    threshold.setType(ThresholdType.ABSOLUTE_CHANGE);
    threshold.setDsName("ds-name");
    threshold.setDsType("interface");
    threshold.setValue(0.9);
    threshold.setRearm(0.5);
    threshold.setTrigger(3);
    ThresholdConfigWrapper wrapper = new ThresholdConfigWrapper(threshold);
    new ThresholdEvaluatorStateAbsoluteChange(wrapper);
}
Also used : ThresholdEvaluatorStateAbsoluteChange(org.opennms.netmgt.threshd.ThresholdEvaluatorAbsoluteChange.ThresholdEvaluatorStateAbsoluteChange) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)14 ThresholdEvaluatorStateAbsoluteChange (org.opennms.netmgt.threshd.ThresholdEvaluatorAbsoluteChange.ThresholdEvaluatorStateAbsoluteChange)14 Threshold (org.opennms.netmgt.config.threshd.Threshold)13 Date (java.util.Date)4 Event (org.opennms.netmgt.xml.event.Event)3 ThrowableAnticipator (org.opennms.test.ThrowableAnticipator)1