Search in sources :

Example 86 with ThrowableAnticipator

use of org.opennms.test.ThrowableAnticipator in project opennms by OpenNMS.

the class ThresholdEvaluatorHighLowTest method testIsRearmExceededBogusType.

@Test
public void testIsRearmExceededBogusType() {
    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(0.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 87 with ThrowableAnticipator

use of org.opennms.test.ThrowableAnticipator in project opennms by OpenNMS.

the class ThresholdEvaluatorHighLowTest method testConstructorThresholdNoValue.

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

use of org.opennms.test.ThrowableAnticipator 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 89 with ThrowableAnticipator

use of org.opennms.test.ThrowableAnticipator 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 90 with ThrowableAnticipator

use of org.opennms.test.ThrowableAnticipator in project opennms by OpenNMS.

the class ThresholdEvaluatorHighLowTest method testConstructorThresholdNull.

@Test
public void testConstructorThresholdNull() {
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalArgumentException("threshold argument cannot be null"));
    try {
        new ThresholdEvaluatorStateHighLow(null);
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
}
Also used : ThresholdEvaluatorStateHighLow(org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow) ThrowableAnticipator(org.opennms.test.ThrowableAnticipator) Test(org.junit.Test)

Aggregations

ThrowableAnticipator (org.opennms.test.ThrowableAnticipator)105 Test (org.junit.Test)44 Ignore (org.junit.Ignore)12 ThresholdEvaluatorStateHighLow (org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow)9 Threshold (org.opennms.netmgt.config.threshd.Threshold)8 BindException (org.springframework.validation.BindException)8 Date (java.util.Date)6 LocationMonitorIdCommand (org.opennms.web.svclayer.model.LocationMonitorIdCommand)6 MarshallingResourceFailureException (org.opennms.core.xml.MarshallingResourceFailureException)4 DistributedStatusDetailsCommand (org.opennms.web.svclayer.model.DistributedStatusDetailsCommand)4 FileSystemResource (org.springframework.core.io.FileSystemResource)4 InputStreamResource (org.springframework.core.io.InputStreamResource)4 Resource (org.springframework.core.io.Resource)4 Errors (org.springframework.validation.Errors)4 File (java.io.File)3 IOException (java.io.IOException)3 SQLException (java.sql.SQLException)3 JdbcFilterDao (org.opennms.netmgt.filter.JdbcFilterDao)2 EventBuilder (org.opennms.netmgt.model.events.EventBuilder)2 RrdException (org.opennms.netmgt.rrd.RrdException)2