Search in sources :

Example 46 with Threshold

use of org.opennms.netmgt.config.threshd.Threshold in project opennms by OpenNMS.

the class ThresholdEvaluatorHighLowTest method testConstructorThresholdNoDsName.

@Test
public void testConstructorThresholdNoDsName() {
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalArgumentException("threshold must have a 'ds-name' value set"));
    Threshold threshold = new Threshold();
    threshold.setType(ThresholdType.HIGH);
    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 47 with Threshold

use of org.opennms.netmgt.config.threshd.Threshold in project opennms by OpenNMS.

the class ThresholdEvaluatorHighLowTest method testIsRearmExceededHighTriggeredEqual.

@Test
public void testIsRearmExceededHighTriggeredEqual() {
    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("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 48 with Threshold

use of org.opennms.netmgt.config.threshd.Threshold in project opennms by OpenNMS.

the class ThresholdEvaluatorHighLowTest method testIsRearmExceededLowTriggeredAbove.

@Test
public void testIsRearmExceededLowTriggeredAbove() {
    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(1.0));
}
Also used : ThresholdEvaluatorStateHighLow(org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Example 49 with Threshold

use of org.opennms.netmgt.config.threshd.Threshold 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 50 with Threshold

use of org.opennms.netmgt.config.threshd.Threshold 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)

Aggregations

Threshold (org.opennms.netmgt.config.threshd.Threshold)68 Test (org.junit.Test)64 ThresholdEvaluatorStateHighLow (org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow)33 ThresholdEvaluatorStateRelativeChange (org.opennms.netmgt.threshd.ThresholdEvaluatorRelativeChange.ThresholdEvaluatorStateRelativeChange)18 ThresholdEvaluatorStateAbsoluteChange (org.opennms.netmgt.threshd.ThresholdEvaluatorAbsoluteChange.ThresholdEvaluatorStateAbsoluteChange)13 Status (org.opennms.netmgt.threshd.ThresholdEvaluatorState.Status)11 Date (java.util.Date)10 Event (org.opennms.netmgt.xml.event.Event)8 ThrowableAnticipator (org.opennms.test.ThrowableAnticipator)8 ModelAndView (org.springframework.web.servlet.ModelAndView)4 ThresholdingConfigFactory (org.opennms.netmgt.config.ThresholdingConfigFactory)3 ServletException (javax.servlet.ServletException)2 Group (org.opennms.netmgt.config.threshd.Group)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Expression (org.opennms.netmgt.config.threshd.Expression)1 ResourceFilter (org.opennms.netmgt.config.threshd.ResourceFilter)1