Search in sources :

Example 1 with Status

use of org.opennms.netmgt.threshd.ThresholdEvaluatorState.Status in project opennms by OpenNMS.

the class ThresholdEvaluatorHighLowTest method testEvaluateHighNoTrigger.

@Test
public void testEvaluateHighNoTrigger() {
    Threshold threshold = new Threshold();
    threshold.setType(ThresholdType.HIGH);
    threshold.setDsName("ds-name");
    threshold.setDsType("node");
    threshold.setValue(101.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.NO_CHANGE, status);
}
Also used : Status(org.opennms.netmgt.threshd.ThresholdEvaluatorState.Status) ThresholdEvaluatorStateHighLow(org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Example 2 with Status

use of org.opennms.netmgt.threshd.ThresholdEvaluatorState.Status in project opennms by OpenNMS.

the class ThresholdEvaluatorHighLowTest method testIsTriggerCountExceededAtTriggerValueOne.

@Test
public void testIsTriggerCountExceededAtTriggerValueOne() {
    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);
    assertFalse("trigger count should not be exeeded before exceeding value", item.isTriggerCountExceeded());
    Status status = item.evaluate(100.0);
    assertEquals("first threshold evaluation status", Status.TRIGGERED, status);
    assertTrue("trigger count should be exeeded after exceeding value (and being triggered)", item.isTriggerCountExceeded());
}
Also used : Status(org.opennms.netmgt.threshd.ThresholdEvaluatorState.Status) ThresholdEvaluatorStateHighLow(org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Example 3 with Status

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

Example 4 with Status

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

Example 5 with Status

use of org.opennms.netmgt.threshd.ThresholdEvaluatorState.Status in project opennms by OpenNMS.

the class ThresholdEvaluatorHighLowTest method testIsTriggerCountExceededNotAfterReArm.

@Test
public void testIsTriggerCountExceededNotAfterReArm() {
    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);
    assertFalse("trigger count should not be exeeded before exceeding value", item.isTriggerCountExceeded());
    Status status = item.evaluate(100.0);
    assertEquals("first threshold evaluation status", Status.TRIGGERED, status);
    assertTrue("trigger count should  be exeeded after exceeding value", item.isTriggerCountExceeded());
    status = item.evaluate(0.0);
    assertEquals("first threshold evaluation status", Status.RE_ARMED, status);
    assertFalse("trigger count should be reset after being rearmed", item.isTriggerCountExceeded());
}
Also used : Status(org.opennms.netmgt.threshd.ThresholdEvaluatorState.Status) ThresholdEvaluatorStateHighLow(org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Aggregations

Status (org.opennms.netmgt.threshd.ThresholdEvaluatorState.Status)12 Test (org.junit.Test)11 Threshold (org.opennms.netmgt.config.threshd.Threshold)11 ThresholdEvaluatorStateHighLow (org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow)11 LinkedList (java.util.LinkedList)1 Event (org.opennms.netmgt.xml.event.Event)1