Remove usage of deprecated APIs

pull/324/head
Mahmoud Ben Hassine
parent bf688ddf12
commit 01d8861d44
No known key found for this signature in database
GPG Key ID: 2B4156D07E8A1737

@ -213,7 +213,7 @@ public class DefaultRulesEngineTest extends AbstractTest {
// Then
Assertions.assertThat(engineParameters).isNotSameAs(parameters);
Assertions.assertThat(engineParameters).isEqualToComparingFieldByField(parameters);
Assertions.assertThat(engineParameters).usingRecursiveComparison().isEqualTo(parameters);
}
@Test

@ -36,11 +36,10 @@ import org.apache.commons.jexl3.JexlBuilder;
import org.apache.commons.jexl3.JexlEngine;
import org.apache.commons.jexl3.JexlException;
import org.apache.commons.jexl3.introspection.JexlSandbox;
import org.assertj.core.api.Assertions;
import org.jeasy.rules.api.Action;
import org.jeasy.rules.api.Facts;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
/**
* @author Lauri Kimmel
@ -48,8 +47,6 @@ import org.junit.rules.ExpectedException;
*/
public class JexlActionTest {
@Rule
public final ExpectedException expectedException = ExpectedException.none();
@Test
public void testJexlActionExecution() throws Exception {
@ -89,17 +86,17 @@ public class JexlActionTest {
}
@Test
public void testJexlActionExecutionWithFailure() throws Exception {
public void testJexlActionExecutionWithFailure() {
// given
expectedException.expect(JexlException.Method.class);
expectedException.expectMessage("org.jeasy.rules.jexl.JexlAction.<init>@1:7 unsolvable function/method 'setBlah'");
Action action = new JexlAction("person.setBlah(true);");
Facts facts = new Facts();
Person foo = new Person("foo", 20);
facts.put("person", foo);
// when
action.execute(facts);
Assertions.assertThatThrownBy(() -> action.execute(facts))
.isInstanceOf(JexlException.Method.class)
.hasMessage("org.jeasy.rules.jexl.JexlAction.<init>@1:7 unsolvable function/method 'setBlah'");
// then
// excepted exception

@ -39,13 +39,13 @@ import java.util.Map;
import org.apache.commons.jexl3.JexlBuilder;
import org.apache.commons.jexl3.JexlEngine;
import org.assertj.core.api.Assertions;
import org.jeasy.rules.api.Rule;
import org.jeasy.rules.api.Rules;
import org.jeasy.rules.support.reader.JsonRuleDefinitionReader;
import org.jeasy.rules.support.composite.UnitRuleGroup;
import org.jeasy.rules.support.reader.YamlRuleDefinitionReader;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
@ -72,9 +72,6 @@ public class JexlRuleFactoryTest {
});
}
@org.junit.Rule
public ExpectedException expectedException = ExpectedException.none();
@Parameter(0)
public JexlRuleFactory factory;
@ -161,42 +158,42 @@ public class JexlRuleFactoryTest {
}
@Test
public void testRuleCreationFromFileReader_withInvalidCompositeRuleType() throws Exception {
public void testRuleCreationFromFileReader_withInvalidCompositeRuleType() {
// given
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Invalid composite rule type, must be one of [UnitRuleGroup, ConditionalRuleGroup, ActivationRuleGroup]");
File rulesDescriptor = new File("src/test/resources/composite-rule-invalid-composite-rule-type." + ext);
// when
factory.createRule(new FileReader(rulesDescriptor));
Assertions.assertThatThrownBy(() -> factory.createRule(new FileReader(rulesDescriptor)))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Invalid composite rule type, must be one of [UnitRuleGroup, ConditionalRuleGroup, ActivationRuleGroup]");
// then
// expected exception
}
@Test
public void testRuleCreationFromFileReader_withEmptyComposingRules() throws Exception {
public void testRuleCreationFromFileReader_withEmptyComposingRules() {
// given
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Composite rules must have composing rules specified");
File rulesDescriptor = new File("src/test/resources/composite-rule-invalid-empty-composing-rules." + ext);
// when
factory.createRule(new FileReader(rulesDescriptor));
Assertions.assertThatThrownBy(() -> factory.createRule(new FileReader(rulesDescriptor)))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Composite rules must have composing rules specified");
// then
// expected exception
}
@Test
public void testRuleCreationFromFileReader_withNonCompositeRuleDeclaresComposingRules() throws Exception {
public void testRuleCreationFromFileReader_withNonCompositeRuleDeclaresComposingRules() {
// given
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Non-composite rules cannot have composing rules");
File rulesDescriptor = new File("src/test/resources/non-composite-rule-with-composing-rules." + ext);
// when
factory.createRule(new FileReader(rulesDescriptor));
Assertions.assertThatThrownBy(() -> factory.createRule(new FileReader(rulesDescriptor)))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Non-composite rules cannot have composing rules");
// then
// expected exception

Loading…
Cancel
Save