Search in sources :

Example 6 with ThresholdEvaluatorStateHighLow

use of org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow 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 7 with ThresholdEvaluatorStateHighLow

use of org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow 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 8 with ThresholdEvaluatorStateHighLow

use of org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow in project opennms by OpenNMS.

the class ThresholdEvaluatorHighLowTest method testIsThresholdExceededBogusType.

@Test
public void testIsThresholdExceededBogusType() {
    Threshold threshold = new Threshold();
    threshold.setType(ThresholdType.RELATIVE_CHANGE);
    threshold.setDsName("ds-name");
    threshold.setDsType("node");
    threshold.setValue(99.0);
    threshold.setRearm(0.5);
    threshold.setTrigger(1);
    ThresholdConfigWrapper wrapper = new ThresholdConfigWrapper(threshold);
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalStateException("This thresholding strategy can only be used for thresholding types of 'high' and 'low'."));
    try {
        ThresholdEvaluatorStateHighLow item = new ThresholdEvaluatorStateHighLow(wrapper);
        item.isThresholdExceeded(98.0);
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
}
Also used : ThresholdEvaluatorStateHighLow(org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow) Threshold(org.opennms.netmgt.config.threshd.Threshold) ThrowableAnticipator(org.opennms.test.ThrowableAnticipator) Test(org.junit.Test)

Example 9 with ThresholdEvaluatorStateHighLow

use of org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow in project opennms by OpenNMS.

the class ThresholdEvaluatorHighLowTest method testIsThresholdExceededLowNotTriggeredAbove.

@Test
public void testIsThresholdExceededLowNotTriggeredAbove() {
    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);
    assertFalse("threshold should not be exceeded", item.isThresholdExceeded(100.0));
}
Also used : ThresholdEvaluatorStateHighLow(org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Example 10 with ThresholdEvaluatorStateHighLow

use of org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow in project opennms by OpenNMS.

the class ThresholdEvaluatorHighLowTest method testIsThresholdExceededHighTriggeredAbove.

@Test
public void testIsThresholdExceededHighTriggeredAbove() {
    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("threshold should be exceeded", item.isThresholdExceeded(100.0));
}
Also used : ThresholdEvaluatorStateHighLow(org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)34 ThresholdEvaluatorStateHighLow (org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow)34 Threshold (org.opennms.netmgt.config.threshd.Threshold)33 Status (org.opennms.netmgt.threshd.ThresholdEvaluatorState.Status)11 ThrowableAnticipator (org.opennms.test.ThrowableAnticipator)9 Date (java.util.Date)2 Event (org.opennms.netmgt.xml.event.Event)2