Status status = item.evaluate(dsValue); Event event = item.getEventForState(status, date, dsValue, resource); if (event != null) {
@Test public void testEvaluateHighTriggerTwiceNoRetrigger() { 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); status = item.evaluate(100.0); assertEquals("third threshold evaluation status", Status.NO_CHANGE, status); status = item.evaluate(100.0); assertEquals("fourth threshold evaluation status", Status.NO_CHANGE, status); }
@Test public void testEvaluateHighTriggerRearmTriggerAgain() { 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("first threshold evaluation status", Status.TRIGGERED, status); status = item.evaluate(0.0); assertEquals("second threshold evaluation status", Status.RE_ARMED, status); status = item.evaluate(100.0); assertEquals("third threshold evaluation status", Status.TRIGGERED, status); }
@Test public void testEvaluateHighTriggerRearm() { 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("first threshold evaluation status", Status.TRIGGERED, status); status = item.evaluate(0.0); assertEquals("second threshold evaluation status", Status.RE_ARMED, status); }
@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); }
@Test public void testEvaluateHighNoTriggerTwice() { 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("threshold evaluation status", Status.NO_CHANGE, status); }
@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); }
@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); }
@Test public void testEvaluateLowTriggerOnce() { 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); ThresholdEvaluatorState item = new ThresholdEvaluatorStateHighLow(wrapper); Status status = item.evaluate(100.0); assertEquals("threshold evaluation status", Status.NO_CHANGE, status); }