Add tests for null checks in DefaultRulesEngine

Refines c994ffb01a
master
Mahmoud Ben Hassine 4 years ago
parent 2228fb2a61
commit 6de08b45a9
No known key found for this signature in database
GPG Key ID: 2B4156D07E8A1737

@ -37,7 +37,9 @@ import org.assertj.core.api.Assertions;
import org.jeasy.rules.annotation.Action; import org.jeasy.rules.annotation.Action;
import org.jeasy.rules.annotation.Condition; import org.jeasy.rules.annotation.Condition;
import org.jeasy.rules.annotation.Priority; import org.jeasy.rules.annotation.Priority;
import org.jeasy.rules.api.Facts;
import org.jeasy.rules.api.RuleListener; import org.jeasy.rules.api.RuleListener;
import org.jeasy.rules.api.Rules;
import org.jeasy.rules.api.RulesEngineListener; import org.jeasy.rules.api.RulesEngineListener;
import org.jeasy.rules.api.RulesEngineParameters; import org.jeasy.rules.api.RulesEngineParameters;
import org.junit.After; import org.junit.After;
@ -64,6 +66,26 @@ public class DefaultRulesEngineTest extends AbstractTest {
annotatedRule = new AnnotatedRule(); annotatedRule = new AnnotatedRule();
} }
@Test(expected = NullPointerException.class)
public void whenFireRules_thenNullRulesShouldNotBeAccepted() {
rulesEngine.fire(null, new Facts());
}
@Test(expected = NullPointerException.class)
public void whenFireRules_thenNullFactsShouldNotBeAccepted() {
rulesEngine.fire(new Rules(), null);
}
@Test(expected = NullPointerException.class)
public void whenCheckRules_thenNullRulesShouldNotBeAccepted() {
rulesEngine.check(null, new Facts());
}
@Test(expected = NullPointerException.class)
public void whenCheckRules_thenNullFactsShouldNotBeAccepted() {
rulesEngine.check(new Rules(), null);
}
@Test @Test
public void whenConditionIsTrue_thenActionShouldBeExecuted() throws Exception { public void whenConditionIsTrue_thenActionShouldBeExecuted() throws Exception {
// Given // Given

Loading…
Cancel
Save