Search in sources :

Example 26 with ThresholdEvaluatorStateHighLow

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

the class ThresholdEvaluatorHighLowTest method testConstructorThresholdNoType.

@Test
public void testConstructorThresholdNoType() {
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalArgumentException("threshold must have a 'type' value set"));
    Threshold threshold = new Threshold();
    threshold.setDsName("ds-name");
    threshold.setDsType("node");
    threshold.setValue(1.0);
    threshold.setRearm(0.5);
    threshold.setTrigger(3);
    ThresholdConfigWrapper wrapper = new ThresholdConfigWrapper(threshold);
    try {
        new ThresholdEvaluatorStateHighLow(wrapper);
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
}
Also used : ThresholdEvaluatorStateHighLow(org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow) ThrowableAnticipator(org.opennms.test.ThrowableAnticipator) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Example 27 with ThresholdEvaluatorStateHighLow

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

the class ThresholdEvaluatorHighLowTest method testIsRearmExceededLowTriggeredEqual.

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

Example 28 with ThresholdEvaluatorStateHighLow

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

the class ThresholdEvaluatorHighLowTest method testEvaluateHighTriggerTwice.

@Test
public void testEvaluateHighTriggerTwice() {
    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);
    ThresholdEvaluatorState item = new ThresholdEvaluatorStateHighLow(wrapper);
    Status status = item.evaluate(100.0);
    assertEquals("first threshold evaluation status", Status.NO_CHANGE, status);
    status = item.evaluate(100.0);
    assertEquals("second 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 29 with ThresholdEvaluatorStateHighLow

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

the class ThresholdEvaluatorHighLowTest method testIsRearmExceededHighNoTriggeredAbove.

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

Example 30 with ThresholdEvaluatorStateHighLow

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

the class ThresholdEvaluatorHighLowTest method testIsRearmExceededLowNoTriggeredBelow.

@Test
public void testIsRearmExceededLowNoTriggeredBelow() {
    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("rearm should not be exceeded", item.isRearmExceeded(0.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