From 84c1710394b3b478663dd16ca4b6044a2ac3f3df Mon Sep 17 00:00:00 2001 From: Paolo Bizzarri Date: Fri, 8 Nov 2024 08:38:44 +0100 Subject: [PATCH] [incubator-kie-drools-6136] Migrate drools test coverage to JUnit5 - #3 (#6147) * More unit tests migrated * Migrate more tests to junit5 --- ...stractTupleIndexHashTableIteratorTest.java | 23 +- .../drools/mvel/BaseBetaConstraintsTest.java | 16 +- .../mvel/DefaultBetaConstraintsTest.java | 134 +- .../mvel/DoubleBetaConstraintsTest.java | 51 +- .../org/drools/mvel/FieldConstraintTest.java | 41 +- .../InternalRuleBaseEventSupportTest.java | 80 +- .../mvel/KnowledgeBaseEventSupportTest.java | 80 +- .../LeftTupleIndexHashTableIteratorTest.java | 17 +- .../mvel/QuadroupleBetaConstraintsTest.java | 161 +-- .../RightTupleIndexHashTableIteratorTest.java | 18 +- .../mvel/SingleBetaConstraintsTest.java | 35 +- .../mvel/TripleBetaConstraintsTest.java | 75 +- .../mvel/integrationtests/AlphaNodeTest.java | 72 +- .../mvel/integrationtests/DRLDumperTest.java | 26 +- .../integrationtests/DateCoercionTest.java | 46 +- .../integrationtests/DateComparisonTest.java | 36 +- .../integrationtests/DroolsEventListTest.java | 26 +- .../integrationtests/DroolsFromRHSTest.java | 31 +- .../mvel/integrationtests/DroolsTest.java | 25 +- .../drools/mvel/integrationtests/DslTest.java | 95 +- .../integrationtests/DynamicRuleLoadTest.java | 36 +- .../DynamicRuleRemovalTest.java | 33 +- .../DynamicRulesChangesTest.java | 42 +- .../integrationtests/DynamicRulesTest.java | 188 ++- .../EdgeCaseNonExecModelTest.java | 37 +- .../EnableAuditLogCommandTest.java | 30 +- .../mvel/integrationtests/EnumTest.java | 40 +- .../ExecutionFlowControlTest.java | 168 +-- .../ExistentialOperatorTest.java | 26 +- .../mvel/integrationtests/ExpirationTest.java | 222 ++-- .../mvel/integrationtests/ExtendsTest.java | 148 ++- .../FailureOnRemovalTest.java | 48 +- .../FireAllRulesCommandTest.java | 57 +- .../FireUntilHaltAccumulateTest.java | 36 +- .../integrationtests/FireUntilHaltTest.java | 41 +- .../integrationtests/FirstOrderLogicTest.java | 187 +-- .../mvel/integrationtests/FunctionsTest.java | 46 +- .../integrationtests/GeneratedBeansTest.java | 36 +- .../mvel/integrationtests/GenericsTest.java | 31 +- .../mvel/integrationtests/I18nTest.java | 59 +- .../IntegrationInterfacesTest.java | 49 +- .../mvel/integrationtests/JBRULESTest.java | 71 +- .../mvel/integrationtests/JittingTest.java | 118 +- .../LengthSlidingWindowTest.java | 49 +- .../mvel/integrationtests/LifecycleTest.java | 35 +- .../mvel/integrationtests/LinkingTest.java | 126 +- .../mvel/integrationtests/ListenersTest.java | 57 +- .../MBeansMonitoringTest.java | 217 ++- .../integrationtests/MTEntryPointsTest.java | 42 +- .../MVELEmptyCollectionsTest.java | 75 +- .../mvel/integrationtests/MVELTest.java | 197 +-- .../integrationtests/MapConstraintTest.java | 66 +- .../mvel/integrationtests/MatchTest.java | 61 +- .../integrationtests/MergePackageTest.java | 35 +- .../integrationtests/MessageImplTest.java | 31 +- .../mvel/integrationtests/Misc2Test.java | 1173 ++++++++++------- .../NamedConsequencesTest.java | 276 ++-- .../integrationtests/NewLineAtEoFTest.java | 31 +- .../NodePositionInPathTest.java | 26 +- .../NodesPartitioningTest.java | 44 +- .../NullCheckOnExistentialNodeTest.java | 44 +- .../NullSafeDereferencingTest.java | 77 +- .../mvel/integrationtests/NullTest.java | 72 +- .../integrationtests/ObjectTypeNodeTest.java | 26 +- .../integrationtests/OutOfMemoryTest.java | 45 +- .../PackageInMultipleResourcesTest.java | 31 +- .../integrationtests/ParallelBuildTest.java | 26 +- .../ParallelCompilationTest.java | 35 +- .../ParallelEvaluationTest.java | 30 +- .../ParallelExecutionTest.java | 165 ++- .../mvel/integrationtests/ParserTest.java | 2 +- .../integrationtests/PassiveQueryTest.java | 61 +- .../integrationtests/PathEndNodeTest.java | 26 +- .../PhreakConcurrencyTest.java | 10 +- .../integrationtests/PolymorphismTest.java | 36 +- .../PropertyReactivityBlockerTest.java | 46 +- .../PropertyReactivityTest.java | 230 ++-- .../PropertySpecificTest.java | 404 +++--- .../PseudoClockEventsTest.java | 57 +- .../mvel/integrationtests/Query2Test.java | 26 +- .../mvel/integrationtests/Query3Test.java | 70 +- .../QueryCepFireUntilHaltTest.java | 51 +- .../integrationtests/QueryInRHSCepTest.java | 87 +- .../mvel/integrationtests/QueryTest.java | 174 +-- .../SerializedPackageMergeTest.java | 2 +- .../TemporalOperatorTest.java | 160 +-- .../mvel/integrationtests/TreeTest.java | 26 +- .../integrationtests/TypeDeclarationTest.java | 36 +- .../mvel/integrationtests/UnlinkingTest.java | 26 +- .../mvel/integrationtests/VarargsTest.java | 33 +- .../mvel/integrationtests/WindowTest.java | 65 +- ...WorkingMemoryActionsSerializationTest.java | 38 +- .../integrationtests/XSDResourceTest.java | 3 +- .../SimpleEventGeneratorTest.java | 61 +- .../marshalling/InputStreamMarkResetTest.java | 2 +- .../integrationtests/session/DeleteTest.java | 3 - 96 files changed, 3937 insertions(+), 3727 deletions(-) diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/AbstractTupleIndexHashTableIteratorTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/AbstractTupleIndexHashTableIteratorTest.java index 4062f3ca681..fecbcecb6cd 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/AbstractTupleIndexHashTableIteratorTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/AbstractTupleIndexHashTableIteratorTest.java @@ -19,8 +19,8 @@ package org.drools.mvel; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.compiler.builder.impl.EvaluatorRegistry; import org.drools.core.base.ClassFieldAccessorCache; @@ -37,23 +37,18 @@ import org.drools.model.index.BetaIndexImpl; import org.drools.modelcompiler.util.EvaluationUtil; import org.drools.mvel.accessors.ClassFieldAccessorStore; -import org.junit.After; -import org.junit.Before; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public abstract class AbstractTupleIndexHashTableIteratorTest { public static EvaluatorRegistry registry = new EvaluatorRegistry(); - protected boolean useLambdaConstraint; - private IndexMemory.EqualityMemoryType originalMemoryImpl; - @Before + @BeforeEach public void before() { try { originalMemoryImpl = IndexMemory.getEqualityMemoryType(); @@ -64,7 +59,7 @@ public void before() { } - @After + @AfterEach public void after() { try { IndexMemory.setEqualityMemoryType(originalMemoryImpl); @@ -73,12 +68,8 @@ public void after() { } } - @Parameterized.Parameters(name = "useLambdaConstraint={0}") - public static Collection getParameters() { - Collection parameters = new ArrayList<>(); - parameters.add(new Object[]{false}); - parameters.add(new Object[]{true}); - return parameters; + public static Stream parameters() { + return Stream.of(false, true); } protected static BetaConstraint createFooThisEqualsDBetaConstraint(boolean useLambdaConstraint) { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/BaseBetaConstraintsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/BaseBetaConstraintsTest.java index 63ed505e233..981b0d4ae0d 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/BaseBetaConstraintsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/BaseBetaConstraintsTest.java @@ -19,8 +19,8 @@ package org.drools.mvel; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.core.RuleBaseConfiguration; import org.drools.core.base.ClassFieldAccessorCache; @@ -47,27 +47,19 @@ import org.drools.model.functions.Predicate1; import org.drools.modelcompiler.util.EvaluationUtil; import org.drools.mvel.model.Cheese; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public abstract class BaseBetaConstraintsTest { public static EvaluatorRegistry registry = new EvaluatorRegistry(); - protected boolean useLambdaConstraint; - @Parameterized.Parameters(name = "useLambdaConstraint={0}") - public static Collection getParameters() { - Collection parameters = new ArrayList<>(); - parameters.add(new Object[]{false}); - parameters.add(new Object[]{true}); - return parameters; + public static Stream parameters() { + return Stream.of(false, true); } - protected BetaConstraint getCheeseTypeConstraint(final String identifier, + protected BetaConstraint getCheeseTypeConstraint(boolean useLambdaConstraint, final String identifier, Operator operator) { if (useLambdaConstraint) { Pattern pattern = new Pattern(0, new ClassObjectType(Cheese.class)); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/DefaultBetaConstraintsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/DefaultBetaConstraintsTest.java index 3965eb1737b..adb9296d485 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/DefaultBetaConstraintsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/DefaultBetaConstraintsTest.java @@ -21,122 +21,126 @@ import org.drools.drl.parser.impl.Operator; import org.drools.core.common.DefaultBetaConstraints; import org.drools.base.rule.constraint.BetaConstraint; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class DefaultBetaConstraintsTest extends BaseBetaConstraintsTest { - public DefaultBetaConstraintsTest(boolean useLambdaConstraint) { - this.useLambdaConstraint = useLambdaConstraint; - } - @Test - public void testNoIndexConstraints() { - BetaConstraint constraint0 = getCheeseTypeConstraint("cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testNoIndexConstraints(boolean useLambdaConstraint) { + BetaConstraint constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); BetaConstraint[] constraints = new BetaConstraint[] {constraint0 }; checkBetaConstraints( constraints, DefaultBetaConstraints.class ); - BetaConstraint constraint1 = getCheeseTypeConstraint("cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); constraints = new BetaConstraint[] {constraint0, constraint1 }; checkBetaConstraints( constraints, DefaultBetaConstraints.class ); - BetaConstraint constraint2 = getCheeseTypeConstraint("cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint2 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); constraints = new BetaConstraint[] {constraint0, constraint1, constraint2 }; checkBetaConstraints( constraints, DefaultBetaConstraints.class ); - BetaConstraint constraint3 = getCheeseTypeConstraint("cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); constraints = new BetaConstraint[] {constraint0, constraint1, constraint2, constraint3 }; checkBetaConstraints( constraints, DefaultBetaConstraints.class ); - BetaConstraint constraint4 = getCheeseTypeConstraint("cheeseType4", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint4 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType4", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); constraints = new BetaConstraint[] {constraint0, constraint1, constraint2, constraint3, constraint4 }; checkBetaConstraints( constraints, DefaultBetaConstraints.class ); - BetaConstraint constraint5 = getCheeseTypeConstraint("cheeseType5", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint5 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType5", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); constraints = new BetaConstraint[] {constraint0, constraint1, constraint2, constraint3, constraint5 }; checkBetaConstraints( constraints, DefaultBetaConstraints.class ); - BetaConstraint constraint6 = getCheeseTypeConstraint("cheeseType6", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint6 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType6", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); constraints = new BetaConstraint[] {constraint0, constraint1, constraint2, constraint3, constraint4, constraint5, constraint6 }; checkBetaConstraints( constraints, DefaultBetaConstraints.class ); } - @Test - public void testIndexedConstraint() { - BetaConstraint constraint0 = getCheeseTypeConstraint("cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator()); + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testIndexedConstraint(boolean useLambdaConstraint) { + BetaConstraint constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator()); BetaConstraint[] constraints = new BetaConstraint[] {constraint0 }; checkBetaConstraints( constraints, DefaultBetaConstraints.class ); - BetaConstraint constraint1 = getCheeseTypeConstraint("cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator()); constraints = new BetaConstraint[] {constraint0, constraint1 }; checkBetaConstraints( constraints, DefaultBetaConstraints.class ); - BetaConstraint constraint2 = getCheeseTypeConstraint("cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint2 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator()); constraints = new BetaConstraint[] {constraint0, constraint1, constraint2 }; checkBetaConstraints( constraints, DefaultBetaConstraints.class ); - BetaConstraint constraint3 = getCheeseTypeConstraint("cheeseType3", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType3", Operator.BuiltInOperator.EQUAL.getOperator()); constraints = new BetaConstraint[] {constraint0, constraint1, constraint2, constraint3 }; checkBetaConstraints( constraints, DefaultBetaConstraints.class ); - BetaConstraint constraint4 = getCheeseTypeConstraint("cheeseType4", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint4 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType4", Operator.BuiltInOperator.EQUAL.getOperator()); constraints = new BetaConstraint[] {constraint0, constraint1, constraint2, constraint3, constraint4 }; checkBetaConstraints( constraints, DefaultBetaConstraints.class ); - BetaConstraint constraint5 = getCheeseTypeConstraint("cheeseType5", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint5 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType5", Operator.BuiltInOperator.EQUAL.getOperator()); constraints = new BetaConstraint[] {constraint0, constraint1, constraint2, constraint3, constraint4, constraint5 }; checkBetaConstraints( constraints, DefaultBetaConstraints.class ); - BetaConstraint constraint6 = getCheeseTypeConstraint("cheeseType6", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint6 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType6", Operator.BuiltInOperator.EQUAL.getOperator()); constraints = new BetaConstraint[] {constraint0, constraint1, constraint2, constraint3, constraint4, constraint5, constraint6 }; checkBetaConstraints( constraints, DefaultBetaConstraints.class ); } - @Test - public void testSingleIndex() { - BetaConstraint constraint0 = getCheeseTypeConstraint("cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator()); - BetaConstraint constraint1 = getCheeseTypeConstraint("cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - BetaConstraint constraint2 = getCheeseTypeConstraint("cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - BetaConstraint constraint3 = getCheeseTypeConstraint("cheeseType4", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - BetaConstraint constraint4 = getCheeseTypeConstraint("cheeseType5", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testSingleIndex(boolean useLambdaConstraint) { + BetaConstraint constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint2 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType4", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint4 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType5", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); BetaConstraint[] constraints = new BetaConstraint[] {constraint0, constraint1, constraint2, constraint3, constraint4 }; checkBetaConstraints( constraints, DefaultBetaConstraints.class ); } - @Test - public void testSingleIndexNotFirst() { - BetaConstraint constraint0 = getCheeseTypeConstraint("cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - BetaConstraint constraint1 = getCheeseTypeConstraint("cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - BetaConstraint constraint2 = getCheeseTypeConstraint("cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - BetaConstraint constraint3 = getCheeseTypeConstraint("cheeseType4", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - BetaConstraint constraint4 = getCheeseTypeConstraint("cheeseType5", Operator.BuiltInOperator.EQUAL.getOperator()); + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testSingleIndexNotFirst(boolean useLambdaConstraint) { + BetaConstraint constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint2 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType4", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint4 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType5", Operator.BuiltInOperator.EQUAL.getOperator()); BetaConstraint[] constraints = new BetaConstraint[] {constraint0, constraint1, constraint2, constraint3, constraint4 }; checkBetaConstraints( constraints, DefaultBetaConstraints.class ); } - @Test - public void testDoubleIndex() { - BetaConstraint constraint0 = getCheeseTypeConstraint("cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator()); - BetaConstraint constraint1 = getCheeseTypeConstraint("cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - BetaConstraint constraint2 = getCheeseTypeConstraint("cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - BetaConstraint constraint3 = getCheeseTypeConstraint("cheeseType4", Operator.BuiltInOperator.EQUAL.getOperator()); - BetaConstraint constraint4 = getCheeseTypeConstraint("cheeseType5", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testDoubleIndex(boolean useLambdaConstraint) { + BetaConstraint constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint2 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType4", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint4 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType5", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); BetaConstraint[] constraints = new BetaConstraint[] {constraint0, constraint1, constraint2, constraint3, constraint4 }; checkBetaConstraints( constraints, DefaultBetaConstraints.class ); } - @Test - public void testDoubleIndexNotFirst() { - BetaConstraint constraint0 = getCheeseTypeConstraint("cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - BetaConstraint constraint1 = getCheeseTypeConstraint("cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - BetaConstraint constraint2 = getCheeseTypeConstraint("cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - BetaConstraint constraint3 = getCheeseTypeConstraint("cheeseType4", Operator.BuiltInOperator.EQUAL.getOperator()); - BetaConstraint constraint4 = getCheeseTypeConstraint("cheeseType5", Operator.BuiltInOperator.EQUAL.getOperator()); + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testDoubleIndexNotFirst(boolean useLambdaConstraint) { + BetaConstraint constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint2 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType4", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint4 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType5", Operator.BuiltInOperator.EQUAL.getOperator()); BetaConstraint[] constraints = new BetaConstraint[] {constraint0, constraint1, constraint2, constraint3, constraint4 }; @@ -144,26 +148,28 @@ public void testDoubleIndexNotFirst() { } - @Test - public void testTripleIndex() { - BetaConstraint constraint0 = getCheeseTypeConstraint("cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator()); - BetaConstraint constraint1 = getCheeseTypeConstraint("cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - BetaConstraint constraint2 = getCheeseTypeConstraint("cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - BetaConstraint constraint3 = getCheeseTypeConstraint("cheeseType4", Operator.BuiltInOperator.EQUAL.getOperator()); - BetaConstraint constraint4 = getCheeseTypeConstraint("cheeseType5", Operator.BuiltInOperator.EQUAL.getOperator()); + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testTripleIndex(boolean useLambdaConstraint) { + BetaConstraint constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint2 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType4", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint4 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType5", Operator.BuiltInOperator.EQUAL.getOperator()); BetaConstraint[] constraints = new BetaConstraint[] {constraint0, constraint1, constraint2, constraint3, constraint4 }; checkBetaConstraints( constraints, DefaultBetaConstraints.class ); } - @Test - public void testTripleIndexNotFirst() { - BetaConstraint constraint0 = getCheeseTypeConstraint("cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - BetaConstraint constraint1 = getCheeseTypeConstraint("cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator()); - BetaConstraint constraint2 = getCheeseTypeConstraint("cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - BetaConstraint constraint3 = getCheeseTypeConstraint("cheeseType4", Operator.BuiltInOperator.EQUAL.getOperator()); - BetaConstraint constraint4 = getCheeseTypeConstraint("cheeseType5", Operator.BuiltInOperator.EQUAL.getOperator()); + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testTripleIndexNotFirst(boolean useLambdaConstraint) { + BetaConstraint constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint2 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType4", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint4 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType5", Operator.BuiltInOperator.EQUAL.getOperator()); BetaConstraint[] constraints = new BetaConstraint[] {constraint0, constraint1, constraint2, constraint3, constraint4 }; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/DoubleBetaConstraintsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/DoubleBetaConstraintsTest.java index 24eb084b4e5..5bbc057bfea 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/DoubleBetaConstraintsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/DoubleBetaConstraintsTest.java @@ -22,52 +22,53 @@ import org.drools.core.common.DoubleBetaConstraints; import org.drools.base.reteoo.NodeTypeEnums; import org.drools.base.rule.constraint.BetaConstraint; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class DoubleBetaConstraintsTest extends BaseBetaConstraintsTest { - public DoubleBetaConstraintsTest(boolean useLambdaConstraint) { - this.useLambdaConstraint = useLambdaConstraint; - } - - @Test - public void testAllNoneIndexed() { - BetaConstraint constraint0 = getCheeseTypeConstraint("cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - BetaConstraint constraint1 = getCheeseTypeConstraint("cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testAllNoneIndexed(boolean useLambdaConstraint) { + BetaConstraint constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); BetaConstraint[] constraints = new BetaConstraint[] {constraint0, constraint1 }; checkBetaConstraints( constraints, DoubleBetaConstraints.class ); } - @Test - public void testOneIndexed() { - BetaConstraint constraint0 = getCheeseTypeConstraint("cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator()); - BetaConstraint constraint1 = getCheeseTypeConstraint("cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testOneIndexed(boolean useLambdaConstraint) { + BetaConstraint constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); BetaConstraint[] constraints = new BetaConstraint[] {constraint0, constraint1 }; checkBetaConstraints( constraints, DoubleBetaConstraints.class ); - constraint0 = getCheeseTypeConstraint( "cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); - constraint1 = getCheeseTypeConstraint( "cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator() ); + constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); + constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator() ); constraints = new BetaConstraint[] {constraint0, constraint1 }; checkBetaConstraints( constraints, DoubleBetaConstraints.class ); } - @Test - public void testOneIndexedForComparison() { - BetaConstraint constraint0 = getCheeseTypeConstraint("cheeseType0", Operator.BuiltInOperator.GREATER.getOperator()); - BetaConstraint constraint1 = getCheeseTypeConstraint("cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testOneIndexedForComparison(boolean useLambdaConstraint) { + BetaConstraint constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.GREATER.getOperator()); + BetaConstraint constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); BetaConstraint[] constraints = new BetaConstraint[] {constraint0, constraint1 }; checkBetaConstraints( constraints, DoubleBetaConstraints.class, NodeTypeEnums.ExistsNode ); - constraint0 = getCheeseTypeConstraint( "cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); - constraint1 = getCheeseTypeConstraint( "cheeseType1", Operator.BuiltInOperator.GREATER.getOperator() ); + constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); + constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.GREATER.getOperator() ); constraints = new BetaConstraint[] {constraint0, constraint1 }; checkBetaConstraints( constraints, DoubleBetaConstraints.class, NodeTypeEnums.ExistsNode ); } - @Test - public void testTwoIndexed() { - BetaConstraint constraint0 = getCheeseTypeConstraint("cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator()); - BetaConstraint constraint1 = getCheeseTypeConstraint("cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator()); + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testTwoIndexed(boolean useLambdaConstraint) { + BetaConstraint constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator()); BetaConstraint[] constraints = new BetaConstraint[] {constraint0, constraint1 }; checkBetaConstraints( constraints, DoubleBetaConstraints.class ); } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/FieldConstraintTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/FieldConstraintTest.java index 3529c40ce07..bc8934acbc1 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/FieldConstraintTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/FieldConstraintTest.java @@ -18,9 +18,6 @@ */ package org.drools.mvel; -import org.drools.base.rule.Declaration; -import org.drools.base.rule.Pattern; -import org.drools.base.rule.accessor.ReadAccessor; import org.drools.base.rule.constraint.AlphaNodeFieldConstraint; import org.drools.core.base.ClassFieldAccessorCache; import org.drools.core.common.InternalFactHandle; @@ -30,37 +27,23 @@ import org.drools.mvel.accessors.ClassFieldAccessorStore; import org.drools.mvel.accessors.ClassFieldReader; import org.drools.mvel.model.Cheese; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -import java.util.ArrayList; -import java.util.Collection; +import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; -import static org.drools.base.base.AccessorKey.AccessorType.ClassObjectType; -@RunWith(Parameterized.class) public class FieldConstraintTest { ClassFieldAccessorStore store = new ClassFieldAccessorStore(); - private final boolean useLambdaConstraint; - - public FieldConstraintTest(boolean useLambdaConstraint) { - this.useLambdaConstraint = useLambdaConstraint; - } - - @Parameterized.Parameters(name = "useLambdaConstraint={0}") - public static Collection getParameters() { - Collection parameters = new ArrayList<>(); - parameters.add(new Object[]{false}); - parameters.add(new Object[]{true}); - return parameters; + public static Stream parameters() { + return Stream.of(false, true); } - @Before + @BeforeEach public void setUp() throws Exception { store.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) ); store.setEagerWire( true ); @@ -78,8 +61,9 @@ public void setUp() throws Exception { * This is currently the same as using a ReturnValueConstraint just that it * doesn't need any requiredDeclarations */ - @Test - public void testLiteralConstraint() { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testLiteralConstraint(boolean useLambdaConstraint) { InternalKnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase();; StatefulKnowledgeSessionImpl ksession = (StatefulKnowledgeSessionImpl)kBase.newKieSession(); @@ -116,8 +100,9 @@ public void testLiteralConstraint() { * * */ - @Test - public void testPrimitiveLiteralConstraint() { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testPrimitiveLiteralConstraint(boolean useLambdaConstraint) { InternalKnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase();; StatefulKnowledgeSessionImpl ksession = (StatefulKnowledgeSessionImpl)kBase.newKieSession(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/InternalRuleBaseEventSupportTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/InternalRuleBaseEventSupportTest.java index b1ad9689c78..6aa91e878cf 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/InternalRuleBaseEventSupportTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/InternalRuleBaseEventSupportTest.java @@ -21,8 +21,7 @@ import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; -import java.util.ArrayList; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.base.base.ValueResolver; import org.drools.core.base.ClassFieldAccessorCache; @@ -38,10 +37,8 @@ import org.drools.core.test.model.Cheese; import org.drools.kiesession.rulebase.InternalKnowledgeBase; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.event.kiebase.AfterFunctionRemovedEvent; import org.kie.api.event.kiebase.AfterKieBaseLockedEvent; import org.kie.api.event.kiebase.AfterKieBaseUnlockedEvent; @@ -64,7 +61,6 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class InternalRuleBaseEventSupportTest { private InternalKnowledgeBase kBase; @@ -72,25 +68,11 @@ public class InternalRuleBaseEventSupportTest { private TestRuleBaseListener listener2; private InternalKnowledgePackage pkg; - private final boolean useLambdaConstraint; - - public InternalRuleBaseEventSupportTest(boolean useLambdaConstraint) { - this.useLambdaConstraint = useLambdaConstraint; - } - - @Parameterized.Parameters(name = "useLambdaConstraint={0}") - public static Collection getParameters() { - Collection parameters = new ArrayList<>(); - parameters.add(new Object[]{false}); - parameters.add(new Object[]{true}); - return parameters; + public static Stream parameters() { + return Stream.of(false, true); } - /* (non-Javadoc) - * @see junit.framework.TestCase#setUp() - */ - @Before - public void setUp() throws Exception { + public void setUp(boolean useLambdaConstraint) throws Exception { kBase = KnowledgeBaseFactory.newKnowledgeBase();; listener1 = new TestRuleBaseListener( "(listener-1) " ); listener2 = new TestRuleBaseListener( "(listener-2) " ); @@ -169,8 +151,10 @@ public String getName() { } - @Test - public void testAddPackageEvents() throws Exception { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testAddPackageEvents(boolean useLambdaConstraint) throws Exception { + setUp(useLambdaConstraint); assertThat(listener1.getBeforePackageAdded()).isEqualTo(0); assertThat(listener1.getAfterPackageAdded()).isEqualTo(0); assertThat(listener2.getBeforePackageAdded()).isEqualTo(0); @@ -192,8 +176,10 @@ public void testAddPackageEvents() throws Exception { assertThat(listener2.getAfterRuleAdded()).isEqualTo(2); } - @Test - public void testRemovePackageEvents() throws Exception { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testRemovePackageEvents(boolean useLambdaConstraint) throws Exception { + setUp(useLambdaConstraint); this.kBase.addPackage( pkg ); assertThat(listener1.getBeforePackageRemoved()).isEqualTo(0); @@ -371,25 +357,25 @@ public void beforeKieBaseUnlocked(BeforeKieBaseUnlockedEvent event) { } - public void beforeProcessAdded(BeforeProcessAddedEvent event) { - // TODO Auto-generated method stub - - } - - public void afterProcessAdded(AfterProcessAddedEvent event) { - // TODO Auto-generated method stub - - } - - public void beforeProcessRemoved(BeforeProcessRemovedEvent event) { - // TODO Auto-generated method stub - - } - - public void afterProcessRemoved(AfterProcessRemovedEvent event) { - // TODO Auto-generated method stub - - } + public void beforeProcessAdded(BeforeProcessAddedEvent event) { + // TODO Auto-generated method stub + + } + + public void afterProcessAdded(AfterProcessAddedEvent event) { + // TODO Auto-generated method stub + + } + + public void beforeProcessRemoved(BeforeProcessRemovedEvent event) { + // TODO Auto-generated method stub + + } + + public void afterProcessRemoved(AfterProcessRemovedEvent event) { + // TODO Auto-generated method stub + + } } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/KnowledgeBaseEventSupportTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/KnowledgeBaseEventSupportTest.java index a01a2148814..4aa81d4b185 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/KnowledgeBaseEventSupportTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/KnowledgeBaseEventSupportTest.java @@ -21,14 +21,15 @@ import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; -import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; +import java.util.stream.Stream; import org.drools.base.base.ValueResolver; import org.drools.core.base.ClassFieldAccessorCache; import org.drools.kiesession.rulebase.InternalKnowledgeBase; import org.drools.mvel.accessors.ClassFieldAccessorStore; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.drools.base.base.ClassObjectType; import org.drools.base.definitions.InternalKnowledgePackage; import org.drools.base.definitions.rule.impl.RuleImpl; @@ -39,10 +40,6 @@ import org.drools.core.rule.consequence.KnowledgeHelper; import org.drools.core.test.model.Cheese; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.kie.api.event.kiebase.AfterFunctionRemovedEvent; import org.kie.api.event.kiebase.AfterKieBaseLockedEvent; import org.kie.api.event.kiebase.AfterKieBaseUnlockedEvent; @@ -65,7 +62,6 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class KnowledgeBaseEventSupportTest { private InternalKnowledgeBase kbase; @@ -73,25 +69,11 @@ public class KnowledgeBaseEventSupportTest { private TestRuleBaseListener listener2; private InternalKnowledgePackage pkg; - private final boolean useLambdaConstraint; - - public KnowledgeBaseEventSupportTest(boolean useLambdaConstraint) { - this.useLambdaConstraint = useLambdaConstraint; - } - - @Parameterized.Parameters(name = "useLambdaConstraint={0}") - public static Collection getParameters() { - Collection parameters = new ArrayList<>(); - parameters.add(new Object[]{false}); - parameters.add(new Object[]{true}); - return parameters; + public static Stream parameters() { + return Stream.of(false, true); } - /* (non-Javadoc) - * @see junit.framework.TestCase#setUp() - */ - @Before - public void setUp() throws Exception { + public void setUp(boolean useLambdaConstraint) throws Exception { kbase = KnowledgeBaseFactory.newKnowledgeBase(); listener1 = new TestRuleBaseListener( "(listener-1) " ); listener2 = new TestRuleBaseListener( "(listener-2) " ); @@ -169,8 +151,10 @@ public String getName() { pkg.addRule( rule2 ); } - @Test - public void testAddPackageEvents() throws Exception { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testAddPackageEvents(boolean useLambdaConstraint) throws Exception { + setUp(useLambdaConstraint); assertThat(listener1.getBeforePackageAdded()).isEqualTo(0); assertThat(listener1.getAfterPackageAdded()).isEqualTo(0); assertThat(listener2.getBeforePackageAdded()).isEqualTo(0); @@ -192,8 +176,10 @@ public void testAddPackageEvents() throws Exception { assertThat(listener2.getAfterRuleAdded()).isEqualTo(2); } - @Test - public void testRemovePackageEvents() throws Exception { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testRemovePackageEvents(boolean useLambdaConstraint) throws Exception { + setUp(useLambdaConstraint); this.kbase.addPackages( Collections.singleton( pkg ) ); assertThat(listener1.getBeforeKnowledgePackageRemoved()).isEqualTo(0); @@ -371,25 +357,25 @@ public void beforeKieBaseUnlocked(BeforeKieBaseUnlockedEvent event) { } - public void afterProcessAdded(AfterProcessAddedEvent arg0) { - // TODO Auto-generated method stub - - } - - public void afterProcessRemoved(AfterProcessRemovedEvent arg0) { - // TODO Auto-generated method stub - - } - - public void beforeProcessAdded(BeforeProcessAddedEvent arg0) { - // TODO Auto-generated method stub - - } - - public void beforeProcessRemoved(BeforeProcessRemovedEvent arg0) { - // TODO Auto-generated method stub - - } + public void afterProcessAdded(AfterProcessAddedEvent arg0) { + // TODO Auto-generated method stub + + } + + public void afterProcessRemoved(AfterProcessRemovedEvent arg0) { + // TODO Auto-generated method stub + + } + + public void beforeProcessAdded(BeforeProcessAddedEvent arg0) { + // TODO Auto-generated method stub + + } + + public void beforeProcessRemoved(BeforeProcessRemovedEvent arg0) { + // TODO Auto-generated method stub + + } } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/LeftTupleIndexHashTableIteratorTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/LeftTupleIndexHashTableIteratorTest.java index cb4d2bbdc9f..fedfd004cdc 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/LeftTupleIndexHashTableIteratorTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/LeftTupleIndexHashTableIteratorTest.java @@ -37,7 +37,8 @@ import org.drools.core.util.index.TupleIndexHashTable.FieldIndexHashTableFullIterator; import org.drools.core.util.index.TupleList; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; @@ -45,12 +46,9 @@ public class LeftTupleIndexHashTableIteratorTest extends AbstractTupleIndexHashTableIteratorTest { - public LeftTupleIndexHashTableIteratorTest(boolean useLambdaConstraint) { - this.useLambdaConstraint = useLambdaConstraint; - } - - @Test - public void test1() { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void test1(boolean useLambdaConstraint) { BetaConstraint constraint0 = createFooThisEqualsDBetaConstraint(useLambdaConstraint); BetaConstraint[] constraints = new BetaConstraint[]{constraint0}; @@ -114,8 +112,9 @@ public void test1() { assertThat(resultList.size()).isEqualTo(13); } - @Test - public void testLastBucketInTheTable() { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testLastBucketInTheTable(boolean useLambdaConstraint) { // JBRULES-2574 // setup the entry array with an element in the first bucket, one // in the middle and one in the last bucket diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/QuadroupleBetaConstraintsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/QuadroupleBetaConstraintsTest.java index f1f64ae4d46..97b82484a88 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/QuadroupleBetaConstraintsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/QuadroupleBetaConstraintsTest.java @@ -21,138 +21,139 @@ import org.drools.drl.parser.impl.Operator; import org.drools.core.common.QuadroupleBetaConstraints; import org.drools.base.rule.constraint.BetaConstraint; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class QuadroupleBetaConstraintsTest extends BaseBetaConstraintsTest { - public QuadroupleBetaConstraintsTest(boolean useLambdaConstraint) { - this.useLambdaConstraint = useLambdaConstraint; - - } - - @Test - public void testNoneIndxed() { - BetaConstraint constraint0 = getCheeseTypeConstraint("cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - BetaConstraint constraint1 = getCheeseTypeConstraint("cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - BetaConstraint constraint3 = getCheeseTypeConstraint("cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - BetaConstraint constraint4 = getCheeseTypeConstraint("cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testNoneIndxed(boolean useLambdaConstraint) { + BetaConstraint constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint4 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); BetaConstraint[] constraints = new BetaConstraint[] {constraint0, constraint1, constraint3, constraint4 }; checkBetaConstraints( constraints, QuadroupleBetaConstraints.class ); } - @Test - public void testOneIndxed() { - BetaConstraint constraint0 = getCheeseTypeConstraint("cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator()); - BetaConstraint constraint1 = getCheeseTypeConstraint("cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - BetaConstraint constraint3 = getCheeseTypeConstraint("cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - BetaConstraint constraint4 = getCheeseTypeConstraint("cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testOneIndxed(boolean useLambdaConstraint) { + BetaConstraint constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint4 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); BetaConstraint[] constraints = new BetaConstraint[] {constraint0, constraint1, constraint3, constraint4 }; checkBetaConstraints( constraints, QuadroupleBetaConstraints.class ); - constraint0 = getCheeseTypeConstraint( "cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); - constraint1 = getCheeseTypeConstraint( "cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator() ); - constraint3 = getCheeseTypeConstraint( "cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); - constraint4 = getCheeseTypeConstraint( "cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); + constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); + constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator() ); + constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); + constraint4 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); constraints = new BetaConstraint[] {constraint0, constraint1, constraint3, constraint4 }; checkBetaConstraints( constraints, QuadroupleBetaConstraints.class ); - constraint0 = getCheeseTypeConstraint( "cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); - constraint1 = getCheeseTypeConstraint( "cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); - constraint3 = getCheeseTypeConstraint( "cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator() ); - constraint4 = getCheeseTypeConstraint( "cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); + constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); + constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); + constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator() ); + constraint4 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); constraints = new BetaConstraint[] {constraint0, constraint1, constraint3, constraint4 }; checkBetaConstraints( constraints, QuadroupleBetaConstraints.class ); - constraint0 = getCheeseTypeConstraint( "cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); - constraint1 = getCheeseTypeConstraint( "cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); - constraint3 = getCheeseTypeConstraint( "cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); - constraint4 = getCheeseTypeConstraint( "cheeseType3", Operator.BuiltInOperator.EQUAL.getOperator() ); + constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); + constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); + constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); + constraint4 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType3", Operator.BuiltInOperator.EQUAL.getOperator() ); constraints = new BetaConstraint[] {constraint0, constraint1, constraint3, constraint4 }; checkBetaConstraints( constraints, QuadroupleBetaConstraints.class ); } - @Test - public void testTwoIndxed() { - BetaConstraint constraint0 = getCheeseTypeConstraint("cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator()); - BetaConstraint constraint1 = getCheeseTypeConstraint("cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator()); - BetaConstraint constraint3 = getCheeseTypeConstraint("cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - BetaConstraint constraint4 = getCheeseTypeConstraint("cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testTwoIndxed(boolean useLambdaConstraint) { + BetaConstraint constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint4 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); BetaConstraint[] constraints = new BetaConstraint[] {constraint0, constraint1, constraint3, constraint4 }; checkBetaConstraints( constraints, QuadroupleBetaConstraints.class ); - constraint0 = getCheeseTypeConstraint("cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator()); - constraint1 = getCheeseTypeConstraint("cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - constraint3 = getCheeseTypeConstraint("cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator()); - constraint4 = getCheeseTypeConstraint("cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator()); + constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator()); + constraint4 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); constraints = new BetaConstraint[] {constraint0, constraint1, constraint3, constraint4 }; checkBetaConstraints( constraints, QuadroupleBetaConstraints.class ); - constraint0 = getCheeseTypeConstraint("cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator()); - constraint1 = getCheeseTypeConstraint("cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - constraint3 = getCheeseTypeConstraint("cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - constraint4 = getCheeseTypeConstraint("cheeseType3", Operator.BuiltInOperator.EQUAL.getOperator()); + constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator()); + constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + constraint4 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType3", Operator.BuiltInOperator.EQUAL.getOperator()); constraints = new BetaConstraint[] {constraint0, constraint1, constraint3, constraint4 }; checkBetaConstraints( constraints, QuadroupleBetaConstraints.class ); - constraint0 = getCheeseTypeConstraint("cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - constraint1 = getCheeseTypeConstraint("cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator()); - constraint3 = getCheeseTypeConstraint("cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator()); - constraint4 = getCheeseTypeConstraint("cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator()); + constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator()); + constraint4 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); constraints = new BetaConstraint[] {constraint0, constraint1, constraint3, constraint4 }; checkBetaConstraints( constraints, QuadroupleBetaConstraints.class ); - constraint0 = getCheeseTypeConstraint("cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - constraint1 = getCheeseTypeConstraint("cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator()); - constraint3 = getCheeseTypeConstraint("cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - constraint4 = getCheeseTypeConstraint("cheeseType3", Operator.BuiltInOperator.EQUAL.getOperator()); + constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator()); + constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + constraint4 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType3", Operator.BuiltInOperator.EQUAL.getOperator()); constraints = new BetaConstraint[] {constraint0, constraint1, constraint3, constraint4 }; checkBetaConstraints( constraints, QuadroupleBetaConstraints.class ); - constraint0 = getCheeseTypeConstraint("cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - constraint1 = getCheeseTypeConstraint("cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - constraint3 = getCheeseTypeConstraint("cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator()); - constraint4 = getCheeseTypeConstraint("cheeseType3", Operator.BuiltInOperator.EQUAL.getOperator()); + constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator()); + constraint4 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType3", Operator.BuiltInOperator.EQUAL.getOperator()); constraints = new BetaConstraint[] {constraint0, constraint1, constraint3, constraint4 }; checkBetaConstraints( constraints, QuadroupleBetaConstraints.class ); } - @Test - public void testThreeIndxed() { - BetaConstraint constraint0 = getCheeseTypeConstraint("cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator()); - BetaConstraint constraint1 = getCheeseTypeConstraint("cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator()); - BetaConstraint constraint3 = getCheeseTypeConstraint("cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator()); - BetaConstraint constraint4 = getCheeseTypeConstraint("cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testThreeIndxed(boolean useLambdaConstraint) { + BetaConstraint constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint4 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType3", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); BetaConstraint[] constraints = new BetaConstraint[] {constraint0, constraint1, constraint3, constraint4 }; checkBetaConstraints( constraints, QuadroupleBetaConstraints.class ); - constraint0 = getCheeseTypeConstraint( "cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator() ); - constraint1 = getCheeseTypeConstraint( "cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator() ); - constraint3 = getCheeseTypeConstraint( "cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); - constraint4 = getCheeseTypeConstraint( "cheeseType3", Operator.BuiltInOperator.EQUAL.getOperator() ); + constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator() ); + constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator() ); + constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); + constraint4 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType3", Operator.BuiltInOperator.EQUAL.getOperator() ); constraints = new BetaConstraint[] {constraint0, constraint1, constraint3, constraint4 }; checkBetaConstraints( constraints, QuadroupleBetaConstraints.class ); - constraint0 = getCheeseTypeConstraint( "cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator() ); - constraint1 = getCheeseTypeConstraint( "cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); - constraint3 = getCheeseTypeConstraint( "cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator() ); - constraint4 = getCheeseTypeConstraint( "cheeseType3", Operator.BuiltInOperator.EQUAL.getOperator() ); + constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator() ); + constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); + constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator() ); + constraint4 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType3", Operator.BuiltInOperator.EQUAL.getOperator() ); constraints = new BetaConstraint[] {constraint0, constraint1, constraint3, constraint4 }; checkBetaConstraints( constraints, QuadroupleBetaConstraints.class ); - constraint0 = getCheeseTypeConstraint( "cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); - constraint1 = getCheeseTypeConstraint( "cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator() ); - constraint3 = getCheeseTypeConstraint( "cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator() ); - constraint4 = getCheeseTypeConstraint( "cheeseType3", Operator.BuiltInOperator.EQUAL.getOperator() ); + constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); + constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator() ); + constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator() ); + constraint4 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType3", Operator.BuiltInOperator.EQUAL.getOperator() ); constraints = new BetaConstraint[] {constraint0, constraint1, constraint3, constraint4 }; checkBetaConstraints( constraints, QuadroupleBetaConstraints.class ); } - @Test - public void testFourIndxed() { - BetaConstraint constraint0 = getCheeseTypeConstraint("cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator()); - BetaConstraint constraint1 = getCheeseTypeConstraint("cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator()); - BetaConstraint constraint3 = getCheeseTypeConstraint("cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator()); - BetaConstraint constraint4 = getCheeseTypeConstraint("cheeseType3", Operator.BuiltInOperator.EQUAL.getOperator()); + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testFourIndxed(boolean useLambdaConstraint) { + BetaConstraint constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint4 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType3", Operator.BuiltInOperator.EQUAL.getOperator()); BetaConstraint[] constraints = new BetaConstraint[] {constraint0, constraint1, constraint3, constraint4 }; checkBetaConstraints( constraints, QuadroupleBetaConstraints.class ); } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/RightTupleIndexHashTableIteratorTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/RightTupleIndexHashTableIteratorTest.java index b333261944a..7db4f5b1b7c 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/RightTupleIndexHashTableIteratorTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/RightTupleIndexHashTableIteratorTest.java @@ -38,21 +38,18 @@ import org.drools.core.util.index.TupleIndexHashTable.FieldIndexHashTableFullIterator; import org.drools.core.util.index.TupleList; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; public class RightTupleIndexHashTableIteratorTest extends AbstractTupleIndexHashTableIteratorTest { - public RightTupleIndexHashTableIteratorTest(boolean useLambdaConstraint) { - this.useLambdaConstraint = useLambdaConstraint; - } - - @Test - public void test1() { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void test1(boolean useLambdaConstraint) { BetaConstraint constraint0 = createFooThisEqualsDBetaConstraint(useLambdaConstraint); BetaConstraint[] constraints = new BetaConstraint[]{constraint0}; @@ -116,8 +113,9 @@ public void test1() { assertThat(resultList.size()).isEqualTo(13); } - @Test - public void testLastBucketInTheTable() { + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testLastBucketInTheTable(boolean useLambdaConstraint) { // JBRULES-2574 // setup the entry array with an element in the first bucket, one // in the middle and one in the last bucket diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/SingleBetaConstraintsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/SingleBetaConstraintsTest.java index 5bb3c17c4b0..6d231390efc 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/SingleBetaConstraintsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/SingleBetaConstraintsTest.java @@ -22,38 +22,39 @@ import org.drools.core.common.SingleBetaConstraints; import org.drools.base.reteoo.NodeTypeEnums; import org.drools.base.rule.constraint.BetaConstraint; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class SingleBetaConstraintsTest extends BaseBetaConstraintsTest { - public SingleBetaConstraintsTest(boolean useLambdaConstraint) { - this.useLambdaConstraint = useLambdaConstraint; - } - - @Test - public void testIndexed() { - BetaConstraint constraint0 = getCheeseTypeConstraint("cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator()); + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testIndexed(boolean useLambdaConstraint) { + BetaConstraint constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator()); BetaConstraint[] constraints = new BetaConstraint[] {constraint0 }; checkBetaConstraints( constraints, SingleBetaConstraints.class ); } - @Test - public void testNotIndexed() { - BetaConstraint constraint0 = getCheeseTypeConstraint("cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testNotIndexed(boolean useLambdaConstraint) { + BetaConstraint constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); BetaConstraint[] constraints = new BetaConstraint[] {constraint0 }; checkBetaConstraints( constraints, SingleBetaConstraints.class ); } - @Test - public void testIndexedForComparison() { - BetaConstraint constraint0 = getCheeseTypeConstraint("cheeseType0", Operator.BuiltInOperator.LESS.getOperator()); + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testIndexedForComparison(boolean useLambdaConstraint) { + BetaConstraint constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.LESS.getOperator()); BetaConstraint[] constraints = new BetaConstraint[] {constraint0 }; checkBetaConstraints( constraints, SingleBetaConstraints.class, NodeTypeEnums.ExistsNode ); } - @Test - public void testNotIndexedForComparison() { - BetaConstraint constraint0 = getCheeseTypeConstraint("cheeseType0", Operator.BuiltInOperator.LESS.getOperator()); + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testNotIndexedForComparison(boolean useLambdaConstraint) { + BetaConstraint constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.LESS.getOperator()); BetaConstraint[] constraints = new BetaConstraint[] {constraint0 }; checkBetaConstraints( constraints, SingleBetaConstraints.class, NodeTypeEnums.JoinNode ); } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/TripleBetaConstraintsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/TripleBetaConstraintsTest.java index af763994258..7ba51fc1491 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/TripleBetaConstraintsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/TripleBetaConstraintsTest.java @@ -21,70 +21,71 @@ import org.drools.drl.parser.impl.Operator; import org.drools.core.common.TripleBetaConstraints; import org.drools.base.rule.constraint.BetaConstraint; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class TripleBetaConstraintsTest extends BaseBetaConstraintsTest { - public TripleBetaConstraintsTest(boolean useLambdaConstraint) { - this.useLambdaConstraint = useLambdaConstraint; - } - - @Test - public void testNoneIndxed() { - BetaConstraint constraint0 = getCheeseTypeConstraint("cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - BetaConstraint constraint1 = getCheeseTypeConstraint("cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - BetaConstraint constraint3 = getCheeseTypeConstraint("cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testNoneIndxed(boolean useLambdaConstraint) { + BetaConstraint constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); BetaConstraint[] constraints = new BetaConstraint[] {constraint0, constraint1, constraint3 }; checkBetaConstraints( constraints, TripleBetaConstraints.class ); } - @Test - public void testOneIndxed() { - BetaConstraint constraint0 = getCheeseTypeConstraint("cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator()); - BetaConstraint constraint1 = getCheeseTypeConstraint("cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); - BetaConstraint constraint3 = getCheeseTypeConstraint("cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testOneIndxed(boolean useLambdaConstraint) { + BetaConstraint constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + BetaConstraint constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); BetaConstraint[] constraints = new BetaConstraint[] {constraint0, constraint1, constraint3 }; checkBetaConstraints( constraints, TripleBetaConstraints.class ); - constraint0 = getCheeseTypeConstraint( "cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); - constraint1 = getCheeseTypeConstraint( "cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator() ); - constraint3 = getCheeseTypeConstraint( "cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); + constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); + constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator() ); + constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); constraints = new BetaConstraint[] {constraint0, constraint1, constraint3 }; checkBetaConstraints( constraints, TripleBetaConstraints.class ); - constraint0 = getCheeseTypeConstraint( "cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); - constraint1 = getCheeseTypeConstraint( "cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); - constraint3 = getCheeseTypeConstraint( "cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator() ); + constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); + constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); + constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator() ); constraints = new BetaConstraint[] {constraint0, constraint1, constraint3 }; checkBetaConstraints( constraints, TripleBetaConstraints.class ); } - @Test - public void testTwoIndxed() { - BetaConstraint constraint0 = getCheeseTypeConstraint("cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator()); - BetaConstraint constraint1 = getCheeseTypeConstraint("cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator()); - BetaConstraint constraint3 = getCheeseTypeConstraint("cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testTwoIndxed(boolean useLambdaConstraint) { + BetaConstraint constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.NOT_EQUAL.getOperator()); BetaConstraint[] constraints = new BetaConstraint[] {constraint0, constraint1, constraint3 }; checkBetaConstraints( constraints, TripleBetaConstraints.class ); - constraint0 = getCheeseTypeConstraint( "cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator() ); - constraint1 = getCheeseTypeConstraint( "cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); - constraint3 = getCheeseTypeConstraint( "cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator() ); + constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator() ); + constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); + constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator() ); constraints = new BetaConstraint[] {constraint0, constraint1, constraint3 }; checkBetaConstraints( constraints, TripleBetaConstraints.class ); - constraint0 = getCheeseTypeConstraint( "cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); - constraint1 = getCheeseTypeConstraint( "cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator() ); - constraint3 = getCheeseTypeConstraint( "cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator() ); + constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.NOT_EQUAL.getOperator() ); + constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator() ); + constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator() ); constraints = new BetaConstraint[] {constraint0, constraint1, constraint3 }; checkBetaConstraints( constraints, TripleBetaConstraints.class ); } - @Test - public void testThreeIndxed() { - BetaConstraint constraint0 = getCheeseTypeConstraint("cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator()); - BetaConstraint constraint1 = getCheeseTypeConstraint("cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator()); - BetaConstraint constraint3 = getCheeseTypeConstraint("cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator()); + @ParameterizedTest(name = "useLambdaConstraint={0}") + @MethodSource("parameters") + public void testThreeIndxed(boolean useLambdaConstraint) { + BetaConstraint constraint0 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType0", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint1 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType1", Operator.BuiltInOperator.EQUAL.getOperator()); + BetaConstraint constraint3 = getCheeseTypeConstraint(useLambdaConstraint, "cheeseType2", Operator.BuiltInOperator.EQUAL.getOperator()); BetaConstraint[] constraints = new BetaConstraint[] {constraint0, constraint1, constraint3 }; checkBetaConstraints( constraints, TripleBetaConstraints.class ); } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/AlphaNodeTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/AlphaNodeTest.java index 6d14f2355c6..b59f1b6e87b 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/AlphaNodeTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/AlphaNodeTest.java @@ -18,37 +18,28 @@ */ package org.drools.mvel.integrationtests; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.mvel.compiler.Person; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class AlphaNodeTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public AlphaNodeTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testAlpha() { - + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAlpha(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import " + Person.class.getCanonicalName() + "\n" + @@ -64,8 +55,9 @@ public void testAlpha() { assertThat(ksession.fireAllRules()).isEqualTo(1); } - @Test - public void testSharedAlpha() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSharedAlpha(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import " + Person.class.getCanonicalName() + "\n" + "rule R1 when\n" + @@ -84,8 +76,9 @@ public void testSharedAlpha() { assertThat(ksession.fireAllRules()).isEqualTo(2); } - @Test - public void testBeta() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBeta(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import " + Person.class.getCanonicalName() + "\n" + "rule R1 when\n" + @@ -102,8 +95,9 @@ public void testBeta() { assertThat(ksession.fireAllRules()).isEqualTo(1); } - @Test - public void testSharedAlphaWithBeta() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSharedAlphaWithBeta(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import " + Person.class.getCanonicalName() + "\n" + "rule R1 when\n" + @@ -124,8 +118,9 @@ public void testSharedAlphaWithBeta() { assertThat(ksession.fireAllRules()).isEqualTo(2); } - @Test - public void testAlphaModify() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAlphaModify(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import " + Person.class.getCanonicalName() + "\n" + "rule R1 when\n" + @@ -141,8 +136,9 @@ public void testAlphaModify() { assertThat(ksession.fireAllRules()).isEqualTo(1); } - @Test - public void testAlphaDelete() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAlphaDelete(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import " + Person.class.getCanonicalName() + "\n" + "rule R1 when\n" + @@ -163,8 +159,9 @@ public void testAlphaDelete() { assertThat(ksession.fireAllRules()).isEqualTo(1); } - @Test - public void testAlphaModifyDelete() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAlphaModifyDelete(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import " + Person.class.getCanonicalName() + "\n" + "rule R1 when\n" + @@ -189,8 +186,9 @@ public void testAlphaModifyDelete() { assertThat(ksession.fireAllRules()).isEqualTo(3); } - @Test - public void testBetaModifyWithAlpha() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBetaModifyWithAlpha(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import " + Person.class.getCanonicalName() + "\n" + "rule R1 when\n" + @@ -212,8 +210,9 @@ public void testBetaModifyWithAlpha() { assertThat(ksession.fireAllRules()).isEqualTo(2); } - @Test - public void testAlphaModifyWithBeta() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAlphaModifyWithBeta(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import " + Person.class.getCanonicalName() + "\n" + "rule R1 when\n" + @@ -235,8 +234,9 @@ public void testAlphaModifyWithBeta() { assertThat(ksession.fireAllRules()).isEqualTo(2); } - @Test - public void test3Alpha() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void test3Alpha(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import " + Person.class.getCanonicalName() + "\n" + "rule R1 when\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DRLDumperTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DRLDumperTest.java index 21c08ce7094..5a0ad1a2f37 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DRLDumperTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DRLDumperTest.java @@ -19,8 +19,8 @@ package org.drools.mvel.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.drl.parser.DrlParser; import org.drools.drl.parser.DroolsError; @@ -31,10 +31,9 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.TestConstants; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.io.Resource; @@ -46,24 +45,17 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -@RunWith(Parameterized.class) public class DRLDumperTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public DRLDumperTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } private static Logger logger = LoggerFactory.getLogger( DRLDumperTest.class ); - @Test - public void testDumpers() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDumpers(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final DrlParser parser = new DrlParser(LanguageLevelOption.DRL5); final Resource resource = new InputStreamResource(getClass().getResourceAsStream("drl/test_Dumpers.drl")); final PackageDescr pkg = parser.parse(resource); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DateCoercionTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DateCoercionTest.java index 1dd24026b54..94f941b661f 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DateCoercionTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DateCoercionTest.java @@ -19,17 +19,16 @@ package org.drools.mvel.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.Date; import java.util.List; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.Message; @@ -37,22 +36,15 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class DateCoercionTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public DateCoercionTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testDateCoercionWithOr() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDateCoercionWithOr(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-296 String drl = "import java.util.Date\n" + "global java.util.List list\n" + @@ -82,8 +74,9 @@ public void testDateCoercionWithOr() { assertThat(list.get(0)).isEqualTo("working"); } - @Test - public void testDateCoercionWithVariable() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDateCoercionWithVariable(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-970 String drl = "import java.util.Date\n" + "global java.util.List list\n" + @@ -113,8 +106,9 @@ public void testDateCoercionWithVariable() { assertThat(list.get(0)).isEqualTo("working"); } - @Test - public void testDateCoercionWithInstanceVariable() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDateCoercionWithInstanceVariable(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-970 String drl = "import " + DateContainer.class.getCanonicalName() + "\n" + "import java.util.Date\n" + @@ -149,8 +143,9 @@ public DateContainer( Date date ) { } } - @Test - public void testDateCoercionWithNestedOr() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDateCoercionWithNestedOr(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-1253575 String drl = "import java.util.Date\n" + "global java.util.List list\n" + @@ -180,8 +175,9 @@ public void testDateCoercionWithNestedOr() { assertThat(list.get(0)).isEqualTo("working"); } - @Test - public void testLocalDateTimeCoercion() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLocalDateTimeCoercion(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-7631 String drl = "import java.util.Date\n" + "import java.time.LocalDateTime\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DateComparisonTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DateComparisonTest.java index 164fa148f73..0f77749a697 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DateComparisonTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DateComparisonTest.java @@ -20,18 +20,17 @@ import java.util.ArrayList; import java.util.Calendar; -import java.util.Collection; import java.util.Date; import java.util.GregorianCalendar; import java.util.List; +import java.util.stream.Stream; import org.drools.mvel.compiler.Cheese; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; @@ -40,22 +39,15 @@ /** * This is a sample class to launch a rule. */ -@RunWith(Parameterized.class) public class DateComparisonTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public DateComparisonTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testDateComparisonThan() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDateComparisonThan(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.drools.mvel.compiler;\n"; str += "global java.util.List results;\n"; @@ -95,8 +87,9 @@ public void testDateComparisonThan() throws Exception { assertThat(results.contains("test date less than")).isTrue(); } - @Test - public void testDateComparisonAfter() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDateComparisonAfter(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.drools.mvel.compiler;\n"; str += "global java.util.List results;\n"; @@ -136,8 +129,9 @@ public void testDateComparisonAfter() throws Exception { assertThat(results.contains("test date less than")).isTrue(); } - @Test - public void testDateComparisonAfterWithThisBinding() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDateComparisonAfterWithThisBinding(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.drools.mvel.compiler;\n"; str += "global java.util.List results;\n"; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DroolsEventListTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DroolsEventListTest.java index 6c00f973e30..e50b69beede 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DroolsEventListTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DroolsEventListTest.java @@ -18,17 +18,16 @@ */ package org.drools.mvel.integrationtests; -import java.util.Collection; import java.util.Comparator; +import java.util.stream.Stream; import ca.odell.glazedlists.SortedList; import org.drools.mvel.compiler.Cheese; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.rule.FactHandle; @@ -37,22 +36,15 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class DroolsEventListTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public DroolsEventListTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testOpenQuery() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOpenQuery(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.kie.test \n"; str += "import " + Cheese.class.getCanonicalName() + "\n"; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DroolsFromRHSTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DroolsFromRHSTest.java index 61188563f25..45c9f8902a9 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DroolsFromRHSTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DroolsFromRHSTest.java @@ -19,36 +19,28 @@ package org.drools.mvel.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class DroolsFromRHSTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public DroolsFromRHSTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testHalt() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testHalt(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "test_halt.drl"); KieSession ksession = kbase.newKieSession(); @@ -65,8 +57,9 @@ public void testHalt() throws Exception { } } - @Test - public void testFireLimit() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFireLimit(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "test_fireLimit.drl"); KieSession ksession = kbase.newKieSession(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DroolsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DroolsTest.java index 31edd9bf1ca..c8b7f44e70d 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DroolsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DroolsTest.java @@ -19,30 +19,22 @@ package org.drools.mvel.integrationtests; import java.io.Serializable; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; -@RunWith(Parameterized.class) public class DroolsTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public DroolsTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); - } private final static int NUM_FACTS = 20; private static int counter; @@ -71,8 +63,9 @@ public int getId() { } } - @Test - public void test1() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void test1(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "package org.drools.mvel.integrationtests;\n"; str += "import " + DroolsTest.class.getName() + ";\n"; str += "import " + DroolsTest.class.getName() + ".Foo;\n"; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DslTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DslTest.java index 18cf572779e..9ef5342cb36 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DslTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DslTest.java @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.drl.parser.lang.Expander; import org.drools.drl.parser.lang.dsl.DefaultExpanderResolver; @@ -36,11 +37,10 @@ import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieUtil; import org.drools.testcoverage.common.util.TestConstants; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; @@ -56,22 +56,15 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class DslTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public DslTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); - } - - @Test - public void testMultiLineTemplates() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMultiLineTemplates(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final Reader source = new InputStreamReader( getClass().getResourceAsStream( "rule_with_expander_multiline.dslr" ) ); final Reader dsl = new InputStreamReader( getClass().getResourceAsStream( "test_dsl_multiline.dsl" ) ); Expander ex = new DefaultExpanderResolver(dsl).get("*", null); @@ -79,8 +72,9 @@ public void testMultiLineTemplates() throws Exception { assertThat(r.trim()).isEqualTo("when Car(color==\"Red\") then doSomething();"); } - @Test - public void testWithExpanderDSL() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testWithExpanderDSL(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final Resource resource1 = KieServices.Factory.get().getResources().newClassPathResource("test_expander.dsl", getClass()); resource1.setSourcePath(TestConstants.TEST_RESOURCES_FOLDER + "test_expander.dsl"); final Resource resource2 = KieServices.Factory.get().getResources().newClassPathResource("rule_with_expander_dsl.dslr", getClass()); @@ -115,8 +109,9 @@ private void checkDSLExpanderTest(KieBuilder kieBuilder) throws IOException, Cla assertThat(messages.size()).isEqualTo(1); } - @Test - public void testWithExpanderMore() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testWithExpanderMore(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final Resource resource1 = KieServices.Factory.get().getResources().newClassPathResource("test_expander.dsl", getClass()); resource1.setSourcePath(TestConstants.TEST_RESOURCES_FOLDER + "test_expander.dsl"); final Resource resource2 = KieServices.Factory.get().getResources().newClassPathResource("rule_with_expander_dsl_more.dslr", getClass()); @@ -162,8 +157,10 @@ public void testWithExpanderMore() throws Exception { assertThat(messages.size()).isEqualTo(1); } - @Test @Ignore("antlr cannot parse correctly if the file ends with a comment without a further line break") - public void testEmptyDSL() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Disabled("antlr cannot parse correctly if the file ends with a comment without a further line break") + public void testEmptyDSL(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // FIXME etirelli / mic_hat not sure what to do with this? final String DSL = "# This is an empty dsl file."; // gives antlr error KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); @@ -194,8 +191,9 @@ public void testEmptyDSL() throws Exception { assertThat(pkgs).isNull(); } - @Test - public void testDSLWithIndividualConstraintMappings() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDSLWithIndividualConstraintMappings(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final Resource resource1 = KieServices.Factory.get().getResources().newClassPathResource("test_dslWithIndividualConstraints.dsl", getClass()); resource1.setSourcePath(TestConstants.TEST_RESOURCES_FOLDER + "test_dslWithIndividualConstraints.dsl"); final Resource resource2 = KieServices.Factory.get().getResources().newClassPathResource("test_dslWithIndividualConstraints.dslr", getClass()); @@ -229,8 +227,9 @@ public void testDSLWithIndividualConstraintMappings() throws Exception { } - @Test - public void testDSLWithSpaceBetweenParenthesis() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDSLWithSpaceBetweenParenthesis(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3438 String dsl = "[when]There is a Person=Person( )\n" + "[when]-named {name}=name == \"{name}\"\n" @@ -248,11 +247,12 @@ public void testDSLWithSpaceBetweenParenthesis() { + "Log \"OK\"\n" + "end\n"; - assertThat(doTest(dsl, drl).contains("OK")).isTrue(); + assertThat(doTest(kieBaseTestConfiguration, dsl, drl).contains("OK")).isTrue(); } - @Test - public void testDSLWithVariableBinding() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDSLWithVariableBinding(KieBaseTestConfiguration kieBaseTestConfiguration) { String dsl = "[when]There is a Person=$p : Person()\n" + "[when]-named {name}=name == \"{name}\"\n" + "[when]-aged less than {age}=age < {age}\n" @@ -269,11 +269,12 @@ public void testDSLWithVariableBinding() { + "Log person name\n" + "end\n"; - assertThat(doTest(dsl, drl).contains("Mario")).isTrue(); + assertThat(doTest(kieBaseTestConfiguration, dsl, drl).contains("Mario")).isTrue(); } - @Test - public void testDSLWithApostrophe() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDSLWithApostrophe(KieBaseTestConfiguration kieBaseTestConfiguration) { String dsl = "[when]Person's name is {name}=$p : Person(name == \"{name}\")\n" + "[then]Log person name=list.add($p.getName());"; @@ -286,11 +287,12 @@ public void testDSLWithApostrophe() { + "Log person name\n" + "end\n"; - assertThat(doTest(dsl, drl).contains("Mario")).isTrue(); + assertThat(doTest(kieBaseTestConfiguration, dsl, drl).contains("Mario")).isTrue(); } - @Test - public void testDSLWithCommentedBlock() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDSLWithCommentedBlock(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3445 String dsl = "[when]There is a Person=Person()\n" + "[when]-named {name}=name == \"{name}\"\n" @@ -310,11 +312,12 @@ public void testDSLWithCommentedBlock() { + "Log \"OK\"\n" + "end\n"; - assertThat(doTest(dsl, drl).contains("OK")).isTrue(); + assertThat(doTest(kieBaseTestConfiguration, dsl, drl).contains("OK")).isTrue(); } - @Test - public void testDSLWithSingleDotRegex() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDSLWithSingleDotRegex(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-430 String dsl = "[then]Log {message:.}=list.add(\"{message}\");"; @@ -326,10 +329,10 @@ public void testDSLWithSingleDotRegex() { + "Log X\n" + "end\n"; - assertThat(doTest(dsl, drl).contains("X")).isTrue(); + assertThat(doTest(kieBaseTestConfiguration, dsl, drl).contains("X")).isTrue(); } - private List doTest(String dsl, String drl) { + private List doTest(KieBaseTestConfiguration kieBaseTestConfiguration, String dsl, String drl) { final Resource resource1 = KieServices.Factory.get().getResources().newReaderResource(new StringReader(dsl)); resource1.setSourcePath(TestConstants.TEST_RESOURCES_FOLDER + "test_dsl.dsl"); final Resource resource2 = KieServices.Factory.get().getResources().newReaderResource(new StringReader(drl)); @@ -354,8 +357,9 @@ private List doTest(String dsl, String drl) { return list; } - @Test - public void testGreedyDsl() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGreedyDsl(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-1078839 String dsl = "[when]There is a number with value of {value}=i:Integer(intValue() == {value})\n" + "[when]There is a number with=i:Integer()\n"; @@ -376,8 +380,9 @@ public void testGreedyDsl() { assertThat(messages.size()).isEqualTo(0); } - @Test - public void testDSLWithSingleDot() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDSLWithSingleDot(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-768 String dsl = "[when][]if there is a simple event\n" + "{evtName}={evtName}" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DynamicRuleLoadTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DynamicRuleLoadTest.java index ea3fe5eec45..0a062a46672 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DynamicRuleLoadTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DynamicRuleLoadTest.java @@ -19,16 +19,15 @@ package org.drools.mvel.integrationtests; import java.lang.reflect.Field; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.compiler.kproject.models.KieModuleModelImpl; import org.drools.mvel.compiler.Message; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.builder.KieFileSystem; import org.kie.api.builder.KieModule; @@ -41,18 +40,10 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class DynamicRuleLoadTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public DynamicRuleLoadTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } private final String drl1 = @@ -128,8 +119,12 @@ public static Collection getParameters() { private boolean done = false; - @Test - public void testKJarUpgrade() throws Exception { + private KieBaseTestConfiguration kieBaseTestConfiguration; + + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKJarUpgrade(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + this.kieBaseTestConfiguration = kieBaseTestConfiguration; // DROOLS-919 KieServices ks = KieServices.Factory.get(); @@ -147,9 +142,10 @@ public void testKJarUpgrade() throws Exception { assertThat(done).isTrue(); } - - @Test - public void testKJarUpgradeWithJavaClass() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKJarUpgradeWithJavaClass(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + this.kieBaseTestConfiguration = kieBaseTestConfiguration; KieServices ks = KieServices.Factory.get(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DynamicRuleRemovalTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DynamicRuleRemovalTest.java index 0cf264cebce..4dba3b92ce5 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DynamicRuleRemovalTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DynamicRuleRemovalTest.java @@ -21,42 +21,35 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.kiesession.rulebase.InternalKnowledgeBase; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.builder.KieBuilder; import org.kie.api.definition.KiePackage; import org.kie.api.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class DynamicRuleRemovalTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public DynamicRuleRemovalTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testDynamicRuleRemoval() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDynamicRuleRemoval(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { InternalKnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();; - addRule(kbase, "rule1"); - addRule(kbase, "rule2"); - addRule(kbase, "rule3"); + addRule(kieBaseTestConfiguration, kbase, "rule1"); + addRule(kieBaseTestConfiguration, kbase, "rule2"); + addRule(kieBaseTestConfiguration, kbase, "rule3"); final KieSession ksession = kbase.newKieSession(); List rulesList = new ArrayList(); @@ -80,7 +73,7 @@ public void testDynamicRuleRemoval() throws Exception { assertThat(rulesList.contains("rule3")).isTrue(); } - private void addRule(InternalKnowledgeBase kbase, String ruleName) { + private void addRule(KieBaseTestConfiguration kieBaseTestConfiguration, InternalKnowledgeBase kbase, String ruleName) { String rule = createDRL(ruleName); KieBuilder kieBuilder = KieUtil.getKieBuilderFromDrls(kieBaseTestConfiguration, true, rule); Collection pkgs = KieBaseUtil.getDefaultKieBaseFromKieBuilder(kieBuilder).getKiePackages(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DynamicRulesChangesTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DynamicRulesChangesTest.java index b39fd2ce3c7..10e3fb5fae9 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DynamicRulesChangesTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DynamicRulesChangesTest.java @@ -28,6 +28,7 @@ import java.util.concurrent.ExecutorCompletionService; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.stream.Stream; import org.kie.api.definition.rule.Rule; import org.drools.kiesession.rulebase.InternalKnowledgeBase; @@ -35,12 +36,11 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.builder.KieBuilder; import org.kie.api.command.Command; import org.kie.api.definition.KiePackage; @@ -50,23 +50,16 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class DynamicRulesChangesTest { // Note: If PARALLEL_THREADS is set to 2 or larger, this test fails with the below Exception even before modifying this test to cover exec-model // Exception in thread pool-7-thread-1: Exception executing consequence for rule "Raise the alarm when we have one or more fires" in defaultpkg: // java.lang.IllegalArgumentException: Rule name 'Raise the alarm when we have one or more fires' does not exist in the Package 'defaultpkg'. - private final KieBaseTestConfiguration kieBaseTestConfiguration; private static KieBaseTestConfiguration staticKieBaseTestConfiguration; - public DynamicRulesChangesTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } private static final int PARALLEL_THREADS = 1; @@ -74,26 +67,31 @@ public static Collection getParameters() { private static InternalKnowledgeBase kbase; private ExecutorService executor; - @Before - public void setUp() throws Exception { + public void setUp(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { staticKieBaseTestConfiguration = kieBaseTestConfiguration; executor = Executors.newFixedThreadPool(PARALLEL_THREADS); kbase = KnowledgeBaseFactory.newKnowledgeBase(); addRule("raiseAlarm"); } - @After + @AfterEach public void tearDown() throws Exception { executor.shutdownNow(); } - @Test(timeout=10000) - public void testConcurrentRuleAdditions() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testConcurrentRuleAdditions(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + setUp(kieBaseTestConfiguration); parallelExecute(RulesExecutor.getSolvers()); } - @Test(timeout=10000) - public void testBatchRuleAdditions() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testBatchRuleAdditions(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + setUp(kieBaseTestConfiguration); parallelExecute(BatchRulesExecutor.getSolvers()); } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DynamicRulesTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DynamicRulesTest.java index ae39735735b..d3961c30aa7 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DynamicRulesTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/DynamicRulesTest.java @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.core.RuleBaseConfiguration; import org.drools.core.common.InternalAgenda; @@ -44,11 +45,11 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.KieBaseConfiguration; import org.kie.api.builder.KieModule; @@ -73,23 +74,17 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -@RunWith(Parameterized.class) public class DynamicRulesTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public DynamicRulesTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - // TODO: EM failed with some tests. File JIRAs - return TestParametersUtil.getKieBaseCloudConfigurations(false); + public static Stream parameters() { + // TODO: EM failed with some tests. File JIRAs + return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); } - @Test(timeout=10000) - public void testDynamicRuleAdditions() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testDynamicRuleAdditions(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { InternalKnowledgeBase kbase = (InternalKnowledgeBase)KieBaseUtil.getKieBaseFromClasspathResources("test", getClass(), kieBaseTestConfiguration, "test_Dynamic1.drl"); KieSession workingMemory = kbase.newKieSession(); workingMemory.setGlobal("total", @@ -159,8 +154,10 @@ public void testDynamicRuleAdditions() throws Exception { } - @Test(timeout=10000) - public void testDynamicRuleRemovals() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testDynamicRuleRemovals(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { InternalKnowledgeBase kbase = (InternalKnowledgeBase)KieBaseUtil.getKieBaseFromClasspathResources("test", getClass(), kieBaseTestConfiguration, "test_Dynamic1.drl", "test_Dynamic3.drl", "test_Dynamic4.drl"); Collection kpkgs = KieBaseUtil.getKieBaseFromClasspathResources("tmp", getClass(), kieBaseTestConfiguration, "test_Dynamic2.drl").getKiePackages(); @@ -232,8 +229,10 @@ public void testDynamicRuleRemovals() throws Exception { list.clear(); } - @Test(timeout=10000) - public void testDynamicRuleRemovalsUnusedWorkingMemory() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testDynamicRuleRemovalsUnusedWorkingMemory(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { InternalKnowledgeBase kbase = (InternalKnowledgeBase) KieBaseUtil.getKieBaseFromClasspathResources("test", getClass(), kieBaseTestConfiguration, "test_Dynamic1.drl", "test_Dynamic2.drl", "test_Dynamic3.drl", @@ -265,9 +264,11 @@ public void testDynamicRuleRemovalsUnusedWorkingMemory() throws Exception { assertThat(kbase.getKiePackages().size()).isEqualTo(1); } - @Ignore("Fails with standard-drl after changing to new API. See DROOLS-6060") - @Test(timeout=10000) - public void testDynamicFunction() throws Exception { + @Disabled("Fails with standard-drl after changing to new API. See DROOLS-6060") + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testDynamicFunction(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { //JBRULES-1258 serialising a package breaks function removal -- left the serialisation commented out for now Collection kpkgs = KieBaseUtil.getKieBaseFromClasspathResources("tmp", getClass(), kieBaseTestConfiguration, "test_DynamicFunction1.drl").getKiePackages(); @@ -327,8 +328,10 @@ public void testDynamicFunction() throws Exception { assertThat(list.get(2)).isEqualTo(new Integer( 5 )); } - @Test (timeout=10000) - public void testRemovePackage() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testRemovePackage(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { Collection kpkgs = KieBaseUtil.getKieBaseFromClasspathResources("tmp", getClass(), kieBaseTestConfiguration, "test_RemovePackage.drl").getKiePackages(); final String packageName = kpkgs.iterator().next().getName(); InternalKnowledgeBase kbase = (InternalKnowledgeBase)KieBaseUtil.getKieBaseFromClasspathResources("test", getClass(), kieBaseTestConfiguration); @@ -359,8 +362,10 @@ public void testRemovePackage() throws Exception { ruleBaseWM.addPackages(SerializationHelper.serializeObject(kpkgs)); } - @Test(timeout=10000) - public void testDynamicRules() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testDynamicRules(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { InternalKnowledgeBase kbase = (InternalKnowledgeBase)KieBaseUtil.getKieBaseFromClasspathResources("test", getClass(), kieBaseTestConfiguration); KieSession session = kbase.newKieSession(); @@ -383,8 +388,10 @@ public void testDynamicRules() throws Exception { session.fireAllRules(); } - @Test(timeout=10000) - public void testDynamicRules2() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testDynamicRules2(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { InternalKnowledgeBase kbase = (InternalKnowledgeBase)KieBaseUtil.getKieBaseFromClasspathResources("test", getClass(), kieBaseTestConfiguration); KieSession session = kbase.newKieSession(); @@ -407,8 +414,10 @@ public void testDynamicRules2() throws Exception { session.fireAllRules(); } - @Test(timeout=10000) - public void testRuleBaseAddRemove() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testRuleBaseAddRemove(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { InternalKnowledgeBase kbase = (InternalKnowledgeBase)KieBaseUtil.getKieBaseFromClasspathResources("test", getClass(), kieBaseTestConfiguration); //add and remove @@ -424,8 +433,10 @@ public void testRuleBaseAddRemove() throws Exception { kbase.removeKiePackage( pkgName ); } - @Test(timeout=10000) - public void testClassLoaderSwitchsUsingConf() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testClassLoaderSwitchsUsingConf(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { try { // Creates first class loader and use it to load fact classes ClassLoader loader1 = new SubvertedClassLoader( new URL[]{getClass().getResource( "/" )}, @@ -454,8 +465,10 @@ public void testClassLoaderSwitchsUsingConf() throws Exception { } - @Test(timeout=10000) - public void testClassLoaderSwitchsUsingContext() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testClassLoaderSwitchsUsingContext(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { try { // Creates first class loader and use it to load fact classes ClassLoader original = Thread.currentThread().getContextClassLoader(); @@ -489,17 +502,21 @@ public void testClassLoaderSwitchsUsingContext() throws Exception { } } - @Test(timeout=10000) - public void testCollectDynamicRules() throws Exception { - checkCollectWithDynamicRules( "test_CollectDynamicRules1.drl" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testCollectDynamicRules(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + checkCollectWithDynamicRules( kieBaseTestConfiguration, "test_CollectDynamicRules1.drl" ); } - @Test(timeout=10000) - public void testCollectDynamicRulesWithExistingOTN() throws Exception { - checkCollectWithDynamicRules( "test_CollectDynamicRules1a.drl" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testCollectDynamicRulesWithExistingOTN(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + checkCollectWithDynamicRules( kieBaseTestConfiguration, "test_CollectDynamicRules1a.drl" ); } - private void checkCollectWithDynamicRules(String originalDrl) throws java.io.IOException, ClassNotFoundException { + private void checkCollectWithDynamicRules(KieBaseTestConfiguration kieBaseTestConfiguration, String originalDrl) throws java.io.IOException, ClassNotFoundException { InternalKnowledgeBase kbase = (InternalKnowledgeBase)KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, originalDrl); KieSession session = kbase.newKieSession(); @@ -526,8 +543,10 @@ private void checkCollectWithDynamicRules(String originalDrl) throws java.io.IOE assertThat(((List) list.get(0)).size()).isEqualTo(2); } - @Test(timeout=10000) - public void testDynamicNotNode() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testDynamicNotNode(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { InternalKnowledgeBase kbase = (InternalKnowledgeBase)KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_CollectDynamicRules1.drl"); Environment env = EnvironmentFactory.newEnvironment(); env.set( EnvironmentName.OBJECT_MARSHALLING_STRATEGIES, new ObjectMarshallingStrategy[]{ @@ -576,8 +595,10 @@ public void testDynamicNotNode() throws Exception { assertThat(results.size()).isEqualTo(1); } - @Test(timeout=10000) - public void testDynamicRulesAddRemove() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testDynamicRulesAddRemove(KieBaseTestConfiguration kieBaseTestConfiguration) { try { InternalKnowledgeBase kbase = (InternalKnowledgeBase) KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_DynamicRulesTom.drl"); KieSession session = kbase.newKieSession(); @@ -648,8 +669,10 @@ public void testDynamicRulesAddRemove() { } } - @Test(timeout=10000) - public void testDynamicRuleRemovalsSubNetwork() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testDynamicRuleRemovalsSubNetwork(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { Collection kpkgs = KieBaseUtil.getKieBaseFromClasspathResources("tmp", getClass(), kieBaseTestConfiguration, "test_DynamicRulesWithSubnetwork1.drl", "test_DynamicRulesWithSubnetwork.drl").getKiePackages(); @@ -745,8 +768,10 @@ public void testDynamicRuleRemovalsSubNetwork() throws Exception { assertThat(list.size()).isEqualTo(0); } - @Test(timeout=10000) - public void testDynamicRuleRemovalsUnusedWorkingMemorySubNetwork() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testDynamicRuleRemovalsUnusedWorkingMemorySubNetwork(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { InternalKnowledgeBase kbase = (InternalKnowledgeBase) KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_DynamicRulesWithSubnetwork1.drl", "test_DynamicRulesWithSubnetwork2.drl", @@ -765,8 +790,10 @@ public void testDynamicRuleRemovalsUnusedWorkingMemorySubNetwork() throws Except assertThat(kbase.getKiePackages().size()).isEqualTo(1); } - @Test(timeout=10000) - public void testRemovePackageSubNetwork() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testRemovePackageSubNetwork(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_DynamicRulesWithSubnetwork.drl"); String packageName = kbase.getKiePackages().iterator().next().getName(); @@ -843,8 +870,10 @@ public void testRemovePackageSubNetwork() throws Exception { results.clear(); } - @Test(timeout=10000) - public void testRuleBaseAddRemoveSubNetworks() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testRuleBaseAddRemoveSubNetworks(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { try { //add and remove InternalKnowledgeBase kbase = (InternalKnowledgeBase) KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration); @@ -865,8 +894,10 @@ public void testRuleBaseAddRemoveSubNetworks() throws Exception { } } - @Test (timeout=10000) - public void testDynamicRuleAdditionsWithEntryPoints() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testDynamicRuleAdditionsWithEntryPoints(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { InternalKnowledgeBase kbase = (InternalKnowledgeBase) KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration); Collection kpkgs = KieBaseUtil.getKieBaseFromClasspathResources("tmp", getClass(), kieBaseTestConfiguration, "test_DynamicWithEntryPoint.drl").getKiePackages(); @@ -898,8 +929,10 @@ public void testDynamicRuleAdditionsWithEntryPoints() throws Exception { } - @Test(timeout=10000) - public void testIsolatedClassLoaderWithEnumsPkgBuilder() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testIsolatedClassLoaderWithEnumsPkgBuilder(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { try { // Creates first class loader and use it to load fact classes ClassLoader loader1 = new SubvertedClassLoader( new URL[]{getClass().getResource( "/testEnum.jar" )}, @@ -947,8 +980,10 @@ public void testIsolatedClassLoaderWithEnumsPkgBuilder() throws Exception { } } - @Test(timeout=10000) - public void testIsolatedClassLoaderWithEnumsContextClassloader() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testIsolatedClassLoaderWithEnumsContextClassloader(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { try { // Creates first class loader and use it to load fact classes ClassLoader loader1 = new SubvertedClassLoader( new URL[]{getClass().getResource( "/testEnum.jar" )}, @@ -1010,8 +1045,10 @@ public void testIsolatedClassLoaderWithEnumsContextClassloader() throws Exceptio } } - @Test(timeout=10000) - public void testDynamicRuleRemovalsSubNetworkAndNot() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testDynamicRuleRemovalsSubNetworkAndNot(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { InternalKnowledgeBase kbase = (InternalKnowledgeBase) KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_DynamicRulesWithNotSubnetwork.drl"); KieSession ksession = kbase.newKieSession(); @@ -1052,8 +1089,10 @@ public void testDynamicRuleRemovalsSubNetworkAndNot() throws Exception { } - @Test(timeout=10000) - public void testSharedLIANodeRemoval() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testSharedLIANodeRemoval(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // it's not a true share, but the liaNode will have two sinks, due to subnetwork. String str = "global java.util.List list;\n"; str += "rule \"test\"\n"; @@ -1089,8 +1128,10 @@ public void testSharedLIANodeRemoval() throws Exception { assertThat(list.size()).isEqualTo(1); } - @Test(timeout=10000) - public void testDynamicRulesWithTypeDeclarations() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testDynamicRulesWithTypeDeclarations(KieBaseTestConfiguration kieBaseTestConfiguration) { // Note: This test originally use "kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder( kbase );" which is not possible with KieBuilder // Probably this new test is not valid for exec-model and we can remove this test @@ -1145,8 +1186,10 @@ public void testDynamicRulesWithTypeDeclarations() { } - @Test(timeout=10000) - public void testJBRULES_2206() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testJBRULES_2206(KieBaseTestConfiguration kieBaseTestConfiguration) { KieBaseConfiguration config = RuleBaseFactory.newKnowledgeBaseConfiguration(); config.as(RuleBaseConfiguration.KEY).setRuleBaseUpdateHandler( null ); @@ -1211,8 +1254,9 @@ protected synchronized Class loadClass(String name, } } - @Test - public void testSegmentMerging() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSegmentMerging(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl1 = "global java.util.List list\n" + "rule R1 when\n" + " $s : String()\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/EdgeCaseNonExecModelTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/EdgeCaseNonExecModelTest.java index 2ab9ee21fc1..ff89a1d914d 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/EdgeCaseNonExecModelTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/EdgeCaseNonExecModelTest.java @@ -19,16 +19,15 @@ package org.drools.mvel.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.mvel.compiler.Cheese; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; @@ -38,24 +37,17 @@ * This is a place where minor edge cases which fail with exec-model can be temporarily moved from test-compiler-integration test classes. * When fixed, you should move them back to the original test class (or remove @Ignore from the test method). */ -@RunWith(Parameterized.class) public class EdgeCaseNonExecModelTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public EdgeCaseNonExecModelTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(false); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); } // Moved from NamedConsequencesTest // DROOLS-6290 - @Test - public void testNamedConsequencesInsideOR1() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNamedConsequencesInsideOR1(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + @@ -70,7 +62,7 @@ public void testNamedConsequencesInsideOR1() { " results.add( $a.getType() );\n" + "end\n"; - List results = executeTestWithDRL(str); + List results = executeTestWithDRL(kieBaseTestConfiguration, str); assertThat(results.size()).isEqualTo(2); assertThat(results.contains("cheddar")).isTrue(); @@ -79,8 +71,9 @@ public void testNamedConsequencesInsideOR1() { // Moved from NamedConsequencesTest // DROOLS-6290 - @Test - public void testNamedConsequencesInsideOR2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNamedConsequencesInsideOR2(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + @@ -95,13 +88,13 @@ public void testNamedConsequencesInsideOR2() { " results.add( $b.getType() );\n" + "end\n"; - List results = executeTestWithDRL(str); + List results = executeTestWithDRL(kieBaseTestConfiguration, str); assertThat(results.size()).isEqualTo(1); assertThat(results.contains("cheddar")).isTrue(); } - private List executeTestWithDRL(String drl) { + private List executeTestWithDRL(KieBaseTestConfiguration kieBaseTestConfiguration, String drl) { KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, drl); KieSession ksession = kbase.newKieSession(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/EnableAuditLogCommandTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/EnableAuditLogCommandTest.java index cc41a067d8f..b2733f781ce 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/EnableAuditLogCommandTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/EnableAuditLogCommandTest.java @@ -20,17 +20,16 @@ import java.io.File; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.mvel.compiler.Cheese; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.After; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.command.Command; import org.kie.api.runtime.KieSession; @@ -38,24 +37,16 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class EnableAuditLogCommandTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public EnableAuditLogCommandTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } private String auditFileDir = "target"; private String auditFileName = "EnableAuditLogCommandTest"; - @After + @AfterEach public void cleanUp() { File file = new File( auditFileDir + File.separator + auditFileName + ".log" ); if ( file.exists() ) { @@ -63,8 +54,9 @@ public void cleanUp() { } } - @Test - public void testEnableAuditLogCommand() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEnableAuditLogCommand(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.drools.mvel.integrationtests \n"; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/EnumTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/EnumTest.java index c861d912349..31567039160 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/EnumTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/EnumTest.java @@ -20,16 +20,16 @@ import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.kiesession.rulebase.InternalKnowledgeBase; import org.drools.mvel.compiler.Triangle; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.Message; @@ -41,22 +41,15 @@ /** * Test for declared Enums */ -@RunWith(Parameterized.class) public class EnumTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public EnumTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testEnums() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEnums(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_Enums.drl"); KieSession ksession = kbase.newKieSession(); final java.util.List list = new java.util.ArrayList(); @@ -71,8 +64,9 @@ public void testEnums() throws Exception { ksession.dispose(); } - @Test - public void testEnumsWithCompositeBuildingProcess() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEnumsWithCompositeBuildingProcess(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final String drl = "package org.test; " + "" + "declare enum DaysOfWeek " + @@ -88,8 +82,9 @@ public void testEnumsWithCompositeBuildingProcess() throws Exception { assertThat(errors.isEmpty()).as(errors.toString()).isTrue(); } - @Test - public void testQueryEnum() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryEnum(KieBaseTestConfiguration kieBaseTestConfiguration) { final String str = "package org.kie.test;\n" + "\n" + "declare enum Ennumm\n" + @@ -138,8 +133,9 @@ public void testQueryEnum() { ksession.dispose(); } - @Test - public void testInnerEnum() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInnerEnum(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final StringBuilder rule = new StringBuilder(); rule.append( "package org.drools.mvel.compiler\n" ); rule.append( "rule X\n" ); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ExecutionFlowControlTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ExecutionFlowControlTest.java index 8c0b40dcb94..552a97948fc 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ExecutionFlowControlTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ExecutionFlowControlTest.java @@ -34,10 +34,10 @@ import org.drools.mvel.compiler.Pet; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.event.rule.AfterMatchFiredEvent; import org.kie.api.event.rule.AgendaEventListener; @@ -48,28 +48,22 @@ import org.kie.api.runtime.rule.FactHandle; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class ExecutionFlowControlTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public ExecutionFlowControlTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test(timeout = 10000) - public void testSalienceIntegerAndLoadOrder() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testSalienceIntegerAndLoadOrder(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "test_salienceIntegerRule.drl"); KieSession ksession = null; try { @@ -93,8 +87,9 @@ public void testSalienceIntegerAndLoadOrder() throws Exception { } } - @Test - public void testSalienceExpression() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSalienceExpression(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "test_salienceExpressionRule.drl"); KieSession ksession = kbase.newKieSession(); @@ -115,8 +110,9 @@ public void testSalienceExpression() throws Exception { assertThat(list.get(1)).as("Rule 2 should have been fired second").isEqualTo("Rule 2"); } - @Test - public void testSalienceExpressionWithOr() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSalienceExpressionWithOr(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String text = "package org.kie.test\n" + "global java.util.List list\n" + "import " + FactA.class.getCanonicalName() + "\n" @@ -164,8 +160,9 @@ public void testSalienceExpressionWithOr() throws Exception { assertThat(list.get(2)).isEqualTo(fact1); } - @Test - public void testSalienceMinInteger() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSalienceMinInteger(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String text = "package org.kie.test\n" + "global java.util.List list\n" + "rule a\n" @@ -193,8 +190,9 @@ public void testSalienceMinInteger() throws Exception { assertThat(list.get(2)).isEqualTo("b"); } - @Test - public void testLoadOrderConflictResolver() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLoadOrderConflictResolver(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String text = "package org.kie.test\n" + "global java.util.List list\n" + "rule a\n" @@ -262,8 +260,9 @@ public void testLoadOrderConflictResolver() throws Exception { - @Test - public void testEnabledExpressionWithOr() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEnabledExpressionWithOr(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String text = "package org.kie.test\n" + "global java.util.List list\n" + "import " + FactA.class.getCanonicalName() + "\n" @@ -310,8 +309,9 @@ public void testEnabledExpressionWithOr() throws Exception { assertThat(list.get(1)).isEqualTo(fact3); } - @Test - public void testNoLoop() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNoLoop(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "no-loop.drl"); KieSession ksession = kbase.newKieSession();; @@ -327,8 +327,9 @@ public void testNoLoop() throws Exception { } - @Test - public void testNoLoopWithModify() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNoLoopWithModify(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "no-loop_with_modify.drl"); KieSession ksession = kbase.newKieSession(); @@ -346,8 +347,9 @@ public void testNoLoopWithModify() throws Exception { } - @Test - public void testLockOnActive() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLockOnActive(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "test_LockOnActive.drl"); KieSession ksession = kbase.newKieSession(); @@ -380,8 +382,9 @@ public void testLockOnActive() throws Exception { assertThat(group2.size()).isEqualTo(1); } - @Test - public void testLockOnActiveForMain() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLockOnActiveForMain(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = ""; str += "package org.kie \n"; str += "global java.util.List list \n"; @@ -413,8 +416,9 @@ public void testLockOnActiveForMain() { assertThat(list.size()).isEqualTo(6); } - @Test - public void testLockOnActiveForMainWithHalt() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLockOnActiveForMainWithHalt(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = ""; str += "package org.kie \n"; str += "global java.util.List list \n"; @@ -449,8 +453,9 @@ public void testLockOnActiveForMainWithHalt() { assertThat(list.size()).isEqualTo(3); } - @Test - public void testLockOnActiveWithModify() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLockOnActiveWithModify(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "test_LockOnActiveWithUpdate.drl"); KieSession ksession = kbase.newKieSession(); @@ -509,8 +514,9 @@ public void testLockOnActiveWithModify() throws Exception { assertThat(ruleItem2.getRuleExecutor().getActiveMatches().size()).isEqualTo(2); } - @Test - public void testLockOnActiveWithModify2() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLockOnActiveWithModify2(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "test_LockOnActiveWithModify.drl"); KieSession ksession = kbase.newKieSession(); @@ -643,8 +649,9 @@ private void assertEqualsMatrix(final int size, } } - @Test - public void testAgendaGroups() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAgendaGroups(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "test_AgendaGroups.drl"); KieSession ksession = kbase.newKieSession(); @@ -673,8 +680,9 @@ public void testAgendaGroups() throws Exception { assertThat(list.get(7)).isEqualTo("group2"); } - @Test - public void testActivationGroups() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testActivationGroups(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "test_ActivationGroups.drl"); KieSession ksession = kbase.newKieSession(); @@ -717,10 +725,11 @@ public String getOutcome() { } } - @Test + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") // JBRULES-2398 public void - testActivationGroupWithTroubledSyntax() { + testActivationGroupWithTroubledSyntax(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package BROKEN_TEST;\n" + "import " + Holder.class.getCanonicalName() + ";\n" + "rule \"_12\"\n" @@ -783,8 +792,9 @@ public String getOutcome() { assertThat(inrec.getOutcome()).isEqualTo("setting 0"); } - @Test - public void testInsertRetractNoloop() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInsertRetractNoloop(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // read in the source KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "test_Insert_Retract_Noloop.drl"); KieSession ksession = kbase.newKieSession(); @@ -795,8 +805,9 @@ public void testInsertRetractNoloop() throws Exception { assertThat(ksession.getObjects().size()).isEqualTo(0); } - @Test - public void testUpdateNoLoop() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUpdateNoLoop(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // JBRULES-780, throws a NullPointer or infinite loop if there is an // issue KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "test_UpdateNoloop.drl"); @@ -811,8 +822,9 @@ public void testUpdateNoLoop() throws Exception { assertThat(cheese.getPrice()).isEqualTo(14); } - @Test - public void testUpdateActivationCreationNoLoop() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUpdateActivationCreationNoLoop(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // JBRULES-787, no-loop blocks all dependant tuples for update KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "test_UpdateActivationCreationNoLoop.drl"); @@ -862,8 +874,9 @@ public void matchCancelled(MatchCancelledEvent event) { assertThat(cancelled.size()).isEqualTo(0); } - @Test - public void testRuleFlowGroup() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRuleFlowGroup(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "ruleflowgroup.drl"); KieSession ksession = kbase.newKieSession(); @@ -880,8 +893,9 @@ public void testRuleFlowGroup() throws Exception { assertThat(list.size()).isEqualTo(1); } - @Test - public void testRuleFlowGroupDeactivate() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRuleFlowGroupDeactivate(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // need to make eager, for cancel to work, (mdp) KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "ruleflowgroup2.drl"); @@ -902,8 +916,10 @@ public void testRuleFlowGroupDeactivate() throws Exception { assertThat(list.size()).isEqualTo(0); } - @Test(timeout=10000) - public void testRuleFlowGroupInActiveMode() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testRuleFlowGroupInActiveMode(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "ruleflowgroup.drl"); final KieSession ksession = kbase.newKieSession(); @@ -943,8 +959,9 @@ public void afterMatchFired(AfterMatchFiredEvent event) { } } - @Test - public void testDateEffective() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDateEffective(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // read in the source KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "test_EffectiveDate.drl"); @@ -961,21 +978,22 @@ public void testDateEffective() throws Exception { assertThat(message.isFired()).isFalse(); } - @Test - public void testNullPointerOnModifyWithLockOnActive() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNullPointerOnModifyWithLockOnActive(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3234 String str = "package org.kie.test \n" + "import org.drools.mvel.compiler.Person; \n" - + "rule 'Rule 1' agenda-group 'g1' lock-on-active when \n" - + " $p : Person( age != 35 ) \n" - + " then \n" - + " modify( $p ) { setAge( 35 ) }; \n" + + "rule 'Rule 1' agenda-group 'g1' lock-on-active when \n" + + " $p : Person( age != 35 ) \n" + + " then \n" + + " modify( $p ) { setAge( 35 ) }; \n" + "end \n" + "rule 'Rule 2' agenda-group 'g1' no-loop when \n" - + " $p: Person( age == 35) \n" - + " then \n" - + " modify( $p ) { setAge( 36 ) }; \n" + + " $p: Person( age == 35) \n" + + " then \n" + + " modify( $p ) { setAge( 36 ) }; \n" + "end \n"; KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, str); @@ -994,8 +1012,9 @@ public void testNullPointerOnModifyWithLockOnActive() { } - @Test - public void testAgendaGroupGivewaySequence() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAgendaGroupGivewaySequence(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-999360 String str = "global java.util.List ruleList\n" + @@ -1059,8 +1078,9 @@ public void testAgendaGroupGivewaySequence() { assertThat(ruleList.get(7)).isEqualTo(3); } - @Test - public void testActivationGroupWithNots() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testActivationGroupWithNots(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-1318052 String drl = "global java.util.List list;\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ExistentialOperatorTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ExistentialOperatorTest.java index 4e1de4569cf..d582ebc414b 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ExistentialOperatorTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ExistentialOperatorTest.java @@ -18,36 +18,28 @@ */ package org.drools.mvel.integrationtests; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import static org.assertj.core.api.Assertions.assertThat; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.definition.type.FactType; import org.kie.api.runtime.KieSession; -@RunWith(Parameterized.class) public class ExistentialOperatorTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public ExistentialOperatorTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testForallAfterOr() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testForallAfterOr(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-2710 String str = "package redhat\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ExpirationTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ExpirationTest.java index d99aee46c53..5b3da87998d 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ExpirationTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ExpirationTest.java @@ -19,24 +19,22 @@ package org.drools.mvel.integrationtests; import java.time.Duration; -import java.util.Collection; import java.util.Date; import java.util.Objects; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Stream; import org.kie.api.runtime.ClassObjectFilter; import org.drools.core.ClockType; -import org.drools.core.SessionConfiguration; import org.drools.core.impl.RuleBaseFactory; import org.drools.core.time.impl.PseudoClockScheduler; import org.drools.mvel.integrationtests.facts.BasicEvent; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.definition.type.Expires; @@ -48,22 +46,15 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.kie.api.definition.type.Expires.Policy.TIME_SOFT; -@RunWith(Parameterized.class) public class ExpirationTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public ExpirationTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseStreamConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseStreamConfigurations(true).stream(); } - @Test - public void testAlpha() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAlpha(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "import " + A.class.getCanonicalName() + "\n" + "declare A @role( event ) @expires(11ms) end\n" + "global java.util.concurrent.atomic.AtomicInteger counter;\n" + @@ -96,8 +87,9 @@ public void testAlpha() { assertThat(counter.get()).isEqualTo(2); } - @Test - public void testBeta() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBeta(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1329 String drl = "import " + A.class.getCanonicalName() + "\n" + "import " + B.class.getCanonicalName() + "\n" + @@ -136,8 +128,9 @@ public void testBeta() { assertThat(counter.get()).isEqualTo(2); } - @Test - public void testBetaRightExpired() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBetaRightExpired(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1329 String drl = "import " + A.class.getCanonicalName() + "\n" + "import " + B.class.getCanonicalName() + "\n" + @@ -172,8 +165,9 @@ public void testBetaRightExpired() { assertThat(counter.get()).isEqualTo(0); } - @Test - public void testBetaLeftExpired() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBetaLeftExpired(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1329 String drl = "import " + A.class.getCanonicalName() + "\n" + "import " + B.class.getCanonicalName() + "\n" + @@ -208,8 +202,9 @@ public void testBetaLeftExpired() { assertThat(counter.get()).isEqualTo(0); } - @Test - public void testBetaLeftExpired2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBetaLeftExpired2(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1329 String drl = "import " + A.class.getCanonicalName() + "\n" + "import " + B.class.getCanonicalName() + "\n" + @@ -312,8 +307,9 @@ public static class ExpiringEventB { } @Expires( value = "30s", policy = TIME_SOFT ) public static class ExpiringEventC { } - @Test - public void testSoftExpiration() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSoftExpiration(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1483 String drl = "import " + ExpiringEventA.class.getCanonicalName() + "\n" + "import " + ExpiringEventB.class.getCanonicalName() + "\n" + @@ -373,8 +369,9 @@ public void testSoftExpiration() { assertThat(ksession.getObjects(new ClassObjectFilter( ExpiringEventC.class )).size()).isEqualTo(0); } - @Test - public void testSoftExpirationWithDeclaration() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSoftExpirationWithDeclaration(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1483 String drl = "import " + A.class.getCanonicalName() + "\n" + "import " + B.class.getCanonicalName() + "\n" + @@ -437,8 +434,9 @@ public void testSoftExpirationWithDeclaration() { assertThat(ksession.getObjects(new ClassObjectFilter( C.class )).size()).isEqualTo(0); } - @Test - public void testEventsExpiredInThePast() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEventsExpiredInThePast(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { final String drl = " package org.drools.mvel.integrationtests;\n" + " import " + BasicEvent.class.getCanonicalName() + ";\n" + @@ -455,11 +453,12 @@ public void testEventsExpiredInThePast() throws InterruptedException { " then \n" + " end\n"; - testEventsExpiredInThePast(drl); + testEventsExpiredInThePast(kieBaseTestConfiguration, drl); } - @Test - public void testEventsExpiredInThePastTemporalConstraint() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEventsExpiredInThePastTemporalConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { final String drl = " package org.drools.mvel.integrationtests;\n" + " import " + BasicEvent.class.getCanonicalName() + ";\n" + @@ -476,10 +475,10 @@ public void testEventsExpiredInThePastTemporalConstraint() throws InterruptedExc " then \n" + " end\n"; - testEventsExpiredInThePast(drl); + testEventsExpiredInThePast(kieBaseTestConfiguration, drl); } - private void testEventsExpiredInThePast(final String drl) { + private void testEventsExpiredInThePast(KieBaseTestConfiguration kieBaseTestConfiguration, final String drl) { final KieSessionConfiguration sessionConfig = RuleBaseFactory.newKnowledgeSessionConfiguration(); sessionConfig.setOption( ClockTypeOption.get( ClockType.PSEUDO_CLOCK.getId() ) ); @@ -503,28 +502,32 @@ private void testEventsExpiredInThePast(final String drl) { assertThat(kieSession.getObjects()).isEmpty(); } - @Test - public void testExpiredEventWithIdConstraint() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExpiredEventWithIdConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { // DROOLS-4577 - testEventExpiredContraint(true, true); + testEventExpiredContraint(kieBaseTestConfiguration, true, true); } - @Test - public void testExpiredEventWithoutIdConstraint() throws InterruptedException { - testEventExpiredContraint(true, false); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExpiredEventWithoutIdConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + testEventExpiredContraint(kieBaseTestConfiguration, true, false); } - @Test - public void testNotExpiredEventWithIdConstraint() throws InterruptedException { - testEventExpiredContraint(false, true); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNotExpiredEventWithIdConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + testEventExpiredContraint(kieBaseTestConfiguration, false, true); } - @Test - public void testNotExpiredEventWithoutIdConstraint() throws InterruptedException { - testEventExpiredContraint(false, false); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNotExpiredEventWithoutIdConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + testEventExpiredContraint(kieBaseTestConfiguration, false, false); } - private void testEventExpiredContraint(boolean expired, boolean constraint) throws InterruptedException { + private void testEventExpiredContraint(KieBaseTestConfiguration kieBaseTestConfiguration, boolean expired, boolean constraint) throws InterruptedException { final String drl = " package org.drools.mvel.integrationtests;\n" + " import " + DummyEvent.class.getCanonicalName() + ";\n" + @@ -701,8 +704,9 @@ public void setDummyEventId(int dummyEventId) { } } - @Test - public void testEventSameContraint() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEventSameContraint(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { // DROOLS-4580 final String drl = " package org.drools.mvel.integrationtests;\n" + @@ -741,18 +745,20 @@ public void testEventSameContraint() throws InterruptedException { assertThat(kieSession.fireAllRules()).isEqualTo(2); } - @Test - public void testCollectWithExpiredEvent() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCollectWithExpiredEvent(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-4626 - testCollectExpiredEvent(true); + testCollectExpiredEvent(kieBaseTestConfiguration, true); } - @Test - public void testCollectWithoutExpiredEvent() { - testCollectExpiredEvent(false); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCollectWithoutExpiredEvent(KieBaseTestConfiguration kieBaseTestConfiguration) { + testCollectExpiredEvent(kieBaseTestConfiguration, false); } - private void testCollectExpiredEvent(boolean expired) { + private void testCollectExpiredEvent(KieBaseTestConfiguration kieBaseTestConfiguration, boolean expired) { final String drl = " package org.drools.mvel.integrationtests;\n" + @@ -766,13 +772,13 @@ private void testCollectExpiredEvent(boolean expired) { " rule R when\n" + " $listEvent: Collection(size >= 2) from collect (DummyEvent())" + " then \n" + - " System.out.println(\"R is fired\"); \n" + + " System.out.println(\"R is fired\"); \n" + " end\n"; final KieSessionConfiguration sessionConfig = KieServices.get().newKieSessionConfiguration(); sessionConfig.setOption(ClockTypeOption.get(ClockType.PSEUDO_CLOCK.getId())); - KieBaseTestConfiguration equalityConfig = TestParametersUtil.getEqualityInstanceOf(kieBaseTestConfiguration); + KieBaseTestConfiguration equalityConfig = TestParametersUtil2.getEqualityInstanceOf(kieBaseTestConfiguration); KieBase kieBase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", equalityConfig, drl); final KieSession kieSession = kieBase.newKieSession(sessionConfig, null); @@ -789,7 +795,7 @@ private void testCollectExpiredEvent(boolean expired) { long timestamp = currentTime; if (expired) { - timestamp = currentTime - Duration.ofDays(8).toMillis(); //8 days in the past... + timestamp = currentTime - Duration.ofDays(8).toMillis(); //8 days in the past... } final DummyEvent event2 = new DummyEvent(2, timestamp); @@ -800,39 +806,45 @@ private void testCollectExpiredEvent(boolean expired) { assertThat(kieSession.fireAllRules()).isEqualTo(1); } - @Test - public void testSameConstraintAllExpired() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSameConstraintAllExpired(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-4656 - testMultipleExpiredEvent(2, false); + testMultipleExpiredEvent(kieBaseTestConfiguration, 2, false); } - @Test - public void testSameConstraintOneExpired() { - testMultipleExpiredEvent(1, false); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSameConstraintOneExpired(KieBaseTestConfiguration kieBaseTestConfiguration) { + testMultipleExpiredEvent(kieBaseTestConfiguration, 1, false); } - @Test - public void testSameConstraintNoExpiration() { - testMultipleExpiredEvent(0, false); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSameConstraintNoExpiration(KieBaseTestConfiguration kieBaseTestConfiguration) { + testMultipleExpiredEvent(kieBaseTestConfiguration, 0, false); } - @Test - public void testDifferentConstraintAllExpired() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDifferentConstraintAllExpired(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-4656 - testMultipleExpiredEvent(2, true); + testMultipleExpiredEvent(kieBaseTestConfiguration, 2, true); } - @Test - public void testDifferentConstraintOneExpired() { - testMultipleExpiredEvent(1, true); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDifferentConstraintOneExpired(KieBaseTestConfiguration kieBaseTestConfiguration) { + testMultipleExpiredEvent(kieBaseTestConfiguration, 1, true); } - @Test - public void testDifferentConstraintNoExpiration() { - testMultipleExpiredEvent(0, true); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDifferentConstraintNoExpiration(KieBaseTestConfiguration kieBaseTestConfiguration) { + testMultipleExpiredEvent(kieBaseTestConfiguration, 0, true); } - private void testMultipleExpiredEvent(int expiredNumber, boolean differentConstraint) { + private void testMultipleExpiredEvent(KieBaseTestConfiguration kieBaseTestConfiguration, int expiredNumber, boolean differentConstraint) { final String drl = " package org.drools.mvel.integrationtests;\n" + @@ -840,7 +852,7 @@ private void testMultipleExpiredEvent(int expiredNumber, boolean differentConstr " declare DummyEvent\n" + " @role( event )\n" + " @timestamp( eventTimestamp )\n" + - " @expires( 2h )\n" + + " @expires( 2h )\n" + " end\n" + " rule R1 when\n" + " $dummyEvent : DummyEvent()\n" + @@ -876,7 +888,7 @@ private void testMultipleExpiredEvent(int expiredNumber, boolean differentConstr switch (expiredNumber){ case 2: - timeStampEvent1 = currentTime - Duration.ofHours(9).toMillis(); // oldest, expired + timeStampEvent1 = currentTime - Duration.ofHours(9).toMillis(); // oldest, expired timeStampEvent2 = currentTime - Duration.ofHours(8).toMillis(); // expired break; case 1: @@ -898,29 +910,33 @@ private void testMultipleExpiredEvent(int expiredNumber, boolean differentConstr assertThat(kieSession.getObjects().size()).isEqualTo(2 - expiredNumber); } - @Test - public void testInstanceofExpired() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInstanceofExpired(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-4660 - testEvalExpiredEvent(true, false); + testEvalExpiredEvent(kieBaseTestConfiguration, true, false); } - @Test - public void testInstanceofNotExpired() { - testEvalExpiredEvent(false, false); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInstanceofNotExpired(KieBaseTestConfiguration kieBaseTestConfiguration) { + testEvalExpiredEvent(kieBaseTestConfiguration, false, false); } - @Test - public void testEvalExpired() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEvalExpired(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-4660 - testEvalExpiredEvent(true, true); + testEvalExpiredEvent(kieBaseTestConfiguration, true, true); } - @Test - public void testEvalNotExpired() { - testEvalExpiredEvent(false, true); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEvalNotExpired(KieBaseTestConfiguration kieBaseTestConfiguration) { + testEvalExpiredEvent(kieBaseTestConfiguration, false, true); } - private void testEvalExpiredEvent(boolean isExpired, boolean useEval) { + private void testEvalExpiredEvent(KieBaseTestConfiguration kieBaseTestConfiguration, boolean isExpired, boolean useEval) { final String drl = " package org.drools.mvel.integrationtests;\n" + @@ -969,7 +985,7 @@ private void testEvalExpiredEvent(boolean isExpired, boolean useEval) { //facts inserts if(isExpired){ - timestamp = currentTime - Duration.ofDays(8).toMillis(); //8 days in the past... + timestamp = currentTime - Duration.ofDays(8).toMillis(); //8 days in the past... } final DummyEvent dummyEvent = new DummyEvent(1, timestamp); @@ -982,8 +998,9 @@ private void testEvalExpiredEvent(boolean isExpired, boolean useEval) { assertThat(kieSession.getObjects().size()).isEqualTo(isExpired ? 0 : 2); } - @Test - public void testPolymorphicAlphaExpired() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPolymorphicAlphaExpired(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { // DROOLS-5050 final String drl = " package org.drools.mvel.integrationtests;\n" + @@ -1021,8 +1038,9 @@ public void testPolymorphicAlphaExpired() throws InterruptedException { assertThat(kieSession.fireAllRules()).isEqualTo(0); } - @Test - public void testAvoidAlreadyExpiredFactsToForeverRemainInWM() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAvoidAlreadyExpiredFactsToForeverRemainInWM(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-6680 String drl = " import " + DummyEvent.class.getCanonicalName() + ";\n" + @@ -1049,7 +1067,7 @@ public void testAvoidAlreadyExpiredFactsToForeverRemainInWM() { "then\n" + "end"; - KieBaseTestConfiguration equalityConfig = TestParametersUtil.getEqualityInstanceOf(kieBaseTestConfiguration); + KieBaseTestConfiguration equalityConfig = TestParametersUtil2.getEqualityInstanceOf(kieBaseTestConfiguration); KieBase kieBase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", equalityConfig, drl); final KieSessionConfiguration sessionConfig = RuleBaseFactory.newKnowledgeSessionConfiguration(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ExtendsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ExtendsTest.java index d36a355de2d..b30fe2ac189 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ExtendsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ExtendsTest.java @@ -21,9 +21,9 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.util.ArrayList; -import java.util.Collection; import java.util.LinkedList; import java.util.List; +import java.util.stream.Stream; import org.drools.core.common.DefaultEventHandle; import org.drools.core.common.InternalFactHandle; @@ -34,10 +34,9 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.Message; @@ -52,23 +51,16 @@ /** * Test for declared bean Extension */ -@RunWith(Parameterized.class) public class ExtendsTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public ExtendsTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - // TODO: EM failed with some tests. File JIRAs - return TestParametersUtil.getKieBaseCloudConfigurations(false); + public static Stream parameters() { + // TODO: EM failed with some tests. File JIRAs + return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); } - @Test - public void testExtends() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExtends(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { //Test Base Fact Type KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_Extends.drl"); KieSession ksession = kbase.newKieSession(); @@ -90,8 +82,9 @@ public void testExtends() throws Exception { } - @Test - public void testGeneratedMethods() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGeneratedMethods(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_Extends.drl"); KieSession ksession = kbase.newKieSession(); @@ -138,8 +131,9 @@ public void testGeneratedMethods() throws Exception { ksession.dispose(); } - @Test - public void testDeepExt() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeepExt(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_Extends.drl"); KieSession ksession = kbase.newKieSession(); @@ -158,16 +152,18 @@ public void testDeepExt() throws Exception { - @Test - public void testIllegalExtendsLegacy() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIllegalExtendsLegacy(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { //Test Base Fact Type KieBuilder kieBuilder = KieUtil.getKieBuilderFromClasspathResources(kieBaseTestConfiguration, getClass(), false, "test_ExtLegacyIllegal.drl"); List errors = kieBuilder.getResults().getMessages(Message.Level.ERROR); assertThat(errors.isEmpty()).as("Should have an error").isFalse(); } - @Test - public void testExtendsLegacy() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExtendsLegacy(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_ExtLegacy.drl"); KieSession ksession = kbase.newKieSession(); @@ -187,8 +183,9 @@ public void testExtendsLegacy() throws Exception { } - @Test - public void testExtendsAcrossFiles() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExtendsAcrossFiles(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_Ext1.drl", "test_Ext2.drl", "test_Ext3.drl", "test_Ext4.drl"); KieSession ksession = kbase.newKieSession(); @@ -216,8 +213,9 @@ public void testExtendsAcrossFiles() throws Exception { - @Test - public void testFieldInit() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFieldInit(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_ExtFieldInit.drl"); KieSession ksession = kbase.newKieSession(); @@ -247,8 +245,9 @@ public void testFieldInit() throws Exception { } - @Test - public void testBoxedFieldInit() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBoxedFieldInit(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_ExtFieldInit.drl"); KieSession ksession = kbase.newKieSession(); @@ -273,8 +272,9 @@ public void testBoxedFieldInit() throws Exception { } - @Test - public void testExpressionFieldInit() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExpressionFieldInit(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_ExtFieldInit.drl"); KieSession ksession = kbase.newKieSession(); FactType test = ksession.getKieBase().getFactType("org.drools.compiler","MyBoxExpressionBean"); @@ -318,8 +318,9 @@ public void testExpressionFieldInit() throws Exception { System.out.println(x); } - @Test - public void testHierarchy() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testHierarchy(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_ExtHierarchy.drl"); KieSession ksession = kbase.newKieSession(); ksession.setGlobal("list",new LinkedList()); @@ -329,8 +330,9 @@ public void testHierarchy() throws Exception { assertThat(((List) ksession.getGlobal("list")).size()).isEqualTo(1); } - @Test - public void testExtendOverride() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExtendOverride(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "package test.beans;\n" + "\n" + @@ -379,8 +381,9 @@ public void testExtendOverride() { assertThat(x instanceof ArrayList).isTrue(); } - @Test - public void testRedefineDefaults() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRedefineDefaults(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { //Test Base Fact Type KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_Extends.drl"); KieSession ksession = kbase.newKieSession(); @@ -399,8 +402,9 @@ public void testRedefineDefaults() throws Exception { ksession.dispose(); } - @Test - public void testExtendFromOtherPackage() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExtendFromOtherPackage(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String s1 = "package org.drools.mvel.compiler.test.pack1;\n" + "\n" + @@ -448,8 +452,9 @@ public void testExtendFromOtherPackage() throws Exception { assertThat(kSession.fireAllRules()).isEqualTo(3); } - @Test - public void testInheritAnnotationsInOtherPackage() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInheritAnnotationsInOtherPackage(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String s1 = "package org.drools.mvel.compiler.test.pack1;\n" + "global java.util.List list;" + @@ -527,8 +532,9 @@ public void testInheritAnnotationsInOtherPackage() throws Exception { } - @Test - public void testInheritFromClassWithDefaults() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInheritFromClassWithDefaults(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // car is a java class with attributes // brand (default ferrari) @@ -568,8 +574,9 @@ public void testInheritFromClassWithDefaults() throws Exception { } - @Test - public void testExtendSelf() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExtendSelf(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String s1 = "package org.drools;\n" + "global java.util.List list;\n" + "\n" + @@ -582,8 +589,9 @@ public void testExtendSelf() throws Exception { assertThat(errors.isEmpty()).as("Should have an error").isFalse(); } - @Test - public void testExtendCircular() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExtendCircular(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String s1 = "package org.drools;\n" + "global java.util.List list;\n" + "\n" + @@ -607,8 +615,9 @@ public void testExtendCircular() throws Exception { assertThat(errors.toString().contains("circular")).isTrue(); } - @Test - public void testExtendsDump() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExtendsDump(KieBaseTestConfiguration kieBaseTestConfiguration) { PackageDescrBuilder pkgd = DescrFactory.newPackage(); pkgd.name( "org.test" ) .newDeclare().type().name( "Foo" ) @@ -644,8 +653,9 @@ public static class X implements C { } - @Test - public void testDeclareInheritance() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclareInheritance(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String s1 = "package org.drools;\n" + "import org.drools.mvel.integrationtests.ExtendsTest.*;\n" + "\n" + @@ -673,8 +683,9 @@ public void testDeclareInheritance() throws Exception { } - @Test - public void testDeclareExtendsJavaParent() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclareExtendsJavaParent(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "package org.drools.test; \n" + "import org.drools.mvel.compiler.Person; \n" + "declare Student extends Person end \n" + @@ -685,8 +696,9 @@ public void testDeclareExtendsJavaParent() { assertThat(errors.isEmpty()).as(errors.toString()).isTrue(); } - @Test - public void testDeclareExtendsJavaParentOuterPackaga() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclareExtendsJavaParentOuterPackaga(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "package org.drools.test; \n" + "import org.drools.mvel.integrationtests.ExtendsTest.X; \n" + "declare Student extends X end \n" + @@ -697,8 +709,9 @@ public void testDeclareExtendsJavaParentOuterPackaga() { assertThat(errors.isEmpty()).as(errors.toString()).isTrue(); } - @Test - public void testDeclareExtendsMissingJavaParent() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclareExtendsMissingJavaParent(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "package org.drools.test; \n" + "import org.drools.mvel.integrationtests.ExtendsTest.Y; \n" + "declare Student extends Y end \n" + @@ -709,8 +722,9 @@ public void testDeclareExtendsMissingJavaParent() { assertThat(errors.isEmpty()).as("Should have an error").isFalse(); } - @Test - public void testDeclareExtendsWithFullyQualifiedName() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclareExtendsWithFullyQualifiedName(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "package org.drools.extends.test; \n" + "" + "declare org.drools.extends.test.Foo end \n" + @@ -723,8 +737,9 @@ public void testDeclareExtendsWithFullyQualifiedName() { } - @Test - public void testExtendsBasic() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExtendsBasic(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "extend_rule_test.drl"); KieSession session = kbase.newKieSession(); @@ -781,8 +796,9 @@ public void testExtendsBasic() throws Exception { assertThat(list.size()).isEqualTo(0); } - @Test - public void testExtendsBasic2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExtendsBasic2(KieBaseTestConfiguration kieBaseTestConfiguration) { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_RuleExtend.drl"); KieSession ksession = kbase.newKieSession(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/FailureOnRemovalTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/FailureOnRemovalTest.java index 65d29feda7c..3f2b31fe3f5 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/FailureOnRemovalTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/FailureOnRemovalTest.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.util.Collection; +import java.util.stream.Stream; import org.drools.drl.parser.DroolsParserException; import org.drools.kiesession.rulebase.InternalKnowledgeBase; @@ -27,10 +28,9 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.KieBaseConfiguration; import org.kie.api.builder.KieModule; @@ -45,7 +45,6 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class FailureOnRemovalTest { private static final String LS = System.getProperty( "line.separator" ); @@ -56,34 +55,29 @@ public class FailureOnRemovalTest { private static final boolean SHARE_BETA_NODES = true; private static final boolean NOT_SHARE_BETA_NODES = false; - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public FailureOnRemovalTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testWithBetaNodeSharing() throws Exception { - runTest( SHARE_BETA_NODES ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testWithBetaNodeSharing(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + runTest(kieBaseTestConfiguration, SHARE_BETA_NODES ); } - @Test - public void testWithoutBetaNodeSharing() throws Exception { - runTest( NOT_SHARE_BETA_NODES ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testWithoutBetaNodeSharing(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + runTest(kieBaseTestConfiguration, NOT_SHARE_BETA_NODES ); } - private void runTest(boolean shareBetaNodes) throws Exception { - InternalKnowledgeBase kbase = (InternalKnowledgeBase) createKnowledgeBase(shareBetaNodes); - Collection rule1 = compileRule( RULE_1 ); + private void runTest(KieBaseTestConfiguration kieBaseTestConfiguration, boolean shareBetaNodes) throws Exception { + InternalKnowledgeBase kbase = (InternalKnowledgeBase) createKnowledgeBase(kieBaseTestConfiguration, shareBetaNodes); + Collection rule1 = compileRule(kieBaseTestConfiguration, RULE_1 ); kbase.addPackages( rule1 ); // we need to add at least two rules. Test will not fail with only one rule. - Collection rule2 = compileRule( RULE_2 ); + Collection rule2 = compileRule(kieBaseTestConfiguration, RULE_2 ); kbase.addPackages( rule2 ); kbase.removeRule( PACKAGE, @@ -95,11 +89,11 @@ private void runTest(boolean shareBetaNodes) throws Exception { assertThat(fired).isEqualTo(1); - Collection rule3 = compileRule( RULE_3 ); + Collection rule3 = compileRule(kieBaseTestConfiguration, RULE_3 ); kbase.addPackages( rule3 ); } - private Collection compileRule(String name) throws DroolsParserException, + private Collection compileRule(KieBaseTestConfiguration kieBaseTestConfiguration, String name) throws DroolsParserException, IOException { String drl = getDrl( name ); System.out.println(drl); @@ -112,7 +106,7 @@ private KnowledgeBuilderConfiguration createKnowledgeBuilderConfiguration() { return kconf; } - private KieBase createKnowledgeBase(boolean shareBetaNodes) { + private KieBase createKnowledgeBase(KieBaseTestConfiguration kieBaseTestConfiguration, boolean shareBetaNodes) { KieBaseConfiguration ruleBaseConfiguration = createKnowledgeBaseConfiguration( shareBetaNodes ); final KieModule kieModule = KieUtil.getKieModuleFromResources("test", kieBaseTestConfiguration); return KieBaseUtil.newKieBaseFromReleaseId(kieModule.getReleaseId(), ruleBaseConfiguration); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/FireAllRulesCommandTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/FireAllRulesCommandTest.java index d47c637d53e..ad57b957247 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/FireAllRulesCommandTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/FireAllRulesCommandTest.java @@ -19,17 +19,16 @@ package org.drools.mvel.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.commands.runtime.rule.FireAllRulesCommand; import org.drools.mvel.compiler.Cheese; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.command.Command; import org.kie.api.runtime.ExecutionResults; @@ -38,21 +37,15 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class FireAllRulesCommandTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public FireAllRulesCommandTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); - } - @Test - public void oneRuleFiredTest() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void oneRuleFiredTest(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = ""; str += "package org.drools.mvel.integrationtests \n"; str += "import " + Cheese.class.getCanonicalName() + " \n"; @@ -63,7 +56,7 @@ public void oneRuleFiredTest() { str += " System.out.println($c); \n"; str += "end \n"; - StatelessKieSession ksession = getSession(str); + StatelessKieSession ksession = getSession(kieBaseTestConfiguration, str); List> commands = new ArrayList>(); commands.add(CommandFactory.newInsert(new Cheese("stilton"))); @@ -75,8 +68,9 @@ public void oneRuleFiredTest() { assertThat(fired).isEqualTo(1); } - @Test - public void fiveRulesFiredTest() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void fiveRulesFiredTest(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = ""; str += "package org.drools.mvel.integrationtests \n"; str += "import " + Cheese.class.getCanonicalName() + " \n"; @@ -87,7 +81,7 @@ public void fiveRulesFiredTest() { str += " System.out.println($c); \n"; str += "end \n"; - StatelessKieSession ksession = getSession(str); + StatelessKieSession ksession = getSession(kieBaseTestConfiguration, str); List> commands = new ArrayList>(); commands.add(CommandFactory.newInsert(new Cheese("stilton"))); @@ -103,8 +97,9 @@ public void fiveRulesFiredTest() { assertThat(fired).isEqualTo(5); } - @Test - public void zeroRulesFiredTest() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void zeroRulesFiredTest(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = ""; str += "package org.drools.mvel.integrationtests \n"; str += "import " + Cheese.class.getCanonicalName() + " \n"; @@ -115,7 +110,7 @@ public void zeroRulesFiredTest() { str += " System.out.println($c); \n"; str += "end \n"; - StatelessKieSession ksession = getSession(str); + StatelessKieSession ksession = getSession(kieBaseTestConfiguration, str); List> commands = new ArrayList>(); commands.add(CommandFactory.newInsert("not cheese")); @@ -127,8 +122,9 @@ public void zeroRulesFiredTest() { assertThat(fired).isEqualTo(0); } - @Test - public void oneRuleFiredWithDefinedMaxTest() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void oneRuleFiredWithDefinedMaxTest(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = ""; str += "package org.drools.mvel.integrationtests \n"; str += "import " + Cheese.class.getCanonicalName() + " \n"; @@ -139,7 +135,7 @@ public void oneRuleFiredWithDefinedMaxTest() { str += " System.out.println($c); \n"; str += "end \n"; - StatelessKieSession ksession = getSession(str); + StatelessKieSession ksession = getSession(kieBaseTestConfiguration, str); List> commands = new ArrayList>(); commands.add(CommandFactory.newInsert(new Cheese("stilton"))); @@ -153,8 +149,9 @@ public void oneRuleFiredWithDefinedMaxTest() { assertThat(fired).isEqualTo(1); } - @Test - public void infiniteLoopTerminatesAtMaxTest() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void infiniteLoopTerminatesAtMaxTest(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = ""; str += "package org.drools.mvel.integrationtests \n"; str += "import " + Cheese.class.getCanonicalName() + " \n"; @@ -165,7 +162,7 @@ public void infiniteLoopTerminatesAtMaxTest() { str += " update($c); \n"; str += "end \n"; - StatelessKieSession ksession = getSession(str); + StatelessKieSession ksession = getSession(kieBaseTestConfiguration, str); List> commands = new ArrayList>(); commands.add(CommandFactory.newInsert(new Cheese("stilton"))); @@ -179,7 +176,7 @@ public void infiniteLoopTerminatesAtMaxTest() { assertThat(fired).isEqualTo(10); } - private StatelessKieSession getSession(String drl) { + private StatelessKieSession getSession(KieBaseTestConfiguration kieBaseTestConfiguration, String drl) { KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, drl); return kbase.newStatelessKieSession(); } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/FireUntilHaltAccumulateTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/FireUntilHaltAccumulateTest.java index b6eb6579f48..899b125ed49 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/FireUntilHaltAccumulateTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/FireUntilHaltAccumulateTest.java @@ -18,22 +18,20 @@ */ package org.drools.mvel.integrationtests; -import java.util.Collection; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; import org.drools.core.ClockType; import org.drools.core.impl.RuleBaseFactory; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.definition.type.FactType; import org.kie.api.runtime.KieSession; @@ -47,18 +45,10 @@ * fed into the engine by thread A while the engine had been started by * fireUntilHalt by thread B. */ -@RunWith(Parameterized.class) public class FireUntilHaltAccumulateTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public FireUntilHaltAccumulateTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseStreamConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } private KieSession statefulSession; @@ -84,8 +74,7 @@ public static Collection getParameters() { "then\n" + "end"; - @Before - public void setUp() { + public void setUp(KieBaseTestConfiguration kieBaseTestConfiguration) { KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, drl); final KieSessionConfiguration sessionConfig = @@ -96,7 +85,7 @@ public void setUp() { this.stockFactory = new StockFactory(kbase); } - @After + @AfterEach public void cleanUp() { if (this.statefulSession != null) { this.statefulSession.dispose(); @@ -109,9 +98,12 @@ public void cleanUp() { *

* The engine runs in fireUntilHalt mode started in a separate thread. * Events may expire during the evaluation of accumulate. + * @param kieBaseTestConfiguration */ - @Test - public void testFireUntilHaltWithAccumulateAndExpires() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFireUntilHaltWithAccumulateAndExpires(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + setUp(kieBaseTestConfiguration); // thread for firing until halt final ExecutorService executor = Executors.newSingleThreadExecutor(); final Future sessionFuture = executor.submit((Runnable) statefulSession::fireUntilHalt); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/FireUntilHaltTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/FireUntilHaltTest.java index 44266921339..8364c2b82f9 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/FireUntilHaltTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/FireUntilHaltTest.java @@ -19,20 +19,19 @@ package org.drools.mvel.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; import org.drools.mvel.compiler.Cheese; import org.drools.mvel.compiler.Person; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.rule.EntryPoint; @@ -40,22 +39,15 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class FireUntilHaltTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public FireUntilHaltTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testSubmitOnFireUntilHalt() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSubmitOnFireUntilHalt(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { final String drl = "import " + Person.class.getCanonicalName() + "\n" + "global java.util.List list;" + @@ -100,8 +92,9 @@ public void testSubmitOnFireUntilHalt() throws InterruptedException { kSession.dispose(); } - @Test - public void testFireAllWhenFiringUntilHalt() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFireAllWhenFiringUntilHalt(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration); // empty KieSession ksession = kbase.newKieSession(); @@ -126,8 +119,9 @@ public void testFireAllWhenFiringUntilHalt() throws InterruptedException { assertThat(aliveT1).as("T1 should have finished").isFalse(); } - @Test - public void testFireUntilHaltFailingAcrossEntryPoints() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFireUntilHaltFailingAcrossEntryPoints(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String rule1 = "package org.drools.mvel.compiler\n"; rule1 += "global java.util.List list\n"; rule1 += "rule testFireUntilHalt\n"; @@ -165,8 +159,9 @@ public void testFireUntilHaltFailingAcrossEntryPoints() throws Exception { assertThat(list.size()).isEqualTo(1); } - @Test - public void testAllFactsProcessedBeforeHalt() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAllFactsProcessedBeforeHalt(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drl = "package org.example.drools;\n" + "\n" + "global java.util.concurrent.CountDownLatch latch;\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/FirstOrderLogicTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/FirstOrderLogicTest.java index 949113a5d2f..db46de02ad1 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/FirstOrderLogicTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/FirstOrderLogicTest.java @@ -22,6 +22,7 @@ import java.util.Collection; import java.util.List; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; import org.drools.core.ClockType; import org.drools.kiesession.audit.WorkingMemoryConsoleLogger; @@ -45,9 +46,9 @@ import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieUtil; import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.builder.KieModule; import org.kie.api.conf.RemoveIdentitiesOption; @@ -57,7 +58,6 @@ import org.kie.api.runtime.KieSessionConfiguration; import org.kie.api.runtime.conf.ClockTypeOption; import org.kie.api.runtime.rule.FactHandle; -import org.kie.api.time.SessionClock; import org.kie.api.time.SessionPseudoClock; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -68,25 +68,18 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -@RunWith(Parameterized.class) public class FirstOrderLogicTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public FirstOrderLogicTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - // TODO: EM failed with some tests. File JIRAs - return TestParametersUtil.getKieBaseCloudConfigurations(false); + public static Stream parameters() { + // TODO: EM failed with some tests. File JIRAs + return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); } private static Logger logger = LoggerFactory.getLogger(FirstOrderLogicTest.class); - @Test - public void testCollect() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCollect(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { List results = new ArrayList(); KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_Collect.drl"); @@ -127,8 +120,9 @@ public void testCollect() throws Exception { assertThat(results.get(0).getClass().getName()).isEqualTo(ArrayList.class.getName()); } - @Test - public void testCollectNodeSharing() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCollectNodeSharing(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_collectNodeSharing.drl"); KieSession wm = kbase.newKieSession(); @@ -157,8 +151,9 @@ public void testCollectNodeSharing() throws Exception { assertThat(((List) results.get(0)).size()).isEqualTo(2); } - @Test - public void testCollectModify() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCollectModify(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_Collect.drl"); KieSession wm = kbase.newKieSession(); @@ -218,8 +213,9 @@ public void testCollectModify() throws Exception { assertThat(results.size()).isEqualTo(fireCount); } - @Test - public void testCollectResultConstraints() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCollectResultConstraints(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_CollectResultConstraints.drl"); KieSession wm = kbase.newKieSession(); List results = new ArrayList(); @@ -252,8 +248,9 @@ public void testCollectResultConstraints() throws Exception { assertThat(results.get(0).getClass().getName()).isEqualTo(ArrayList.class.getName()); } - @Test - public void testExistsWithBinding() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExistsWithBinding(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_ExistsWithBindings.drl"); KieSession wm = kbase.newKieSession(); @@ -273,8 +270,9 @@ public void testExistsWithBinding() throws Exception { assertThat(list.size()).isEqualTo(1); } - @Test - public void testNot() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNot(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "not_rule_test.drl"); KieSession wm = kbase.newKieSession(); @@ -302,8 +300,9 @@ public void testNot() throws Exception { assertThat(list.contains(new Integer( 8 ))).isTrue(); } - @Test - public void testNotWithBindings() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNotWithBindings(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "not_with_bindings_rule_test.drl"); KieSession wm = kbase.newKieSession(); @@ -333,8 +332,9 @@ public void testNotWithBindings() throws Exception { assertThat(list.size()).isEqualTo(1); } - @Test - public void testExists() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExists(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "exists_rule_test.drl"); KieSession wm = kbase.newKieSession(); @@ -363,8 +363,9 @@ public void testExists() throws Exception { assertThat(list.size()).isEqualTo(1); } - @Test - public void testExists2() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExists2(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_exists.drl"); KieSession workingMemory = kbase.newKieSession(); @@ -398,8 +399,9 @@ public void testExists2() throws Exception { assertThat(list.size()).isEqualTo(1); } - @Test - public void testExists3() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExists3(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_Exists_JBRULES_2810.drl"); KieSession ksession = kbase.newKieSession(); @@ -408,8 +410,9 @@ public void testExists3() throws Exception { ksession.dispose(); } - @Test - public void testForall() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testForall(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_Forall.drl"); KieSession workingMemory = kbase.newKieSession(); @@ -436,8 +439,9 @@ public void testForall() throws Exception { assertThat(list.size()).isEqualTo(1); } - @Test - public void testForall2() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testForall2(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_Forall2.drl"); KieSession ksession = kbase.newKieSession(); @@ -469,8 +473,9 @@ public void testForall2() throws Exception { assertThat(list.size()).isEqualTo(1); } - @Test - public void testRemoveIdentitiesSubNetwork() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemoveIdentitiesSubNetwork(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieModule kieModule = KieUtil.getKieModuleFromClasspathResources("test", getClass(), kieBaseTestConfiguration, "test_removeIdentitiesSubNetwork.drl"); KieBase kbase = KieBaseUtil.newKieBaseFromKieModuleWithAdditionalOptions(kieModule, kieBaseTestConfiguration, RemoveIdentitiesOption.YES); KieSession workingMemory = kbase.newKieSession(); @@ -510,8 +515,9 @@ public void testRemoveIdentitiesSubNetwork() throws Exception { assertThat(list.get(1)).isEqualTo(bob); } - @Test - public void testCollectWithNestedFromWithParams() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCollectWithNestedFromWithParams(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_CollectWithNestedFrom.drl"); KieSession workingMemory = kbase.newKieSession(); @@ -547,8 +553,9 @@ public void testCollectWithNestedFromWithParams() throws Exception { } - @Test - public void testCollectModifyAlphaRestriction() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCollectModifyAlphaRestriction(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_CollectAlphaRestriction.drl"); KieSession wm = kbase.newKieSession(); @@ -595,8 +602,9 @@ public void testCollectModifyAlphaRestriction() throws Exception { } - @Test - public void testForallSinglePattern() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testForallSinglePattern(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_ForallSinglePattern.drl"); KieSession workingMemory = kbase.newKieSession(); @@ -644,8 +652,9 @@ public void testForallSinglePattern() throws Exception { } - @Test - public void testForallSinglePattern2() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testForallSinglePattern2(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_ForallSinglePattern2.drl"); KieSession ksession = kbase.newKieSession(); @@ -663,8 +672,9 @@ public void testForallSinglePattern2() throws Exception { ksession.dispose(); } - @Test - public void testMVELCollect() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMVELCollect(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_MVELCollect.drl"); KieSession wm = kbase.newKieSession(); @@ -696,8 +706,9 @@ public void testMVELCollect() throws Exception { assertThat(((List) results.get(0)).size()).isEqualTo(6); } - @Test - public void testNestedCorelatedRulesWithForall() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNestedCorelatedRulesWithForall(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_NestedCorrelatedRulesWithForall.drl"); KieSession session = kbase.newKieSession(); @@ -752,8 +763,9 @@ public void testNestedCorelatedRulesWithForall() throws Exception { assertThat(list4.size()).isEqualTo(0); } - @Test - public void testFromInsideNotAndExists() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFromInsideNotAndExists(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_FromInsideNotAndExists.drl"); KieSession workingMemory = kbase.newKieSession(); @@ -784,8 +796,9 @@ public void testFromInsideNotAndExists() throws Exception { } - @Test - public void testOr() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOr(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_OrNesting.drl"); KieSession workingMemory = kbase.newKieSession(); @@ -812,8 +825,9 @@ public void testOr() throws Exception { } // JBRULES-2482 - @Test - public void testOrWithVariableResolution() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOrWithVariableResolution(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_OrCEFollowedByMultipleEval.drl"); KieSession ksession = kbase.newKieSession(); @@ -830,8 +844,9 @@ public void testOrWithVariableResolution() throws Exception { } // JBRULES-2526 - @Test - public void testOrWithVariableResolution2() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOrWithVariableResolution2(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_OrCEFollowedByMultipleEval2.drl"); KieSession ksession = kbase.newKieSession(); @@ -847,8 +862,9 @@ public void testOrWithVariableResolution2() throws Exception { times( 8 ) ).afterMatchFired(any(AfterMatchFiredEvent.class)); } - @Test - public void testCollectWithMemberOfOperators() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCollectWithMemberOfOperators(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_CollectMemberOfOperator.drl"); KieSession workingMemory = kbase.newKieSession(); @@ -891,8 +907,9 @@ public void testCollectWithMemberOfOperators() throws Exception { } - @Test - public void testCollectWithContainsOperators() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCollectWithContainsOperators(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_CollectContainsOperator.drl"); KieSession workingMemory = kbase.newKieSession(); @@ -935,8 +952,9 @@ public void testCollectWithContainsOperators() throws Exception { } - @Test - public void testForallSinglePatternWithExists() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testForallSinglePatternWithExists(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_ForallSinglePatternWithExists.drl"); KieSession workingMemory = kbase.newKieSession(); @@ -964,8 +982,9 @@ public void testForallSinglePatternWithExists() throws Exception { } - @Test - public void testCollectResultBetaConstraint() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCollectResultBetaConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_CollectResultsBetaConstraint.drl"); KieSession wm = kbase.newKieSession(); @@ -990,8 +1009,9 @@ public void testCollectResultBetaConstraint() throws Exception { assertThat(results.get(1)).isEqualTo("accumulate"); } - @Test - public void testFromWithOr() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFromWithOr(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_FromWithOr.drl"); KieSession session = kbase.newKieSession(); @@ -1020,8 +1040,9 @@ public void testFromWithOr() throws Exception { } - @Test - public void testForallWithSlidingWindow() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testForallWithSlidingWindow(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final KieSessionConfiguration conf = RuleBaseFactory.newKnowledgeSessionConfiguration(); conf.setOption( ClockTypeOption.get( ClockType.PSEUDO_CLOCK.getId() ) ); @@ -1107,8 +1128,9 @@ public void testForallWithSlidingWindow() throws Exception { } - @Test - public void testCollectFromMVELAfterOr() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCollectFromMVELAfterOr(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_CollectFromMVELAfterOr.drl"); KieSession wm = kbase.newKieSession(); @@ -1138,8 +1160,9 @@ public void testCollectFromMVELAfterOr() throws Exception { assertThat(((Collection) results.get(0)).size()).isEqualTo(3); } - @Test - public void testCollectAfterOrCE() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCollectAfterOrCE(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_OrCEFollowedByCollect.drl"); KieSession session = kbase.newKieSession(); @@ -1154,8 +1177,9 @@ public void testCollectAfterOrCE() throws Exception { assertThat(rules).isEqualTo(2); } - @Test - public void testLotsOfOrs() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLotsOfOrs(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // Decomposed this test down to just two rules, while still exhibiting the problem // Uncomment rest of rule as those are fixed, to complicate it again. String str = "package org.drools.mvel.compiler.test\n" + @@ -1222,8 +1246,9 @@ public void testLotsOfOrs() throws Exception { ksession.dispose(); } - @Test - public void testOrs() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOrs(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "package org.drools.mvel.integrationtests\n" + "import " + Message.class.getName() + "\n" + "rule X\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/FunctionsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/FunctionsTest.java index 0c805357790..b8c1911a47e 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/FunctionsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/FunctionsTest.java @@ -19,19 +19,18 @@ package org.drools.mvel.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Stream; import org.drools.mvel.compiler.Cheese; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.io.Resource; import org.kie.api.runtime.KieSession; @@ -39,23 +38,16 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -@RunWith(Parameterized.class) public class FunctionsTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public FunctionsTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } @SuppressWarnings("unchecked") - @Test - public void testFunction() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFunction(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "test_FunctionInConsequence.drl"); KieSession ksession = kbase.newKieSession(); @@ -72,8 +64,9 @@ public void testFunction() throws Exception { assertThat(((List) ksession.getGlobal("list")).get(0)).isEqualTo(new Integer( 5 )); } - @Test - public void testFunctionException() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFunctionException(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "test_FunctionException.drl"); KieSession ksession = kbase.newKieSession(); @@ -89,8 +82,9 @@ public void testFunctionException() throws Exception { } } - @Test - public void testFunctionWithPrimitives() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFunctionWithPrimitives(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "test_FunctionWithPrimitives.drl"); KieSession ksession = kbase.newKieSession(); @@ -107,8 +101,9 @@ public void testFunctionWithPrimitives() throws Exception { assertThat(list.get(0)).isEqualTo(new Integer( 10 )); } - @Test - public void testFunctionCallingFunctionWithEclipse() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFunctionCallingFunctionWithEclipse(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { Resource[] resources = KieUtil.createResources("test_functionCallingFunction.drl", this.getClass()); Map kieModuleConfigurationProperties = new HashMap<>(); kieModuleConfigurationProperties.put("drools.dialect.java.compiler", "ECLIPSE"); @@ -128,8 +123,9 @@ public void testFunctionCallingFunctionWithEclipse() throws Exception { assertThat(list.get(0).intValue()).isEqualTo(12); } - @Test - public void testJBRULES3117() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJBRULES3117(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package org.kie\n" + "function boolean isOutOfRange( Object value, int lower ) { return true; }\n" + "function boolean isNotContainedInt( Object value, int[] values ) { return true; }\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/GeneratedBeansTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/GeneratedBeansTest.java index 9bd892d00e6..772eae99be4 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/GeneratedBeansTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/GeneratedBeansTest.java @@ -20,38 +20,30 @@ import java.io.Serializable; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.definition.type.FactType; import org.kie.api.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class GeneratedBeansTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public GeneratedBeansTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testGeneratedBeans1() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGeneratedBeans1(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "test_GeneratedBeans.drl"); final FactType cheeseFact = kbase.getFactType("org.drools.generatedbeans", "Cheese"); @@ -92,8 +84,9 @@ public void testGeneratedBeans1() throws Exception { assertThat(result.get(1)).isEqualTo(person); } - @Test - public void testGeneratedBeans2() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGeneratedBeans2(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "test_GeneratedBeans2.drl"); final FactType cheeseFact = kbase.getFactType("org.drools.generatedbeans", "Cheese"); final Object cheese = cheeseFact.newInstance(); @@ -141,8 +134,9 @@ public void testGeneratedBeans2() throws Exception { assertThat(result.get(1)).isEqualTo(person); } - @Test - public void testGeneratedBeansSerializable() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGeneratedBeansSerializable(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "test_GeneratedBeansSerializable.drl"); final FactType cheeseFact = kbase.getFactType("org.drools.generatedbeans", "Cheese"); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/GenericsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/GenericsTest.java index cb5a94aa2cf..ca97f87dac0 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/GenericsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/GenericsTest.java @@ -18,16 +18,15 @@ */ package org.drools.mvel.integrationtests; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.mvel.integrationtests.facts.vehicles.DieselCar; import org.drools.mvel.integrationtests.facts.vehicles.ElectricCar; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; @@ -37,22 +36,15 @@ * This is a place where known behavior differences between exec-model and non-exec-model. * They are not treated as a bug and should be documented in "Migration from non-executable model to executable model" section */ -@RunWith(Parameterized.class) public class GenericsTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public GenericsTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void property_subClassMethod_genericsReturnType() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void property_subClassMethod_genericsReturnType(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-7197 String str = "package com.example.reproducer\n" + "import " + DieselCar.class.getCanonicalName() + ";\n" + @@ -75,8 +67,9 @@ public void property_subClassMethod_genericsReturnType() { assertThat(dieselCar.getScore()).isEqualTo(5); } - @Test - public void property_subClassMethod_explicitReturnType() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void property_subClassMethod_explicitReturnType(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-7197 String str = "package com.example.reproducer\n" + "import " + ElectricCar.class.getCanonicalName() + ";\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/I18nTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/I18nTest.java index 6f0702fe738..9d5283b27d1 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/I18nTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/I18nTest.java @@ -19,19 +19,18 @@ package org.drools.mvel.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.mvel.compiler.I18nPerson; import org.drools.mvel.compiler.Person; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; @@ -49,22 +48,16 @@ /** * Tests DRL's with foreign characters. */ -@RunWith(Parameterized.class) public class I18nTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public I18nTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test @Ignore("Fails because of JBRULES-3435. But the JBRULES-2853 part works fine. Support for i18n properties must be fixed in mvel") - public void readDrlInEncodingUtf8() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Disabled("Fails because of JBRULES-3435. But the JBRULES-2853 part works fine. Support for i18n properties must be fixed in mvel") + public void readDrlInEncodingUtf8(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final Resource drlResource = ResourceFactory.newClassPathResource( "test_I18nPerson_utf8.drl", "UTF-8", getClass()); drlResource.setResourceType(ResourceType.DRL); final KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromResources("i18n-test", kieBaseTestConfiguration, drlResource); @@ -90,8 +83,9 @@ public void readDrlInEncodingUtf8() throws Exception { ksession.dispose(); } - @Test - public void readDrlInEncodingLatin1() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void readDrlInEncodingLatin1(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final Resource drlResource = ResourceFactory.newClassPathResource( "test_I18nPerson_latin1.drl.latin1", "ISO-8859-1", getClass()); drlResource.setResourceType(ResourceType.DRL); final KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromResources("i18n-test", kieBaseTestConfiguration, drlResource); @@ -112,8 +106,9 @@ public void readDrlInEncodingLatin1() throws Exception { ksession.dispose(); } - @Test - public void testIdeographicSpaceInDSL() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIdeographicSpaceInDSL(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // JBRULES-3723 String dsl = "// Testing 'IDEOGRAPHIC SPACE' (U+3000)\n" + @@ -161,8 +156,9 @@ public void testIdeographicSpaceInDSL() throws Exception { ksession.dispose(); } - @Test - public void testNewClassPathResource() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNewClassPathResource(KieBaseTestConfiguration kieBaseTestConfiguration) { final Resource drl = ResourceFactory.newClassPathResource( "test_I18nPerson_utf8_forTestNewClassPathResource.drl", getClass()); final KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromResources("i18n-test", kieBaseTestConfiguration, drl); final KieSession ksession = kbase.newKieSession(); @@ -180,8 +176,9 @@ public void testNewClassPathResource() { ksession.dispose(); } - @Test - public void testKieFileSystem() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKieFileSystem(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package org.drools.mvel.compiler.i18ntest;\n" + "import org.drools.mvel.compiler.I18nPerson;\n" + "\n" + @@ -215,8 +212,9 @@ public void testKieFileSystem() { ksession.dispose(); } - @Test - public void testKieModuleJar() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKieModuleJar(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package org.drools.mvel.compiler.i18ntest;\n" + "import org.drools.mvel.compiler.I18nPerson;\n" + "\n" + @@ -247,8 +245,9 @@ public void testKieModuleJar() { ksession.dispose(); } - @Test - public void testMultibytePositonalQueryParam() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMultibytePositonalQueryParam(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1619 String drl = "package org.drools.mvel.compiler.i18ntest;\n" + "import org.drools.mvel.compiler.Person;\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/IntegrationInterfacesTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/IntegrationInterfacesTest.java index dbaa6a7127d..cf2b136ab92 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/IntegrationInterfacesTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/IntegrationInterfacesTest.java @@ -20,16 +20,15 @@ import java.io.IOException; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.mvel.compiler.Cheese; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.Channel; import org.kie.api.runtime.KieSession; @@ -41,28 +40,21 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -@RunWith(Parameterized.class) public class IntegrationInterfacesTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public IntegrationInterfacesTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - private KieBase getKnowledgeBase(final String resourceName) { + private KieBase getKnowledgeBase(KieBaseTestConfiguration kieBaseTestConfiguration, final String resourceName) { return KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, resourceName); } @SuppressWarnings("unchecked") - @Test - public void testGlobals() throws Exception { - final KieBase kbase = getKnowledgeBase( "globals_rule_test.drl" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGlobals(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + final KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, "globals_rule_test.drl" ); KieSession ksession = kbase.newKieSession(); final List list = mock( List.class ); @@ -84,9 +76,10 @@ public void testGlobals() throws Exception { } @SuppressWarnings("unchecked") - @Test - public void testGlobals2() throws Exception { - final KieBase kbase = getKnowledgeBase( "test_globalsAsConstraints.drl" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGlobals2(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + final KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, "test_globalsAsConstraints.drl" ); KieSession ksession = kbase.newKieSession(); final List results = mock( List.class ); @@ -121,8 +114,9 @@ public void testGlobals2() throws Exception { times( 1 ) ).add( "not memberOf" ); } - @Test - public void testGlobalMerge() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGlobalMerge(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // from JBRULES-1512 String rule1 = "package com.sample\n" + "rule \"rule 1\"\n" + @@ -153,9 +147,10 @@ public void testGlobalMerge() throws Exception { assertThat(list.get(1)).isEqualTo("rule 2 executed boo"); } - @Test - public void testChannels() throws IOException, ClassNotFoundException { - KieBase kbase = getKnowledgeBase( "test_Channels.drl" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testChannels(KieBaseTestConfiguration kieBaseTestConfiguration) throws IOException, ClassNotFoundException { + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, "test_Channels.drl" ); KieSession ksession = kbase.newKieSession(); Channel someChannel = mock( Channel.class ); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/JBRULESTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/JBRULESTest.java index 3959dbc867e..ef27b7d4994 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/JBRULESTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/JBRULESTest.java @@ -20,11 +20,11 @@ import java.io.ByteArrayOutputStream; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.jar.JarEntry; import java.util.jar.JarInputStream; +import java.util.stream.Stream; import org.drools.base.rule.MapBackedClassLoader; import org.drools.mvel.compiler.Bar; @@ -38,10 +38,9 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.Message.Level; @@ -62,22 +61,15 @@ import static org.mockito.Mockito.verify; -@RunWith(Parameterized.class) public class JBRULESTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public JBRULESTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testJBRules2055() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJBRules2055(KieBaseTestConfiguration kieBaseTestConfiguration) { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "test_JBRules2055.drl"); KieSession ksession = kbase.newKieSession(); final List results = new ArrayList(); @@ -93,8 +85,9 @@ public void testJBRules2055() { } - @Test - public void testJBRules2369() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJBRules2369(KieBaseTestConfiguration kieBaseTestConfiguration) { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "test_JBRules2369.drl"); KieSession ksession = kbase.newKieSession(); final List results = new ArrayList(); @@ -116,8 +109,9 @@ public void testJBRules2369() { assertThat(results.size()).isEqualTo(2); } - @Test - public void testJBRules2140() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJBRules2140(KieBaseTestConfiguration kieBaseTestConfiguration) { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "test_JBRules2140.drl"); KieSession ksession = kbase.newKieSession(); final List results = new ArrayList(); @@ -128,8 +122,9 @@ public void testJBRules2140() { assertThat(results.contains("mvel")).isTrue(); } - @Test - public void testJBRULES_2995() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJBRULES_2995(KieBaseTestConfiguration kieBaseTestConfiguration) { final String str = "package org.drools.mvel.compiler\n" + "rule r1\n" + "when\n" + @@ -148,8 +143,9 @@ public void testJBRULES_2995() { assertThat(rules).isEqualTo(1); } - @Test - public void testJBRULES2872() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJBRULES2872(KieBaseTestConfiguration kieBaseTestConfiguration) { final String str = "package org.drools.mvel.compiler.test\n" + "import org.drools.mvel.compiler.FactA\n" + "rule X\n" + @@ -165,8 +161,9 @@ public void testJBRULES2872() { assertThat(error.getLine()).isEqualTo(5); } - @Test - public void testJBRULES3030() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJBRULES3030(KieBaseTestConfiguration kieBaseTestConfiguration) { final String str = "package org.drools.mvel.compiler\n" + "rule X\n" + "when\n" + @@ -180,8 +177,9 @@ public void testJBRULES3030() { assertThat(!errors.isEmpty()).isFalse(); } - @Test - public void testJBRULES3111() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJBRULES3111(KieBaseTestConfiguration kieBaseTestConfiguration) { final String str = "package org.drools.compiler\n" + "declare Bool123\n" + " bool1 : boolean\n" + @@ -237,8 +235,9 @@ public void testJBRULES3111() { assertThat(name).isEqualTo("one"); } - @Test - public void testJBRULES3323() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJBRULES3323(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { //adding rules. it is important to add both since they reciprocate final StringBuilder rule = new StringBuilder(); @@ -293,8 +292,9 @@ public void testJBRULES3323() throws Exception { ksession.dispose(); } - @Test - public void testJBRULES3326() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJBRULES3326(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { final StringBuilder rule = new StringBuilder(); rule.append("package org.drools.mvel.compiler\n"); rule.append("rule X\n"); @@ -312,8 +312,9 @@ public void testJBRULES3326() throws Exception { ksession.dispose(); } - @Test - public void testGUVNOR578_2() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGUVNOR578_2(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // An internal specific test case so not enhanced for executable-model final MapBackedClassLoader loader = new MapBackedClassLoader( this.getClass().getClassLoader() ); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/JittingTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/JittingTest.java index f9d50b4f6c2..50e2e1bf55a 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/JittingTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/JittingTest.java @@ -19,9 +19,9 @@ package org.drools.mvel.integrationtests; import java.math.BigDecimal; -import java.util.Collection; import java.util.HashMap; import java.util.Map; +import java.util.stream.Stream; import org.drools.mvel.compiler.Person; import org.drools.mvel.integrationtests.facts.AnEnum; @@ -29,10 +29,9 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.builder.KieModule; import org.kie.api.runtime.KieSession; @@ -40,24 +39,17 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class JittingTest { // This test is basically written for Mvel Jitting. But it has good edge cases which are useful for testing even with exec-model. - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public JittingTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testJitConstraintInvokingConstructor() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJitConstraintInvokingConstructor(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3628 final String str = "import org.drools.mvel.compiler.Person;\n" + "rule R1 when\n" + @@ -74,8 +66,9 @@ public void testJitConstraintInvokingConstructor() { ksession.dispose(); } - @Test - public void testJittingConstraintWithInvocationOnLiteral() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJittingConstraintWithInvocationOnLiteral(KieBaseTestConfiguration kieBaseTestConfiguration) { final String str = "package com.sample\n" + "import org.drools.mvel.compiler.Person\n" + "rule XXX when\n" + @@ -83,11 +76,12 @@ public void testJittingConstraintWithInvocationOnLiteral() { "then\n" + "end\n"; - testJitting(str); + testJitting(kieBaseTestConfiguration, str); } - @Test - public void testJittingMethodWithCharSequenceArg() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJittingMethodWithCharSequenceArg(KieBaseTestConfiguration kieBaseTestConfiguration) { final String str = "package com.sample\n" + "import org.drools.mvel.compiler.Person\n" + "rule XXX when\n" + @@ -95,10 +89,10 @@ public void testJittingMethodWithCharSequenceArg() { "then\n" + "end\n"; - testJitting(str); + testJitting(kieBaseTestConfiguration, str); } - private void testJitting(final String drl) { + private void testJitting(KieBaseTestConfiguration kieBaseTestConfiguration, final String drl) { KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, drl); final KieSession ksession = kbase.newKieSession(); @@ -109,8 +103,9 @@ private void testJitting(final String drl) { ksession.dispose(); } - @Test - public void testJittingEnum() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJittingEnum(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import " + AnEnum.class.getCanonicalName() + ";\n" + " rule R1 \n" + " when \n" + @@ -126,8 +121,9 @@ public void testJittingEnum() { assertThat(kieSession.fireAllRules()).isEqualTo(1); } - @Test - public void testJittingEnumAttribute() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJittingEnumAttribute(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import " + AnEnum.class.getCanonicalName() + ";\n" + "import " + FactWithEnum.class.getCanonicalName() + ";\n" + " rule R1 \n" + @@ -144,8 +140,9 @@ public void testJittingEnumAttribute() { assertThat(kieSession.fireAllRules()).isEqualTo(1); } - @Test - public void testMvelJitDivision() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMvelJitDivision(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-2928 String drl = "import " + Person.class.getName() + ";\n" + "rule R1 when\n" @@ -167,8 +164,9 @@ public void testMvelJitDivision() { assertThat(fired).isEqualTo(1); } - @Test - public void testJitMemberOf() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJitMemberOf(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-3794 String drl = "import java.util.ArrayList;\n" + @@ -208,27 +206,28 @@ public void testJitMemberOf() { assertThat(fired).isEqualTo(2); } - @Test - public void testJitMapCoercion() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJitMapCoercion(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-4334 - checkJitMapCoercion("status < $map.get(\"key\")", true, 0); - checkJitMapCoercion("$map.get(\"key\") > status", true, 0); - checkJitMapCoercion("status > $map.get(\"key\")", true, 1); - checkJitMapCoercion("$map.get(\"key\") < status", true, 1); + checkJitMapCoercion(kieBaseTestConfiguration, "status < $map.get(\"key\")", true, 0); + checkJitMapCoercion(kieBaseTestConfiguration, "$map.get(\"key\") > status", true, 0); + checkJitMapCoercion(kieBaseTestConfiguration, "status > $map.get(\"key\")", true, 1); + checkJitMapCoercion(kieBaseTestConfiguration, "$map.get(\"key\") < status", true, 1); - checkJitMapCoercion("status < $map.get(\"key\")", false, 1); - checkJitMapCoercion("$map.get(\"key\") > status", false, 1); - checkJitMapCoercion("status > $map.get(\"key\")", false, 0); - checkJitMapCoercion("$map.get(\"key\") < status", false, 0); + checkJitMapCoercion(kieBaseTestConfiguration, "status < $map.get(\"key\")", false, 1); + checkJitMapCoercion(kieBaseTestConfiguration, "$map.get(\"key\") > status", false, 1); + checkJitMapCoercion(kieBaseTestConfiguration, "status > $map.get(\"key\")", false, 0); + checkJitMapCoercion(kieBaseTestConfiguration, "$map.get(\"key\") < status", false, 0); // DROOLS-5596 - checkJitMapCoercion("$map.get(\"key\") < 10", true, 1); - checkJitMapCoercion("$map.get(\"key\") < \"10\"", true, 1); - checkJitMapCoercion("10 > $map.get(\"key\")", true, 1); - checkJitMapCoercion("\"10\" > $map.get(\"key\")", true, 1); + checkJitMapCoercion(kieBaseTestConfiguration, "$map.get(\"key\") < 10", true, 1); + checkJitMapCoercion(kieBaseTestConfiguration, "$map.get(\"key\") < \"10\"", true, 1); + checkJitMapCoercion(kieBaseTestConfiguration, "10 > $map.get(\"key\")", true, 1); + checkJitMapCoercion(kieBaseTestConfiguration, "\"10\" > $map.get(\"key\")", true, 1); } - public void checkJitMapCoercion(String constraint, boolean useInt, int expectedFires) { + public void checkJitMapCoercion(KieBaseTestConfiguration kieBaseTestConfiguration, String constraint, boolean useInt, int expectedFires) { String drl = "package com.sample\n" + "import " + Map.class.getCanonicalName() + ";\n" + @@ -254,8 +253,9 @@ public void checkJitMapCoercion(String constraint, boolean useInt, int expectedF assertThat(ksession.fireAllRules()).isEqualTo(expectedFires); } - @Test - public void testJittingBigDecimalAdd() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJittingBigDecimalAdd(KieBaseTestConfiguration kieBaseTestConfiguration) { // RHDM-1635 final String drl = "import " + BigDecimalFact.class.getCanonicalName() + ";\n" + @@ -274,8 +274,9 @@ public void testJittingBigDecimalAdd() { assertThat(kieSession.fireAllRules()).isEqualTo(1); } - @Test - public void testJittingBigDecimalRemainder() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJittingBigDecimalRemainder(KieBaseTestConfiguration kieBaseTestConfiguration) { // RHDM-1635 final String drl = "import " + BigDecimalFact.class.getCanonicalName() + ";\n" + @@ -310,8 +311,9 @@ public void setValue(BigDecimal value) { } } - @Test - public void testBigDecimalConstructorCoercion() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBigDecimalConstructorCoercion(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-6729 final String drl = "import " + BigDecimal.class.getCanonicalName() + "\n" + @@ -335,8 +337,9 @@ public void testBigDecimalConstructorCoercion() { } } - @Test - public void testJittingVarargsCall() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJittingVarargsCall(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-6841 final String drl = " rule R1 \n" + @@ -360,8 +363,9 @@ public String get(String x) { } } - @Test - public void testInvokeVarargsConstructor() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInvokeVarargsConstructor(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-7095 String drl = "package test\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/LengthSlidingWindowTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/LengthSlidingWindowTest.java index 2a90bfe4795..1a95d14c92c 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/LengthSlidingWindowTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/LengthSlidingWindowTest.java @@ -19,8 +19,8 @@ package org.drools.mvel.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.core.ClockType; import org.drools.core.impl.RuleBaseFactory; @@ -28,10 +28,9 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; @@ -43,22 +42,15 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.within; -@RunWith(Parameterized.class) public class LengthSlidingWindowTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public LengthSlidingWindowTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseStreamConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseStreamConfigurations(true).stream(); } - @Test - public void testSlidingWindowWithAlphaConstraint() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSlidingWindowWithAlphaConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "import " + StockTick.class.getCanonicalName() + "\n" + "global java.util.List list;\n" + @@ -70,11 +62,12 @@ public void testSlidingWindowWithAlphaConstraint() { " list.add($total);\n" + "end \n"; - checkPrice( drl, 30.0 ); + checkPrice(kieBaseTestConfiguration, drl, 30.0 ); } - @Test - public void testSlidingWindowWithBetaConstraint() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSlidingWindowWithBetaConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "import " + StockTick.class.getCanonicalName() + "\n" + "global java.util.List list;\n" + @@ -87,11 +80,12 @@ public void testSlidingWindowWithBetaConstraint() { " list.add($total);\n" + "end \n"; - checkPrice( drl, 10.0 ); + checkPrice(kieBaseTestConfiguration, drl, 10.0 ); } - @Test - public void testSlidingWindowWithDeclaration() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSlidingWindowWithDeclaration(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "import " + StockTick.class.getCanonicalName() + "\n" + "global java.util.List list;\n" + @@ -106,10 +100,10 @@ public void testSlidingWindowWithDeclaration() { " list.add($total);\n" + "end \n"; - checkPrice( drl, 10.0 ); + checkPrice(kieBaseTestConfiguration, drl, 10.0 ); } - private void checkPrice( String drl, double expectedPrice ) { + private void checkPrice(KieBaseTestConfiguration kieBaseTestConfiguration, String drl, double expectedPrice) { KieSessionConfiguration sessionConfig = RuleBaseFactory.newKnowledgeSessionConfiguration(); sessionConfig.setOption( ClockTypeOption.get( ClockType.PSEUDO_CLOCK.getId() ) ); @@ -134,8 +128,9 @@ private void checkPrice( String drl, double expectedPrice ) { assertThat((double) list.get(0)).isCloseTo(expectedPrice, within(0.01)); } - @Test - public void testCompilationFailureWithUnknownWindow() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCompilationFailureWithUnknownWindow(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-841 String drl = "import " + StockTick.class.getCanonicalName() + "\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/LifecycleTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/LifecycleTest.java index 3eb0e34e61e..155f873250f 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/LifecycleTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/LifecycleTest.java @@ -18,18 +18,16 @@ */ package org.drools.mvel.integrationtests; -import java.util.Collection; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; import org.drools.mvel.compiler.StockTick; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -47,24 +45,15 @@ /** * Tests updating events using API. */ -@RunWith(Parameterized.class) public class LifecycleTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public LifecycleTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseStreamConfigurations(true).stream(); } private KieSession kieSession; - @Before - public void initSession() { + public void initSession(KieBaseTestConfiguration kieBaseTestConfiguration) { String drlString = "package org.jboss.brms\n" + "import org.drools.mvel.compiler.StockTick\n" + "declare StockTick\n" + @@ -100,15 +89,17 @@ public void initSession() { .getDefaultReleaseId()).newKieSession(); } - @After + @AfterEach public void cleanup() { if (this.kieSession != null) { this.kieSession.dispose(); } } - @Test - public void testExpires() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExpires(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + initSession(kieBaseTestConfiguration); EntryPoint entryPoint = kieSession.getEntryPoint("EventStream"); StockTick event = new StockTick(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/LinkingTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/LinkingTest.java index 8630aaffed3..39a3cfab016 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/LinkingTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/LinkingTest.java @@ -19,8 +19,8 @@ package org.drools.mvel.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.base.base.ClassObjectType; import org.drools.core.common.InternalAgenda; @@ -48,30 +48,21 @@ import org.drools.core.reteoo.Tuple; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.rule.FactHandle; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class LinkingTest { // Note: Replaced class D with X : See DROOLS-6032 - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public LinkingTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } public static class A { @@ -214,8 +205,9 @@ public void setValue(int value) { } } - @Test - public void testSubNetworkSharing() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSubNetworkSharing(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // Checks the network is correctly formed, with sharing String str = ""; str += "package org.kie \n"; @@ -277,8 +269,9 @@ public void testSubNetworkSharing() throws Exception { assertThat(((RightInputAdapterNode) joinNodeD.getSinkPropagator().getSinks()[1]).getObjectSinkPropagator().getSinks()[0]).isSameAs(existsNode3); } - @Test - public void testSubNetworkSharingMemories() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSubNetworkSharingMemories(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // checks the memory sharing works, and linking, uses the already checked network from testSubNetworkSharing String str = ""; str += "package org.kie \n"; @@ -387,8 +380,9 @@ public void testSubNetworkSharingMemories() throws Exception { assertThat(rs3.isRuleLinked()).isFalse(); } - @Test - public void testSubNetworkRiaLinking() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSubNetworkRiaLinking(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.kie \n"; str += "import " + A.class.getCanonicalName() + "\n" ; @@ -470,8 +464,9 @@ public void testSubNetworkRiaLinking() throws Exception { assertThat(rs.isRuleLinked()).isTrue(); } - @Test - public void testNonReactiveSubNetworkInShareMasks() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNonReactiveSubNetworkInShareMasks(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.kie \n"; str += "import " + A.class.getCanonicalName() + "\n" ; @@ -521,8 +516,9 @@ public void testNonReactiveSubNetworkInShareMasks() throws Exception { assertThat(bm.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(2); // only X can be linked in } - @Test - public void testNonReactiveSubNetworkOwnSegmentMasks() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNonReactiveSubNetworkOwnSegmentMasks(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.kie \n"; str += "import " + A.class.getCanonicalName() + "\n" ; @@ -582,8 +578,9 @@ public void testNonReactiveSubNetworkOwnSegmentMasks() throws Exception { assertThat(riaMem.getAllLinkedMaskTest()).isEqualTo(0); // no segments to be linked in } - @Test - public void testNestedSubNetwork() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNestedSubNetwork(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.kie \n"; str += "import " + A.class.getCanonicalName() + "\n" ; @@ -658,8 +655,9 @@ public void testNestedSubNetwork() throws Exception { assertThat(rs.isRuleLinked()).isFalse(); } - @Test - public void testNestedSubNetworkMasks() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNestedSubNetworkMasks(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.kie \n"; str += "import " + A.class.getCanonicalName() + "\n" ; @@ -825,8 +823,9 @@ public void testNestedSubNetworkMasks() throws Exception { assertThat(eMem.getSegmentMemory().getLinkedNodeMask()).isEqualTo(2); assertThat(riaMem2.getLinkedSegmentMask()).isEqualTo(0); } - @Test - public void testJoinNodes() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJoinNodes(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.kie \n"; str += "import " + A.class.getCanonicalName() + "\n" ; @@ -904,8 +903,9 @@ public void testJoinNodes() throws Exception { assertThat(list.contains("0:0:25")).isTrue(); } - @Test - public void testExistsNodes1() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExistsNodes1(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.kie \n"; str += "import " + A.class.getCanonicalName() + "\n" ; @@ -945,8 +945,9 @@ public void testExistsNodes1() throws Exception { assertThat(list.size()).isEqualTo(1); } - @Test - public void testExistsNodes2() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExistsNodes2(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.kie \n"; str += "import " + A.class.getCanonicalName() + "\n" ; @@ -1004,8 +1005,9 @@ public void testExistsNodes2() throws Exception { assertThat(list.size()).isEqualTo(9); } - @Test - public void testNotNodeUnlinksWithNoConstriants() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNotNodeUnlinksWithNoConstriants(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = ""; str += "package org.kie \n"; str += "import " + A.class.getCanonicalName() + "\n" ; @@ -1080,8 +1082,9 @@ public void testNotNodeUnlinksWithNoConstriants() { assertThat(list.size()).isEqualTo(1); } - @Test - public void testNotNodeDoesNotUnlinksWithConstriants() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNotNodeDoesNotUnlinksWithConstriants(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = ""; str += "package org.kie \n"; str += "import " + A.class.getCanonicalName() + "\n" ; @@ -1133,8 +1136,9 @@ public void testNotNodeDoesNotUnlinksWithConstriants() { assertThat(amem.getSegmentMemory().getLinkedNodeMask()).isEqualTo(7); } - @Test - public void testNotNodes1() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNotNodes1(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.kie \n"; str += "import " + A.class.getCanonicalName() + "\n" ; @@ -1175,8 +1179,9 @@ public void testNotNodes1() throws Exception { } - @Test - public void testNotNodes2() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNotNodes2(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.kie \n"; str += "import " + A.class.getCanonicalName() + "\n" ; @@ -1238,8 +1243,9 @@ public void testNotNodes2() throws Exception { assertThat(list.size()).isEqualTo(9); } - @Test - public void testNotNodeMasksWithConstraints() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNotNodeMasksWithConstraints(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.kie \n"; str += "import " + A.class.getCanonicalName() + "\n" ; @@ -1291,8 +1297,9 @@ public void testNotNodeMasksWithConstraints() throws Exception { assertThat(pmem.isRuleLinked()).isTrue(); } - @Test - public void testNotNodeMasksWithoutConstraints() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNotNodeMasksWithoutConstraints(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.kie \n"; str += "import " + A.class.getCanonicalName() + "\n" ; @@ -1344,8 +1351,9 @@ public void testNotNodeMasksWithoutConstraints() throws Exception { assertThat(pmem.isRuleLinked()).isTrue(); } - @Test - public void testForallNodes() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testForallNodes(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.kie \n"; str += "import " + A.class.getCanonicalName() + "\n" ; @@ -1411,8 +1419,9 @@ public void testForallNodes() throws Exception { // assertEquals( 9, list.size() ); } - @Test - public void testAccumulateNodes1() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccumulateNodes1(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.kie \n"; str += "import " + A.class.getCanonicalName() + "\n" ; @@ -1451,8 +1460,9 @@ public void testAccumulateNodes1() throws Exception { assertThat(list.get(0)).isEqualTo(4); } - @Test - public void testAccumulateNodes2() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccumulateNodes2(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.kie \n"; str += "import " + A.class.getCanonicalName() + "\n" ; @@ -1497,8 +1507,9 @@ public void testAccumulateNodes2() throws Exception { } - @Test - public void testSubnetwork() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSubnetwork(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.kie \n"; str += "import " + A.class.getCanonicalName() + "\n" ; @@ -1550,8 +1561,9 @@ public void testSubnetwork() throws Exception { assertThat(list.size()).isEqualTo(1); // check it doesn't double fire } - @Test - public void testNestedSubnetwork() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNestedSubnetwork(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.kie \n"; str += "import " + A.class.getCanonicalName() + "\n" ; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ListenersTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ListenersTest.java index 04e74f7f11d..44007d77758 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ListenersTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ListenersTest.java @@ -20,15 +20,14 @@ import java.util.Collection; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -51,18 +50,10 @@ /** * Tests stateful/stateless KieSession listeners registration - DROOLS-818. */ -@RunWith(Parameterized.class) public class ListenersTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public ListenersTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } private static final ReleaseId RELEASE_ID = KieServices.Factory.get() @@ -82,16 +73,15 @@ public static Collection getParameters() { private KieSession kieSession; private StatelessKieSession statelessKieSession; - @Before - public void init() { - ReleaseId kieModuleId = prepareKieModule(); + public void init(KieBaseTestConfiguration kieBaseTestConfiguration) { + ReleaseId kieModuleId = prepareKieModule(kieBaseTestConfiguration); final KieContainer kieContainer = ks.newKieContainer(kieModuleId); this.kieSession = kieContainer.newKieSession(); this.statelessKieSession = kieContainer.newStatelessKieSession(); } - @After + @AfterEach public void cleanup() { if (this.kieSession != null) { this.kieSession.dispose(); @@ -99,28 +89,36 @@ public void cleanup() { this.statelessKieSession = null; } - @Test - public void testRegisterAgendaEventListenerStateful() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRegisterAgendaEventListenerStateful(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + init(kieBaseTestConfiguration); kieSession.insert("test"); kieSession.fireAllRules(); checkThatListenerFired(kieSession.getAgendaEventListeners()); } - @Test - public void testRegisterRuleRuntimeEventListenerStateful() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRegisterRuleRuntimeEventListenerStateful(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + init(kieBaseTestConfiguration); kieSession.insert("test"); kieSession.fireAllRules(); checkThatListenerFired(kieSession.getRuleRuntimeEventListeners()); } - @Test - public void testRegisterAgendaEventListenerStateless() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRegisterAgendaEventListenerStateless(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + init(kieBaseTestConfiguration); statelessKieSession.execute(KieServices.Factory.get().getCommands().newInsert("test")); checkThatListenerFired(statelessKieSession.getAgendaEventListeners()); } - @Test - public void testRegisterRuleEventListenerStateless() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRegisterRuleEventListenerStateless(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + init(kieBaseTestConfiguration); statelessKieSession.execute(KieServices.Factory.get().getCommands().newInsert("test")); checkThatListenerFired(statelessKieSession.getRuleRuntimeEventListeners()); } @@ -143,10 +141,11 @@ private MarkingListener getMarkingListener(Collection listeners) { /** * Inserts a new KieModule containing single KieBase and a stateful and stateless KieSessions with listeners * into KieRepository. + * @param kieBaseTestConfiguration * * @return created KIE module ReleaseId */ - private ReleaseId prepareKieModule() { + private ReleaseId prepareKieModule(KieBaseTestConfiguration kieBaseTestConfiguration) { final KieServices ks = KieServices.Factory.get(); KieModuleModel module = ks.newKieModuleModel(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MBeansMonitoringTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MBeansMonitoringTest.java index 702c0877bae..cb5640ddf9c 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MBeansMonitoringTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MBeansMonitoringTest.java @@ -22,7 +22,7 @@ import java.lang.management.ManagementFactory; import java.net.URL; import java.net.URLClassLoader; -import java.util.Collection; +import java.util.stream.Stream; import javax.management.JMX; import javax.management.MBeanServer; @@ -36,12 +36,11 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; import org.drools.testcoverage.common.util.TestConstants; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.builder.KieModule; @@ -69,7 +68,6 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class MBeansMonitoringTest { public static final Logger LOG = LoggerFactory.getLogger(MBeansMonitoringTest.class); @@ -79,18 +77,11 @@ public class MBeansMonitoringTest { private static final String KSESSION2 = "KSession2"; private String mbeansprop; - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public MBeansMonitoringTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseStreamConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseStreamConfigurations(true).stream(); } - @Before + @BeforeEach public void setUp() throws Exception { (( KieServicesImpl ) KieServices.Factory.get()).nullKieClasspathContainer(); ((KieServicesImpl) KieServices.Factory.get()).nullAllContainerIds(); @@ -98,19 +89,20 @@ public void setUp() throws Exception { System.setProperty( MBeansOption.PROPERTY_NAME, "enabled" ); } - @After + @AfterEach public void tearDown() throws Exception { ((KieServicesImpl) KieServices.Factory.get()).nullKieClasspathContainer(); ((KieServicesImpl) KieServices.Factory.get()).nullAllContainerIds(); if (mbeansprop != null) { - System.setProperty( MBeansOption.PROPERTY_NAME, mbeansprop ); - } else { - System.setProperty( MBeansOption.PROPERTY_NAME, MBeansOption.DISABLED.toString() ); - } + System.setProperty( MBeansOption.PROPERTY_NAME, mbeansprop ); + } else { + System.setProperty( MBeansOption.PROPERTY_NAME, MBeansOption.DISABLED.toString() ); + } } - @Test - public void testKieClasspathMBeans() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKieClasspathMBeans(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { MBeanServer mbserver = ManagementFactory.getPlatformMBeanServer(); KieServices ks = KieServices.Factory.get(); @@ -172,96 +164,97 @@ public void testKieClasspathMBeans() throws Exception { kc2.dispose(); } - @Test - public void testEventOffset() throws Exception { - String drl = "package org.drools.mvel.compiler.test\n" + - "import org.drools.mvel.compiler.StockTick\n" + - "declare StockTick\n" + - " @role(event)\n" + - " @expires(10s)\n" + - "end\n" + - "rule X\n" + - "when\n" + - " StockTick()\n" + - "then\n" + - "end"; - - KieServices ks = KieServices.Factory.get(); - - KieModuleModel kproj = ks.newKieModuleModel(); - - KieBaseModel kieBaseModel1 = kproj.newKieBaseModel( KBASE1 ).setDefault( true ) - .setEventProcessingMode( EventProcessingOption.STREAM ); - KieSessionModel ksession1 = kieBaseModel1.newKieSessionModel( KSESSION1 ).setDefault( true ) - .setType( KieSessionModel.KieSessionType.STATEFUL ) - .setClockType( ClockTypeOption.get( ClockType.PSEUDO_CLOCK.getId() ) ); - - ReleaseId releaseId1 = ks.newReleaseId( "org.kie.test", "mbeans", "1.0.0" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEventOffset(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + String drl = "package org.drools.mvel.compiler.test\n" + + "import org.drools.mvel.compiler.StockTick\n" + + "declare StockTick\n" + + " @role(event)\n" + + " @expires(10s)\n" + + "end\n" + + "rule X\n" + + "when\n" + + " StockTick()\n" + + "then\n" + + "end"; + + KieServices ks = KieServices.Factory.get(); + + KieModuleModel kproj = ks.newKieModuleModel(); + + KieBaseModel kieBaseModel1 = kproj.newKieBaseModel( KBASE1 ).setDefault( true ) + .setEventProcessingMode( EventProcessingOption.STREAM ); + KieSessionModel ksession1 = kieBaseModel1.newKieSessionModel( KSESSION1 ).setDefault( true ) + .setType( KieSessionModel.KieSessionType.STATEFUL ) + .setClockType( ClockTypeOption.get( ClockType.PSEUDO_CLOCK.getId() ) ); + + ReleaseId releaseId1 = ks.newReleaseId( "org.kie.test", "mbeans", "1.0.0" ); final Resource drlResource1 = KieServices.Factory.get().getResources().newReaderResource(new StringReader(drl)); drlResource1.setSourcePath(TestConstants.TEST_RESOURCES_FOLDER + "rule1.drl"); - KieModule km = KieUtil.buildAndInstallKieModuleIntoRepo(kieBaseTestConfiguration, releaseId1, kproj, drlResource1); + KieModule km = KieUtil.buildAndInstallKieModuleIntoRepo(kieBaseTestConfiguration, releaseId1, kproj, drlResource1); - KieContainer kc = ks.newKieContainer( releaseId1 ); + KieContainer kc = ks.newKieContainer( releaseId1 ); - KieBase kiebase = kc.getKieBase( KBASE1 ); - MBeanServer mbserver = ManagementFactory.getPlatformMBeanServer(); + KieBase kiebase = kc.getKieBase( KBASE1 ); + MBeanServer mbserver = ManagementFactory.getPlatformMBeanServer(); - ObjectName kbOn = DroolsManagementAgent.createObjectNameFor((InternalKnowledgeBase) kiebase); - mbserver.invoke( kbOn, "startInternalMBeans", new Object[0], new String[0] ); + ObjectName kbOn = DroolsManagementAgent.createObjectNameFor((InternalKnowledgeBase) kiebase); + mbserver.invoke( kbOn, "startInternalMBeans", new Object[0], new String[0] ); - Object expOffset = mbserver.getAttribute( new ObjectName( kbOn + ",group=EntryPoints,EntryPoint=DEFAULT,ObjectType=org.drools.mvel.compiler.StockTick" ), "ExpirationOffset" ); + Object expOffset = mbserver.getAttribute( new ObjectName( kbOn + ",group=EntryPoints,EntryPoint=DEFAULT,ObjectType=org.drools.mvel.compiler.StockTick" ), "ExpirationOffset" ); assertThat(((Number) expOffset).longValue()).isEqualTo(10001); - - kc.dispose(); + kc.dispose(); } - @Test - public void testContainerMBeans() throws Exception { - String drl = "package org.drools.mvel.compiler.test\n" + - "import org.drools.mvel.compiler.StockTick\n" + - "declare StockTick\n" + - " @role(event)\n" + - " @expires(10s)\n" + - "end\n" + - "rule X\n" + - "when\n" + - " StockTick()\n" + - "then\n" + - "end"; - - KieServices ks = KieServices.Factory.get(); - - KieModuleModel kproj = ks.newKieModuleModel(); - - KieBaseModel kieBaseModel1 = kproj.newKieBaseModel( KBASE1 ).setDefault( true ) - .setEventProcessingMode( EventProcessingOption.STREAM ); - KieSessionModel ksessionModel1 = kieBaseModel1.newKieSessionModel( KSESSION1 ).setDefault( true ) - .setType( KieSessionModel.KieSessionType.STATEFUL ) - .setClockType( ClockTypeOption.get( ClockType.PSEUDO_CLOCK.getId() ) ); - - ReleaseId releaseId1 = ks.newReleaseId( "org.kie.test", "mbeans", "1.0.0" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testContainerMBeans(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + String drl = "package org.drools.mvel.compiler.test\n" + + "import org.drools.mvel.compiler.StockTick\n" + + "declare StockTick\n" + + " @role(event)\n" + + " @expires(10s)\n" + + "end\n" + + "rule X\n" + + "when\n" + + " StockTick()\n" + + "then\n" + + "end"; + + KieServices ks = KieServices.Factory.get(); + + KieModuleModel kproj = ks.newKieModuleModel(); + + KieBaseModel kieBaseModel1 = kproj.newKieBaseModel( KBASE1 ).setDefault( true ) + .setEventProcessingMode( EventProcessingOption.STREAM ); + KieSessionModel ksessionModel1 = kieBaseModel1.newKieSessionModel( KSESSION1 ).setDefault( true ) + .setType( KieSessionModel.KieSessionType.STATEFUL ) + .setClockType( ClockTypeOption.get( ClockType.PSEUDO_CLOCK.getId() ) ); + + ReleaseId releaseId1 = ks.newReleaseId( "org.kie.test", "mbeans", "1.0.0" ); final Resource drlResource1 = KieServices.Factory.get().getResources().newReaderResource(new StringReader(drl)); drlResource1.setSourcePath(TestConstants.TEST_RESOURCES_FOLDER + "rule1.drl"); KieModule km = KieUtil.buildAndInstallKieModuleIntoRepo(kieBaseTestConfiguration, releaseId1, kproj, drlResource1); - - KieContainer kc = ks.newKieContainer( releaseId1 ); - KieBase kiebase = kc.getKieBase( KBASE1 ); - kc.newKieSession(KSESSION1); - kiebase.newKieSession(); - - String kc1ID = ((InternalKieContainer) kc).getContainerId(); - MBeanServer mbserver = ManagementFactory.getPlatformMBeanServer(); - LOG.debug("{}", mbserver.queryNames(new ObjectName("org.kie:kcontainerId="+ObjectName.quote(kc1ID)+",*"), null) ); - - ReleaseId verRelease = ks.newReleaseId("org.kie.test", "mbeans", "RELEASE" ); + + KieContainer kc = ks.newKieContainer( releaseId1 ); + KieBase kiebase = kc.getKieBase( KBASE1 ); + kc.newKieSession(KSESSION1); + kiebase.newKieSession(); + + String kc1ID = ((InternalKieContainer) kc).getContainerId(); + MBeanServer mbserver = ManagementFactory.getPlatformMBeanServer(); + LOG.debug("{}", mbserver.queryNames(new ObjectName("org.kie:kcontainerId="+ObjectName.quote(kc1ID)+",*"), null) ); + + ReleaseId verRelease = ks.newReleaseId("org.kie.test", "mbeans", "RELEASE" ); KieContainer kc2 = ks.newKieContainer( "Matteo", verRelease ); - kc2.newKieSession(KSESSION1); - - - KieContainerMonitorMXBean c1Monitor = JMX.newMXBeanProxy( - mbserver, - DroolsManagementAgent.createObjectNameBy(kc1ID), - KieContainerMonitorMXBean.class); + kc2.newKieSession(KSESSION1); + + + KieContainerMonitorMXBean c1Monitor = JMX.newMXBeanProxy( + mbserver, + DroolsManagementAgent.createObjectNameBy(kc1ID), + KieContainerMonitorMXBean.class); assertThat(c1Monitor.getConfiguredReleaseIdStr()).isEqualTo(releaseId1.toExternalForm()); assertThat(c1Monitor.getResolvedReleaseIdStr()).isEqualTo(releaseId1.toExternalForm()); @@ -269,11 +262,11 @@ public void testContainerMBeans() throws Exception { assertThat(c1Monitor.getResolvedReleaseId().sameGAVof(releaseId1)).isTrue(); assertThat(c1Monitor.getConfiguredReleaseId().getVersion()).isEqualTo(releaseId1.getVersion()); assertThat(c1Monitor.getResolvedReleaseId().getVersion()).isEqualTo(releaseId1.getVersion()); - - KieContainerMonitorMXBean c2Monitor = JMX.newMXBeanProxy( - mbserver, - DroolsManagementAgent.createObjectNameBy("Matteo"), - KieContainerMonitorMXBean.class); + + KieContainerMonitorMXBean c2Monitor = JMX.newMXBeanProxy( + mbserver, + DroolsManagementAgent.createObjectNameBy("Matteo"), + KieContainerMonitorMXBean.class); assertThat(c2Monitor.getConfiguredReleaseIdStr()).isEqualTo(verRelease.toExternalForm()); assertThat(c2Monitor.getResolvedReleaseIdStr()).isEqualTo(releaseId1.toExternalForm()); @@ -292,8 +285,9 @@ public void testContainerMBeans() throws Exception { kc2.dispose(); } - @Test - public void testAggregatedAndDispose() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAggregatedAndDispose(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drl = "package org.drools.mvel.integrationtests\n" + "rule ND\n" + @@ -528,8 +522,9 @@ private void checkAgendaTotals(GenericKieSessionMonitoringMXBean mb, long mCreat /** * Copied from KieRepositoryTest to test JMX monitoring */ - @Test - public void testLoadKjarFromClasspath() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLoadKjarFromClasspath(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1335 ClassLoader cl = Thread.currentThread().getContextClassLoader(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MTEntryPointsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MTEntryPointsTest.java index 6351fa8fe7a..749f5ca292b 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MTEntryPointsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MTEntryPointsTest.java @@ -19,21 +19,19 @@ package org.drools.mvel.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -52,24 +50,15 @@ * * BZ-967599 */ -@RunWith(Parameterized.class) public class MTEntryPointsTest { private KieSession kieSession; - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public MTEntryPointsTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseStreamConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseStreamConfigurations(true).stream(); } - @Before - public void initSession() { + public void initSession(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package org.jboss.brms\n" + "\n" + "import org.drools.mvel.integrationtests.MTEntryPointsTest.MessageEvent\n" + @@ -122,7 +111,7 @@ public void initSession() { .getDefaultReleaseId()).newKieSession(); } - @After + @AfterEach public void cleanup() { if (this.kieSession != null) { this.kieSession.dispose(); @@ -133,8 +122,10 @@ public void cleanup() { * Inserts events using multiple threads into one EntryPoint. The insert * operation is synchronized on corresponding SessionEntryPoint instance. */ - @Test - public void testOneEntryPoint() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOneEntryPoint(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + initSession(kieBaseTestConfiguration); final EntryPoint firstThreadEntryPoint = kieSession.getEntryPoint("FirstStream"); final int numInsertersInEachEntryPoint = 10; @@ -161,9 +152,10 @@ public void testOneEntryPoint() throws Exception { * Inserts events using multiple threads into two EntryPoints. The insert * operation is synchronized on corresponding SessionEntryPoint instance. */ - @Test - public void testTwoEntryPoints() throws Exception { - + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTwoEntryPoints(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + initSession(kieBaseTestConfiguration); final EntryPoint firstThreadEntryPoint = kieSession.getEntryPoint("FirstStream"); final EntryPoint secondThreadEntryPoint = kieSession.getEntryPoint("SecondStream"); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MVELEmptyCollectionsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MVELEmptyCollectionsTest.java index aa884f989b4..6b613cfc6a3 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MVELEmptyCollectionsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MVELEmptyCollectionsTest.java @@ -18,73 +18,31 @@ */ package org.drools.mvel.integrationtests; -import org.drools.base.base.ClassObjectType; -import org.drools.base.rule.constraint.AlphaNodeFieldConstraint; -import org.drools.core.reteoo.AlphaNode; -import org.drools.core.reteoo.ObjectTypeNode; -import org.drools.kiesession.rulebase.InternalKnowledgeBase; -import org.drools.mvel.MVELConstraint; -import org.drools.mvel.accessors.ClassFieldReader; -import org.drools.mvel.compiler.Address; -import org.drools.mvel.compiler.Cheese; -import org.drools.mvel.compiler.Cheesery; -import org.drools.mvel.compiler.FactA; -import org.drools.mvel.compiler.Person; -import org.drools.mvel.compiler.TestEnum; -import org.drools.mvel.expr.MVELDebugHandler; -import org.drools.mvel.extractors.MVELObjectClassFieldReader; import org.drools.mvel.integrationtests.facts.FactWithList; import org.drools.mvel.integrationtests.facts.FactWithMap; import org.drools.mvel.integrationtests.facts.FactWithObject; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.drools.util.DateUtils; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; -import org.kie.api.builder.KieBuilder; -import org.kie.api.builder.Message; -import org.kie.api.definition.type.FactType; import org.kie.api.runtime.KieSession; -import org.kie.api.runtime.StatelessKieSession; -import org.mvel2.MVEL; -import org.mvel2.ParserContext; -import java.io.Serializable; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.math.MathContext; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; -@RunWith(Parameterized.class) public class MVELEmptyCollectionsTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public MVELEmptyCollectionsTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { + public static Stream parameters() { // Some of these fail without executable model, so test only executable model. - return TestParametersUtil.getKieBaseCloudOnlyExecModelConfiguration(); + return TestParametersUtil2.getKieBaseCloudOnlyExecModelConfiguration().stream(); } - @Test - public void testEmptyListAsMethodParameter() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEmptyListAsMethodParameter(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import " + FactWithList.class.getCanonicalName() + "; \n" + "rule \"test\"\n" + @@ -103,8 +61,9 @@ public void testEmptyListAsMethodParameter() { assertThat(f.getItems()).hasSize(0); } - @Test - public void testEmptyListAsConstructorParameter() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEmptyListAsConstructorParameter(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import " + FactWithList.class.getCanonicalName() + "; \n" + "import " + FactWithObject.class.getCanonicalName() + "; \n" + @@ -124,8 +83,9 @@ public void testEmptyListAsConstructorParameter() { assertThat(f.getObjectValue()).isInstanceOf(FactWithList.class); } - @Test - public void testEmptyMapAsMethodParameter() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEmptyMapAsMethodParameter(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import " + FactWithMap.class.getCanonicalName() + "; \n" + "rule \"test\"\n" + @@ -144,8 +104,9 @@ public void testEmptyMapAsMethodParameter() { assertThat(f.getItemsMap()).hasSize(0); } - @Test - public void testEmptyMapAsConstructorParameter() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEmptyMapAsConstructorParameter(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import " + FactWithMap.class.getCanonicalName() + "; \n" + "import " + FactWithObject.class.getCanonicalName() + "; \n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MVELTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MVELTest.java index a7c55659195..0b4e6578e1a 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MVELTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MVELTest.java @@ -29,6 +29,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Stream; import org.drools.kiesession.rulebase.InternalKnowledgeBase; import org.drools.mvel.accessors.ClassFieldReader; @@ -36,8 +37,6 @@ import org.drools.core.reteoo.AlphaNode; import org.drools.core.reteoo.ObjectTypeNode; import org.drools.base.rule.constraint.AlphaNodeFieldConstraint; -import org.drools.mvel.compiler.PersonHolder; -import org.drools.mvel.integrationtests.facts.FactWithList; import org.drools.util.DateUtils; import org.drools.mvel.MVELConstraint; import org.drools.mvel.compiler.Address; @@ -51,10 +50,9 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.Message; @@ -67,23 +65,16 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -@RunWith(Parameterized.class) public class MVELTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public MVELTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - // TODO: EM failed with some tests. File JIRAs - return TestParametersUtil.getKieBaseCloudConfigurations(false); + public static Stream parameters() { + // TODO: EM failed with some tests. File JIRAs + return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); } - @Test - public void testHelloWorld() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testHelloWorld(KieBaseTestConfiguration kieBaseTestConfiguration) { // read in the source KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_mvel.drl"); final KieSession ksession = kbase.newKieSession(); @@ -107,8 +98,9 @@ public void testHelloWorld() { assertThat(c.getUsedBy()).isEqualTo(dt); } - @Test - public void testIncrementOperator() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIncrementOperator(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = ""; str += "package org.kie \n"; str += "global java.util.List list \n"; @@ -134,8 +126,9 @@ public void testIncrementOperator() { assertThat(list.get(0)).isEqualTo(10); } - @Test - public void testEvalWithBigDecimal() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEvalWithBigDecimal(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = ""; str += "package org.kie \n"; str += "import java.math.BigDecimal; \n"; @@ -161,8 +154,9 @@ public void testEvalWithBigDecimal() { assertThat(list.get(0)).isEqualTo(new BigDecimal(1.5)); } - @Test - public void testLocalVariableMVELConsequence() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLocalVariableMVELConsequence(KieBaseTestConfiguration kieBaseTestConfiguration) { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_LocalVariableMVELConsequence.drl"); final KieSession ksession = kbase.newKieSession(); @@ -182,8 +176,9 @@ public void testLocalVariableMVELConsequence() { } - @Test - public void testMVELUsingGlobalsInDebugMode() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMVELUsingGlobalsInDebugMode(KieBaseTestConfiguration kieBaseTestConfiguration) { MVELDebugHandler.setDebugMode(true); try { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_MVELGlobalDebug.drl"); @@ -199,15 +194,17 @@ public void testMVELUsingGlobalsInDebugMode() { } - @Test - public void testDuplicateLocalVariableMVELConsequence() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDuplicateLocalVariableMVELConsequence(KieBaseTestConfiguration kieBaseTestConfiguration) { KieBuilder kieBuilder = KieUtil.getKieBuilderFromClasspathResources(kieBaseTestConfiguration, getClass(), false, "test_DuplicateLocalVariableMVELConsequence.drl"); List errors = kieBuilder.getResults().getMessages(org.kie.api.builder.Message.Level.ERROR); assertThat(errors.isEmpty()).as("Should have an error").isFalse(); } - @Test - public void testArrays() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testArrays(KieBaseTestConfiguration kieBaseTestConfiguration) { String text = "package test_mvel;\n"; text += "import " + TestObject.class.getCanonicalName() + ";\n"; text += "import function " + TestObject.class.getCanonicalName() + ".array;\n"; @@ -238,8 +235,9 @@ public void testArrays() { "TestObject.applyValueAddPromo: 1|2|3|4|java"))).isTrue(); } - @Test - public void testPackageImports() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPackageImports(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = ""; str += "package org.kie \n"; str += "dialect \"mvel\"\n"; @@ -263,8 +261,9 @@ public void testPackageImports() { assertThat(insertedObjects.size()).isEqualTo(3); } - @Test - public void testSizeCheckInObject() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSizeCheckInObject(KieBaseTestConfiguration kieBaseTestConfiguration) { final String str = ""+ "package org.drools.mvel.compiler.test \n" + "import " + Triangle.class.getCanonicalName() + "\n" + @@ -282,8 +281,9 @@ public void testSizeCheckInObject() { } - @Test - public void testNestedEnum() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNestedEnum(KieBaseTestConfiguration kieBaseTestConfiguration) { final String str = ""+ "package org.drools.mvel.compiler.test \n" + "import " + Triangle.class.getCanonicalName() + "\n" + @@ -305,8 +305,9 @@ public void testNestedEnum() { assertThat(list.get(0)).isEqualTo(Triangle.Type.ACUTE); } - @Test - public void testNestedEnumWithMap() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNestedEnumWithMap(KieBaseTestConfiguration kieBaseTestConfiguration) { final String str = ""+ "package org.drools.mvel.compiler.test \n" + "import " + DMap.class.getCanonicalName() + " \n" + @@ -332,8 +333,9 @@ public void testNestedEnumWithMap() { assertThat(list.get(0)).isEqualTo("r1"); } - @Test - public void testNewConstructor() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNewConstructor(KieBaseTestConfiguration kieBaseTestConfiguration) { final String str = ""+ "package org.drools.mvel.compiler.test \n" + "import " + Person.class.getCanonicalName() + "\n" + @@ -376,8 +378,9 @@ public void testNewConstructor() { } } - @Test - public void testArrayAccessorWithGenerics() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testArrayAccessorWithGenerics(KieBaseTestConfiguration kieBaseTestConfiguration) { final String str = ""+ "package org.drools.mvel.compiler.test \n" + "import " + Person.class.getCanonicalName() + "\n" + @@ -427,8 +430,9 @@ public void testArrayAccessorWithGenerics() { } } - @Test - public void testArrayAccessorWithStaticFieldAccess() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testArrayAccessorWithStaticFieldAccess(KieBaseTestConfiguration kieBaseTestConfiguration) { final String str = ""+ "package org.drools.mvel.compiler.test \n" + "import " + Person.class.getCanonicalName() + "\n" + @@ -478,8 +482,9 @@ public void testArrayAccessorWithStaticFieldAccess() { } } - @Test - public void testMapAccessorWithStaticFieldAccess() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMapAccessorWithStaticFieldAccess(KieBaseTestConfiguration kieBaseTestConfiguration) { final String str = ""+ "package org.drools.mvel.compiler.test \n" + "import " + Person.class.getCanonicalName() + "\n" + @@ -532,8 +537,9 @@ public void testMapAccessorWithStaticFieldAccess() { } } - @Test - public void testArrayAccessorWithoutGenerics() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testArrayAccessorWithoutGenerics(KieBaseTestConfiguration kieBaseTestConfiguration) { final String str = ""+ "package org.drools.mvel.compiler.test \n" + "import " + Person.class.getCanonicalName() + "\n" + @@ -595,8 +601,9 @@ public Object compiledExecute(final String ex) { new HashMap() ); } - @Test - public void test1() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void test1(KieBaseTestConfiguration kieBaseTestConfiguration) { final ParserContext pc = new ParserContext(); pc.addInput("x", String.class); pc.setStrongTyping(true); @@ -607,8 +614,9 @@ public void test1() { System.out.println(o); } - @Test - public void testTokensInString(){ + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTokensInString(KieBaseTestConfiguration kieBaseTestConfiguration) { //should query antldr DFA63 class but don't know how final String [] operators = {"," ,"=" , "|=", "*"}; //test various in consequence @@ -632,8 +640,9 @@ public void testTokensInString(){ } } - @Test - public void testGeneratedBeansMVEL() throws IllegalAccessException, InstantiationException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGeneratedBeansMVEL(KieBaseTestConfiguration kieBaseTestConfiguration) throws IllegalAccessException, InstantiationException { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_GeneratedBeansMVEL.drl"); // Retrieve the generated fact type @@ -651,8 +660,9 @@ public void testGeneratedBeansMVEL() throws IllegalAccessException, Instantiatio ksession.fireAllRules(); } - @Test - public void testMVELClassReferences() throws InstantiationException, IllegalAccessException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMVELClassReferences(KieBaseTestConfiguration kieBaseTestConfiguration) throws InstantiationException, IllegalAccessException { final String str = "package org.drools.compiler\n" + "declare Assignment\n" + " source : Class\n" + @@ -685,8 +695,9 @@ public void testMVELClassReferences() throws InstantiationException, IllegalAcce assertThat(rules).isEqualTo(2); } - @Test - public void testMVELConstraintsWithFloatingPointNumbersInScientificNotation() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMVELConstraintsWithFloatingPointNumbersInScientificNotation(KieBaseTestConfiguration kieBaseTestConfiguration) { final String rule = "package test; \n" + "dialect \"mvel\"\n" + "global java.util.List list;" + @@ -719,8 +730,9 @@ public void testMVELConstraintsWithFloatingPointNumbersInScientificNotation() { assertThat(list.size()).isEqualTo(1); } - @Test - public void testMvelDoubleInvocation() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMvelDoubleInvocation(KieBaseTestConfiguration kieBaseTestConfiguration) { final String rule = "package org.drools.compiler\n" + "import " + TestUtility.class.getCanonicalName() + ";\n" + "import " + TestFact.class.getCanonicalName() + ";\n" + @@ -798,8 +810,9 @@ public void setS(final String s) { } } - @Test - public void testMVELSoundex() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMVELSoundex(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // read in the source KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "MVEL_soundex.drl"); KieSession ksession = kbase.newKieSession(); @@ -813,8 +826,9 @@ public void testMVELSoundex() throws Exception { assertThat(c.getPrice()).isEqualTo(42); } - @Test - public void testMVELSoundexNoCharParam() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMVELSoundexNoCharParam(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // read in the source KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "MVEL_soundexNPE2500.drl"); KieSession ksession = kbase.newKieSession(); @@ -834,8 +848,9 @@ public void testMVELSoundexNoCharParam() throws Exception { assertThat(starCheese.getPrice()).isEqualTo(2); } - @Test - public void testMVELRewrite() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMVELRewrite(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // read in the source KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_MVELrewrite.drl"); KieSession ksession = kbase.newKieSession(); @@ -857,8 +872,9 @@ public void testMVELRewrite() throws Exception { assertThat(results.get(0)).isEqualTo(cheesery); } - @Test - public void testMVELTypeCoercion() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMVELTypeCoercion(KieBaseTestConfiguration kieBaseTestConfiguration) { final String str = "package org.drools.mvel.compiler.test; \n" + "\n" + "global java.util.List list;" + @@ -883,7 +899,7 @@ public void testMVELTypeCoercion() { " list.add( \"OK\" ); \n" + "end"; - KieBaseTestConfiguration equalityConfig = TestParametersUtil.getEqualityInstanceOf(kieBaseTestConfiguration); + KieBaseTestConfiguration equalityConfig = TestParametersUtil2.getEqualityInstanceOf(kieBaseTestConfiguration); KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", equalityConfig, str); KieSession ksession = kbase.newKieSession(); @@ -896,8 +912,9 @@ public void testMVELTypeCoercion() { ksession.dispose(); } - @Test - public void testNoMvelSyntaxInFunctions() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNoMvelSyntaxInFunctions(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3433 final String str = "import java.util.*;\n" + "dialect \"mvel\"\n" + @@ -912,8 +929,9 @@ public void testNoMvelSyntaxInFunctions() { assertThat(errors.isEmpty()).as("Should have an error").isFalse(); } - @Test - public void testModifyObjectWithMutableHashCodeInEqualityMode() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModifyObjectWithMutableHashCodeInEqualityMode(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-2828 String str = "package com.sample\n" + "import " + Human.class.getCanonicalName() + ";\n" + @@ -928,7 +946,7 @@ public void testModifyObjectWithMutableHashCodeInEqualityMode() { " }\n" + "end"; - KieBaseTestConfiguration equalityConfig = TestParametersUtil.getEqualityInstanceOf(kieBaseTestConfiguration); + KieBaseTestConfiguration equalityConfig = TestParametersUtil2.getEqualityInstanceOf(kieBaseTestConfiguration); KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", equalityConfig, str); KieSession ksession = kbase.newKieSession(); Human h = new Human(2); @@ -937,8 +955,9 @@ public void testModifyObjectWithMutableHashCodeInEqualityMode() { assertThat(h.getAge()).isEqualTo(10); } - @Test - public void testModifyObjectWithMutableHashCodeInEqualityMode2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModifyObjectWithMutableHashCodeInEqualityMode2(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-2828 String str = "package com.sample\n" + "import " + Human.class.getCanonicalName() + ";\n" + @@ -954,7 +973,7 @@ public void testModifyObjectWithMutableHashCodeInEqualityMode2() { " }\n" + "end"; - KieBaseTestConfiguration equalityConfig = TestParametersUtil.getEqualityInstanceOf(kieBaseTestConfiguration); + KieBaseTestConfiguration equalityConfig = TestParametersUtil2.getEqualityInstanceOf(kieBaseTestConfiguration); KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", equalityConfig, str); KieSession ksession = kbase.newKieSession(); Human h = new Human(2); @@ -999,8 +1018,9 @@ public boolean equals(Object obj) { } } - @Test - public void test2ndDashInMvelConsequnence() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void test2ndDashInMvelConsequnence(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-3678 String str = "package com.sample\n" + "import " + Fact.class.getCanonicalName() + ";\n" + @@ -1014,7 +1034,7 @@ public void test2ndDashInMvelConsequnence() { " System.out.println( $fact );\n" + "end"; - KieBaseTestConfiguration equalityConfig = TestParametersUtil.getEqualityInstanceOf(kieBaseTestConfiguration); + KieBaseTestConfiguration equalityConfig = TestParametersUtil2.getEqualityInstanceOf(kieBaseTestConfiguration); KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", equalityConfig, str); KieSession ksession = kbase.newKieSession(); @@ -1044,8 +1064,9 @@ public void setValue( String value ) { } } - @Test - public void testTypeCoercionLongDivByInt() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTypeCoercionLongDivByInt(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-5051 String str = "package com.sample\n" + "import " + Person.class.getCanonicalName() + ";\n" + @@ -1066,8 +1087,9 @@ public void testTypeCoercionLongDivByInt() { assertThat(p.getBigDecimal().round(MathContext.DECIMAL32)).isEqualTo(new BigDecimal(7.35d, MathContext.DECIMAL32)); } - @Test - public void testTypeCoercionIntCompareToDouble() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTypeCoercionIntCompareToDouble(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-2391 String str = "package com.sample\n" + "import " + IntFact.class.getCanonicalName() + ";\n" + @@ -1109,8 +1131,9 @@ public void setB(int b) { } } - @Test - public void testTypeCoercionFloatCompareToDouble() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTypeCoercionFloatCompareToDouble(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package com.sample\n" + "import " + FactA.class.getCanonicalName() + ";\n" + "rule R1\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MapConstraintTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MapConstraintTest.java index b4a479561c4..85707ece0aa 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MapConstraintTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MapConstraintTest.java @@ -19,10 +19,10 @@ package org.drools.mvel.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Stream; import org.drools.core.WorkingMemory; import org.drools.kiesession.audit.WorkingMemoryConsoleLogger; @@ -32,10 +32,9 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.Message; @@ -48,22 +47,15 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -@RunWith(Parameterized.class) public class MapConstraintTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public MapConstraintTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testMapAccess() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMapAccess(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_MapAccess.drl"); KieSession ksession = kbase.newKieSession(); @@ -83,8 +75,9 @@ public void testMapAccess() throws Exception { assertThat(list.contains(map)).isTrue(); } - @Test - public void testMapAccessWithVariable() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMapAccessWithVariable(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_MapAccessWithVariable.drl"); KieSession ksession = kbase.newKieSession(); @@ -106,8 +99,9 @@ public void testMapAccessWithVariable() throws Exception { } // Drools does not support variables inside bindings yet... but we should... - @Test - public void testMapAccessWithVariable2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMapAccessWithVariable2(KieBaseTestConfiguration kieBaseTestConfiguration) { final String str = "package org.drools.compiler;\n" + "import java.util.Map;\n" + "rule \"map access with variable\"\n" + @@ -123,8 +117,9 @@ public void testMapAccessWithVariable2() { assertThat(errors.isEmpty()).as("Should have an error").isFalse(); } - @Test - public void testMapNullConstraint() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMapNullConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_mapNullConstraints.drl"); KieSession ksession = kbase.newKieSession(); @@ -153,8 +148,9 @@ public void testMapNullConstraint() throws Exception { assertThat(aaf.getMatch().getRule().getName()).isEqualTo("8. not work != null"); } - @Test - public void testMapAccessorWithPrimitiveKey() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMapAccessorWithPrimitiveKey(KieBaseTestConfiguration kieBaseTestConfiguration) { final String str = "package com.sample\n" + "import " + MapContainerBean.class.getCanonicalName() + ";\n" + "rule R1 when\n" + @@ -200,8 +196,9 @@ public int get3() { } } - @Test - public void testMapModel() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMapModel(KieBaseTestConfiguration kieBaseTestConfiguration) { final String str = "package org.drools.compiler\n" + "import java.util.Map\n" + "rule \"test\"\n" + @@ -232,8 +229,9 @@ public void testMapModel() { assertThat(rules).isEqualTo(1); } - @Test - public void testListOfMaps() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testListOfMaps(KieBaseTestConfiguration kieBaseTestConfiguration) { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_TestMapVariableRef.drl"); KieSession ksession = kbase.newKieSession(); final List> list = new ArrayList<>(); @@ -252,8 +250,9 @@ public void testListOfMaps() { assertThat(list.size()).isEqualTo(3); } - @Test - public void testAccessingMapValues() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccessingMapValues(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String rule = ""; rule += "package org.drools.mvel.compiler;\n"; rule += "import org.drools.mvel.compiler.Pet;\n"; @@ -281,8 +280,9 @@ public void testAccessingMapValues() throws Exception { session.fireAllRules(); } - @Test - public void testMapOfMap() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMapOfMap(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-6599 final String str = "package org.drools.compiler\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MatchTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MatchTest.java index 8872bb9e49c..004df305da6 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MatchTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MatchTest.java @@ -19,39 +19,31 @@ package org.drools.mvel.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.core.rule.consequence.InternalMatch; import org.drools.mvel.compiler.Bar; import org.drools.mvel.compiler.Foo; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class MatchTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public MatchTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testGetObjectsOnePattern() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGetObjectsOnePattern(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1470 String str = "import org.drools.mvel.compiler.Foo\n" + @@ -92,8 +84,9 @@ public void testGetObjectsOnePattern() { ksession.dispose(); } - @Test - public void testGetObjectsTwoPatterns() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGetObjectsTwoPatterns(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1470 String str = "import org.drools.mvel.compiler.Foo\n" + @@ -136,8 +129,9 @@ public void testGetObjectsTwoPatterns() { ksession.dispose(); } - @Test - public void testGetObjectsAccumulateWithNoMatchingFacts() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGetObjectsAccumulateWithNoMatchingFacts(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1470 String drl = "global java.util.List list\n" + @@ -162,8 +156,9 @@ public void testGetObjectsAccumulateWithNoMatchingFacts() { ksession.dispose(); } - @Test - public void testGetObjectsExists() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGetObjectsExists(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1474 String str = "import org.drools.mvel.compiler.Foo\n" + @@ -210,8 +205,9 @@ public void testGetObjectsExists() { ksession.dispose(); } - @Test - public void testObjectsDeepOnNestedAccumulate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testObjectsDeepOnNestedAccumulate(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1686 String drl = "package testpkg;\n" + "global java.util.List list;\n" + @@ -240,8 +236,9 @@ public void testObjectsDeepOnNestedAccumulate() { assertThat(list.get(0)).isEqualTo(0.0); } - @Test - public void testObjectsDeepOnAccumulateWithoutReverse() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testObjectsDeepOnAccumulateWithoutReverse(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule = "package testpkg;\n" + "import " + CloudComputer.class.getCanonicalName() + "\n;" + @@ -310,8 +307,9 @@ public CloudComputer getComputer() { } } - @Test - public void testGetObjectsAccumulate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGetObjectsAccumulate(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1470 String str = "import org.drools.mvel.compiler.Foo\n" + @@ -358,8 +356,9 @@ public void testGetObjectsAccumulate() { ksession.dispose(); } - @Test - public void testGetObjectsAccumulateWithNestedExists() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGetObjectsAccumulateWithNestedExists(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1474 String str = "import org.drools.mvel.compiler.Foo\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MergePackageTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MergePackageTest.java index 9851873a485..e216dff968f 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MergePackageTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MergePackageTest.java @@ -21,37 +21,30 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.kiesession.rulebase.InternalKnowledgeBase; import org.drools.mvel.compiler.Cheese; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.definition.KiePackage; import org.kie.api.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -@RunWith(Parameterized.class) public class MergePackageTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public MergePackageTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testMergingDifferentPackages2() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMergingDifferentPackages2(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // using different builders try { Collection kpkgs1 = KieBaseUtil.getKieBaseFromClasspathResources("tmp", getClass(), kieBaseTestConfiguration, "test_RuleNameClashes1.drl").getKiePackages(); @@ -84,8 +77,9 @@ public void testMergingDifferentPackages2() throws Exception { } } - @Test - public void testMergePackageWithSameRuleNames() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMergePackageWithSameRuleNames(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { InternalKnowledgeBase kbase = (InternalKnowledgeBase) KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_MergePackageWithSameRuleNames1.drl"); Collection kpkgs = KieBaseUtil.getKieBaseFromClasspathResources("tmp", getClass(), kieBaseTestConfiguration, "test_MergePackageWithSameRuleNames2.drl").getKiePackages(); @@ -100,8 +94,9 @@ public void testMergePackageWithSameRuleNames() throws Exception { assertThat(results.get(0)).isEqualTo("rule1 for the package2"); } - @Test - public void testMergingDifferentPackages() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMergingDifferentPackages(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // using the same builder try { Collection kpkgs = KieBaseUtil.getKieBaseFromClasspathResources("tmp", getClass(), kieBaseTestConfiguration, "test_RuleNameClashes1.drl", "test_RuleNameClashes2.drl").getKiePackages(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MessageImplTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MessageImplTest.java index 3660cca0c43..db6c79d2f14 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MessageImplTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/MessageImplTest.java @@ -18,14 +18,13 @@ */ package org.drools.mvel.integrationtests; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -38,23 +37,16 @@ /** * Tests for MessageImpl */ -@RunWith(Parameterized.class) public class MessageImplTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public MessageImplTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") //See DROOLS-193 (KnowledgeBuilderResult does not always contain a Resource) - public void testMessageFromInvalidDSL() throws Exception { + public void testMessageFromInvalidDSL(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { //Some suitably duff DSL String dsl = "bananna\n"; @@ -78,8 +70,9 @@ public void testMessageFromInvalidDSL() throws Exception { assertThat(results.getMessages().size()).isEqualTo(3); } - @Test - public void testMessageWithIncrementalBuild() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMessageWithIncrementalBuild(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { //Some suitably duff DSL to generate errors String dsl1 = "bananna\n"; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/Misc2Test.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/Misc2Test.java index 980e59288cb..e1ebc19d961 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/Misc2Test.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/Misc2Test.java @@ -19,7 +19,6 @@ package org.drools.mvel.integrationtests; import java.io.Serializable; -import java.io.StringReader; import java.math.BigDecimal; import java.net.URL; import java.net.URLClassLoader; @@ -42,10 +41,10 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Stream; import org.drools.base.base.ValueResolver; import org.drools.compiler.builder.impl.KnowledgeBuilderConfigurationImpl; -import org.drools.compiler.builder.impl.KnowledgeBuilderImpl; import org.kie.api.runtime.ClassObjectFilter; import org.drools.base.InitialFact; import org.drools.base.base.ClassObjectType; @@ -55,10 +54,8 @@ import org.drools.core.common.InternalWorkingMemory; import org.drools.core.common.Memory; import org.drools.core.common.NodeMemories; -import org.drools.base.definitions.InternalKnowledgePackage; import org.drools.base.definitions.rule.impl.RuleImpl; import org.drools.core.impl.InternalRuleBase; -import org.drools.core.reteoo.CoreComponentFactory; import org.drools.core.reteoo.LeftInputAdapterNode; import org.drools.core.reteoo.ObjectTypeNode; import org.drools.core.reteoo.ObjectTypeNodeId; @@ -84,11 +81,11 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; @@ -141,25 +138,18 @@ /** * Run all the tests with the ReteOO engine implementation */ -@RunWith(Parameterized.class) public class Misc2Test { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public Misc2Test(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - // TODO: EM failed with some tests. File JIRAs - return TestParametersUtil.getKieBaseCloudConfigurations(false); + public static Stream parameters() { + // TODO: EM failed with some tests. File JIRAs + return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); } private static final Logger logger = LoggerFactory.getLogger( Misc2Test.class ); - @Test - public void testUpdateWithNonEffectiveActivations() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUpdateWithNonEffectiveActivations(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // JBRULES-3604 String str = "package inheritance\n" + "\n" + @@ -204,8 +194,9 @@ public void testUpdateWithNonEffectiveActivations() throws Exception { ksession.dispose(); } - @Test - public void testNPEOnMutableGlobal() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNPEOnMutableGlobal(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // BZ-1019473 String str = "package org.drools.mvel.compiler\n" + "global java.util.List context\n" + @@ -231,8 +222,9 @@ public void testNPEOnMutableGlobal() throws Exception { ksession.dispose(); } - @Test - public void testAnalyzeConditionWithVariableRegExp() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAnalyzeConditionWithVariableRegExp(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // JBRULES-3659 String str = "dialect \"mvel\"\n" + @@ -267,8 +259,9 @@ public void testAnalyzeConditionWithVariableRegExp() throws Exception { assertThat(ksession.fireAllRules()).isEqualTo(2); } - @Test - public void testShareAlphaNodesRegardlessDoubleOrSingleQuotes() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testShareAlphaNodesRegardlessDoubleOrSingleQuotes(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3640 String str = "declare RecordA\n" + @@ -316,8 +309,9 @@ public void testShareAlphaNodesRegardlessDoubleOrSingleQuotes() { assertThat(ksession.fireAllRules()).isEqualTo(4); } - @Test - public void testCorrectDeclarationsInConsequence() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCorrectDeclarationsInConsequence(KieBaseTestConfiguration kieBaseTestConfiguration) { // This showed up a bug where consequences declarations were being held onto and not replaced Address barcelonaCityCenter; @@ -408,8 +402,9 @@ private Address producePeopleInCity(final KieSession ksession, final String city return address; } - @Test - public void testEvalBeforeNot() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEvalBeforeNot(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package org.drools.mvel.compiler.integration; \n" + "import " + A.class.getCanonicalName() + ";\n" + @@ -438,8 +433,9 @@ public void testEvalBeforeNot() { ksession.fireAllRules(); } - @Test - public void testKnowledgeBaseEventSupportLeak() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKnowledgeBaseEventSupportLeak(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // JBRULES-3666 KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration); KieBaseEventListener listener = new DefaultKieBaseEventListener(); @@ -450,8 +446,9 @@ public void testKnowledgeBaseEventSupportLeak() throws Exception { assertThat(kbase.getKieBaseEventListeners().size()).isEqualTo(0); } - @Test - public void testReuseAgendaAfterException() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testReuseAgendaAfterException(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // JBRULES-3677 String str = "import org.drools.mvel.compiler.Person;\n" + @@ -536,8 +533,9 @@ public void afterRuleFlowGroupDeactivated( org.kie.api.event.rule.RuleFlowGroupD } - @Test - public void testBooleanPropertyStartingWithEmpty() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBooleanPropertyStartingWithEmpty(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3690 String str = "declare Fact\n" + @@ -553,8 +551,9 @@ public void testBooleanPropertyStartingWithEmpty() { KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, str); } - @Test - public void testMVELForLoop() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMVELForLoop(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // JBRULES-3717 String str = "rule demo\n" + "dialect \"mvel\"\n" + @@ -570,8 +569,9 @@ public void testMVELForLoop() throws Exception { assertThat(errors.isEmpty()).as(errors.toString()).isTrue(); } - @Test - public void testBigDecimalComparison() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBigDecimalComparison(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // JBRULES-3715 String str = "import org.drools.mvel.compiler.Person;\n" + "rule \"Big Decimal Comparison\"\n" + @@ -592,8 +592,10 @@ public void testBigDecimalComparison() throws Exception { ksession.dispose(); } - @Test(timeout = 5000) - public void testInfiniteLoopCausedByInheritance() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(5000) + public void testInfiniteLoopCausedByInheritance(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-13 String str = "declare Parent\n" + @@ -630,8 +632,9 @@ public void testInfiniteLoopCausedByInheritance() throws Exception { ksession.fireAllRules(); } - @Test - public void testIntSorting() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIntSorting(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-15 String str = "global java.util.List list\n" + @@ -662,8 +665,9 @@ public void testIntSorting() { assertThat(list).isEqualTo(asList(1, 2, 4, 5, 6)); } - @Test - public void testIntSorting2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIntSorting2(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-15 String str = "global java.util.List list\n" + @@ -696,8 +700,10 @@ public void testIntSorting2() { assertThat(list).isEqualTo(asList(7, 6, 5, 4, 3, 2, 1)); } - @Test(timeout = 10000) - public void testPropertyReactiveOnAlphaNodeFollowedByAccumulate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testPropertyReactiveOnAlphaNodeFollowedByAccumulate(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-16 String str = "package org.kie.pmml.pmml_4_1.test;\n" + @@ -767,8 +773,9 @@ public void testPropertyReactiveOnAlphaNodeFollowedByAccumulate() { assertThat(ksession.fireAllRules()).isEqualTo(3); } - @Test - public void testPropertyReactiveAccumulateModification() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPropertyReactiveAccumulateModification(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-16 String str = "package org.drools.mvel.compiler.test;\n" + @@ -835,8 +842,9 @@ public void testPropertyReactiveAccumulateModification() { assertThat(ksession.getQueryResults("getNeuron").iterator().next().get("$value")).isEqualTo(2.0); } - @Test - public void testMvelAssignmentToPublicField() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMvelAssignmentToPublicField(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import " + Misc2Test.Foo.class.getCanonicalName() + "\n" + "rule R\n" + @@ -859,8 +867,9 @@ public void testMvelAssignmentToPublicField() { assertThat(foo2.x).isEqualTo(1); } - @Test - public void testMvelInvokeAsList() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMvelInvokeAsList(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import java.util.List;\n" + "import java.util.Arrays;\n" + @@ -897,8 +906,9 @@ public void testMvelInvokeAsList() { ksession.fireAllRules(); } - @Test - public void testDynamicAddRule() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDynamicAddRule(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-17 String str = "import " + Misc2Test.A.class.getCanonicalName() + "\n" + @@ -1008,8 +1018,9 @@ public String toString() { } } - @Test - public void testNumberCoercionOnNonGenericMap() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNumberCoercionOnNonGenericMap(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3708 String str = "package com.ilesteban.jit;\n" + @@ -1050,8 +1061,9 @@ public void testNumberCoercionOnNonGenericMap() { assertThat(ksession.fireAllRules()).isEqualTo(2); } - @Test - public void testPropertyReactivityWithNestedAccessorsInModify() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPropertyReactivityWithNestedAccessorsInModify(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3691 String str = "package com.ilesteban.rulenotbeingfired;\n" + @@ -1122,8 +1134,9 @@ public boolean isNotEmpty() { } } - @Test - public void testMvelResolvingGenericVariableDeclaredInParentClass() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMvelResolvingGenericVariableDeclaredInParentClass(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3684 String str = "import " + Misc2Test.AbstractBase.class.getCanonicalName() + "\n" + @@ -1153,8 +1166,9 @@ public StringConcrete() { } } - @Test - public void testMvelParsingParenthesisInString() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMvelParsingParenthesisInString(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3698 String str = "rule \"Test Rule\"\n" + @@ -1175,8 +1189,9 @@ public Answer getAnswer() { } } - @Test - public void testCompilationMustFailComparingAClassLiteral() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCompilationMustFailComparingAClassLiteral(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-20 String str = "import Misc2Test.Answer\n" + @@ -1192,8 +1207,9 @@ public void testCompilationMustFailComparingAClassLiteral() { assertThat(errors.isEmpty()).as("Should have an error").isFalse(); } - @Test - public void testDeclaredTypeExtendingInnerClass() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclaredTypeExtendingInnerClass(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-27 String str = "import " + Misc2Test.StaticPerson.class.getCanonicalName() + "\n" + @@ -1227,8 +1243,9 @@ public void setName( String name ) { } } - @Test - public void testAllowEqualityBetweenObjectAndPrimitiveInt() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAllowEqualityBetweenObjectAndPrimitiveInt(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-20 String str = "declare Bean\n" + @@ -1257,8 +1274,9 @@ public void testAllowEqualityBetweenObjectAndPrimitiveInt() { assertThat(ksession.fireAllRules()).isEqualTo(1); } - @Test - public void testJitConstraintWithOperationOnBigDecimal() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJitConstraintWithOperationOnBigDecimal(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-32 String str = "import " + Misc2Test.Model.class.getCanonicalName() + "\n" + @@ -1306,8 +1324,9 @@ public void setPrice( BigDecimal price ) { } } - @Test - public void testJitComparable() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJitComparable(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-37 String str = "import " + Misc2Test.IntegerWrapperImpl.class.getCanonicalName() + "\n" + @@ -1351,8 +1370,9 @@ public int getInt() { } } - @Test - public void testJitComparableNoGeneric() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJitComparableNoGeneric(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-37 BZ-1233976 String str = "import " + ComparableInteger.class.getCanonicalName() + "\n" + @@ -1389,8 +1409,9 @@ public int getInt() { } } - @Test - public void testJitComparable2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJitComparable2(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-469 String str = "import " + Misc2Test.IntegerWrapperImpl2.class.getCanonicalName() + "\n" + @@ -1434,8 +1455,9 @@ public int getInt() { } } - @Test - public void testEqualityOfDifferentTypes() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEqualityOfDifferentTypes(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-42 String str = "declare Person\n" + @@ -1471,8 +1493,9 @@ public void testEqualityOfDifferentTypes() { ksession.fireAllRules(); } - @Test - public void testUnificationInRule() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUnificationInRule(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-45 String str = "declare A\n" + @@ -1502,8 +1525,9 @@ public void testUnificationInRule() { assertThat(ksession.fireAllRules()).isEqualTo(2); } - @Test - public void testDeclarationsScopeUsingOR() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclarationsScopeUsingOR(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-44 String str = "declare A\n" + @@ -1540,8 +1564,9 @@ public void testDeclarationsScopeUsingOR() { assertThat(ksession.fireAllRules()).isEqualTo(2); } - @Test - public void testDeclarationsScopeUsingOR2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclarationsScopeUsingOR2(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-44 String str = "declare A\n" + @@ -1574,8 +1599,9 @@ public void testDeclarationsScopeUsingOR2() { assertThat(ksession.fireAllRules()).isEqualTo(2); } - @Test - public void testDeclarationsScopeUsingOR3() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclarationsScopeUsingOR3(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-44 String str = "declare A\n" + @@ -1614,8 +1640,9 @@ public void testDeclarationsScopeUsingOR3() { assertThat(ksession.fireAllRules()).isEqualTo(3); } - @Test - public void testDeclarationsScopeUsingOR4() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclarationsScopeUsingOR4(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-44 String str = "declare A\n" + @@ -1646,8 +1673,9 @@ public void testDeclarationsScopeUsingOR4() { assertThat(errors.isEmpty()).as("Should have an error").isFalse(); } - @Test - public void testQueryAfterEvalInsideOR() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryAfterEvalInsideOR(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-54 String str = "package pakko\n" + @@ -1687,8 +1715,9 @@ public void testQueryAfterEvalInsideOR() { assertThat(ksession.fireAllRules()).isEqualTo(2); } - @Test - public void testPackageVisibility() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPackageVisibility(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-61 String str = "package org.drools.integrationtests;\n" + @@ -1704,8 +1733,9 @@ public void testPackageVisibility() { assertThat(errors.isEmpty()).as("Should have an error").isFalse(); } - @Test - public void testNullValueInFrom() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNullValueInFrom(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-71 String str = "global java.util.List list\n" + @@ -1729,8 +1759,9 @@ public void testNullValueInFrom() { ksession.fireAllRules(); } - @Test - public void testNumberInQuotes() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNumberInQuotes(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-68 String str = "declare A\n" + @@ -1759,8 +1790,9 @@ public void testNumberInQuotes() throws Exception { assertThat(ksession.fireAllRules()).isEqualTo(2); } - @Test - public void testStringCoercionComparison() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testStringCoercionComparison(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-167 String str = "import " + Person.class.getName() + ";\n" + "rule R1 when\n" + @@ -1774,8 +1806,9 @@ public void testStringCoercionComparison() { assertThat(ksession.fireAllRules()).isEqualTo(1); } - @Test - public void testAvoidUnwantedSemicolonWhenDelimitingExpression() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAvoidUnwantedSemicolonWhenDelimitingExpression(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-86 String str = "global java.util.List l\n" + @@ -1798,8 +1831,9 @@ public void testAvoidUnwantedSemicolonWhenDelimitingExpression() { assertThat(l.get(0)).isEqualTo("http://onefineday.123"); } - @Test - public void testJitCastOfPrimitiveType() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJitCastOfPrimitiveType(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-79 String str = "rule R when\n" + @@ -1815,8 +1849,9 @@ public void testJitCastOfPrimitiveType() { } - @Test - public void testSelfChangingRuleSet() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSelfChangingRuleSet(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-92 String str = "package org.drools.mvel.integrationtests;\n" + @@ -1886,8 +1921,9 @@ public void testSelfChangingRuleSet() { } - @Test - public void testMatchIntegers() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMatchIntegers(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-94 String str = "global java.util.List list; \n" + @@ -1929,8 +1965,9 @@ public void setDuration( long duration ) { } } - @Test - public void testDurationAnnotation() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDurationAnnotation(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-94 String str = "package org.drools.mvel.integrationtests;\n" + @@ -1944,8 +1981,9 @@ public void testDurationAnnotation() { KieSession ksession = kbase.newKieSession(); } - @Test - public void testDurationAnnotationOnKie() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDurationAnnotationOnKie(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-94 String str = "package org.drools.mvel.integrationtests;\n" + @@ -1959,8 +1997,9 @@ public void testDurationAnnotationOnKie() { KieSession ksession = kbase.newKieSession(); } - @Test - public void testDurationAnnotationWithError() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDurationAnnotationWithError(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-94 String str = "package org.drools.mvel.integrationtests;\n" + @@ -1975,8 +2014,9 @@ public void testDurationAnnotationWithError() { assertThat(errors.isEmpty()).as("Should have an error").isFalse(); } - @Test - public void testPhreakWithConcurrentUpdates() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPhreakWithConcurrentUpdates(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-7 String str = "import " + Person.class.getCanonicalName() + "\n" + @@ -2028,8 +2068,9 @@ public void testPhreakWithConcurrentUpdates() { assertThat(ksession.fireAllRules()).isEqualTo(0); } - @Test - public void testPhreakWith2Nots() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPhreakWith2Nots(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-7 String str = "import " + Person.class.getCanonicalName() + "\n" + @@ -2072,8 +2113,9 @@ public void testPhreakWith2Nots() { assertThat((int) list.get(0)).isEqualTo(31); } - @Test - public void testPhreakTMS() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPhreakTMS(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-7 String str = "import " + Person.class.getCanonicalName() + "\n" + @@ -2103,8 +2145,9 @@ public void testPhreakTMS() { assertThat(ksession.getObjects(new ClassObjectFilter( Cheese.class )).size()).isEqualTo(1); } - @Test - public void testHelloWorld() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testHelloWorld(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-145 String drl = "package org.drools.test\n" + "declare Message\n" + @@ -2194,8 +2237,9 @@ public String toString() { } } - @Test - public void testPhreakInnerJoinNot() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPhreakInnerJoinNot(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-7 String str = "import org.drools.mvel.integrationtests.Misc2Test.Lecture\n" + @@ -2246,8 +2290,9 @@ public void testPhreakInnerJoinNot() { assertThat(list.contains("B")).isTrue(); } - @Test - public void testPhreakAccumulate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPhreakAccumulate(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-7 String str = "import org.drools.mvel.integrationtests.Misc2Test.Lecture\n" + @@ -2304,8 +2349,9 @@ public void testPhreakAccumulate() { list.clear(); } - @Test - public void testQueryAndRetract() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryAndRetract(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-7 String str = "global java.util.List list\n" + @@ -2340,8 +2386,10 @@ public void onDeleteMatch( Match match ) { assertThat(list.size()).isEqualTo(1); } - @Test(timeout = 5000) - public void testPhreakNoLoop() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(5000) + public void testPhreakNoLoop(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-7 String str = "declare Person \n" + @@ -2367,8 +2415,9 @@ public void testPhreakNoLoop() { assertThat(ksession.fireAllRules()).isEqualTo(2); } - @Test - public void testAddSameResourceTwice() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAddSameResourceTwice(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-180 String str = "rule R when\n" + @@ -2381,8 +2430,9 @@ public void testAddSameResourceTwice() { assertThat(messages.isEmpty()).as("Should have any message").isFalse(); // Duplicate rule name } - @Test - public void testTwoTimers() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTwoTimers(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-980385 String str = "import java.util.Date\n" + @@ -2419,8 +2469,9 @@ public void testTwoTimers() { KieSession ksession = ks.newKieContainer( ks.getRepository().getDefaultReleaseId() ).newKieSession(); } - @Test - public void testUnsupportedPolymorphicDeclaration() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUnsupportedPolymorphicDeclaration(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-162 String drl = "package org.drools.test; \n" + "" + @@ -2447,8 +2498,9 @@ public void testUnsupportedPolymorphicDeclaration() { assertThat(errors.isEmpty()).as("Should have an error").isFalse(); } - @Test - public void testUnaryNegation() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUnaryNegation(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-177 String str = "rule R when\n" + @@ -2506,8 +2558,9 @@ public String toString() { } } - @Test - public void testNotNodeUpdateBlocker() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNotNodeUpdateBlocker(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.integrationtests.Misc2Test.Conversation;\n" + "global java.util.List list;" + @@ -2564,8 +2617,9 @@ public void testNotNodeUpdateBlocker() { assertThat(conversations.size()).isEqualTo(1); } - @Test - public void testFailedStaticImport() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFailedStaticImport(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-155 String drl = "package org.drools.test; \n" + "" + @@ -2580,8 +2634,9 @@ public void testFailedStaticImport() { assertThat(errors.isEmpty()).as("Should have an error").isFalse(); } - @Test - public void testNamedConsequence() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNamedConsequence(KieBaseTestConfiguration kieBaseTestConfiguration) { List firedRules = new ArrayList<>(); String str = "import " + Foo.class.getCanonicalName() + "\n" + @@ -2611,8 +2666,9 @@ public void testNamedConsequence() { assertThat(firedRules.size()).isEqualTo(1); } - @Test - public void testNamedConsequenceWithNot() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNamedConsequenceWithNot(KieBaseTestConfiguration kieBaseTestConfiguration) { List firedRules = new ArrayList<>(); String str = "import " + Foo.class.getCanonicalName() + "\n" + @@ -2674,8 +2730,9 @@ public void setX( int x ) { } } - @Test - public void testBetaNodeInSubnetworkInStreamMode() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBetaNodeInSubnetworkInStreamMode(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-995408 String str = "import " + Foo.class.getCanonicalName() + "\n" + @@ -2694,7 +2751,7 @@ public void testBetaNodeInSubnetworkInStreamMode() { " $f.setX( 2 );\n" + "end"; - KieBaseTestConfiguration streamConfig = TestParametersUtil.getStreamInstanceOf(kieBaseTestConfiguration); + KieBaseTestConfiguration streamConfig = TestParametersUtil2.getStreamInstanceOf(kieBaseTestConfiguration); KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", streamConfig, str); KieSession ksession = kbase.newKieSession(); @@ -2710,8 +2767,9 @@ public void testBetaNodeInSubnetworkInStreamMode() { assertThat(foo.getX()).isEqualTo(2); } - @Test - public void testAutomaticallySwitchFromReteOOToPhreak() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAutomaticallySwitchFromReteOOToPhreak(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "rule R when then end\n"; KieServices ks = KieServices.Factory.get(); @@ -2724,8 +2782,9 @@ public void testAutomaticallySwitchFromReteOOToPhreak() { ksession.fireAllRules(); } - @Test - public void testListnersOnStatlessKieSession() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testListnersOnStatlessKieSession(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-141 // BZ-999491 String str = @@ -2786,8 +2845,9 @@ public void afterRuleFlowGroupDeactivated( org.kie.api.event.rule.RuleFlowGroupD assertThat(firings.size()).isEqualTo(2); } - @Test - public void testImportExceptional() throws java.lang.Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testImportExceptional(KieBaseTestConfiguration kieBaseTestConfiguration) throws java.lang.Exception { // DROOLS-253 imported Exception would have qualified as the default Exception thrown by the RHS String str = "import org.acme.healthcare.Exception;\n" + @@ -2811,8 +2871,9 @@ public void testImportExceptional() throws java.lang.Exception { assertThat(list).isEqualTo(List.of(1)); } - @Test - public void testMapAccessorWithCustomOp() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMapAccessorWithCustomOp(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-216 String str = "import java.util.Map;\n" + @@ -2838,8 +2899,9 @@ public void testMapAccessorWithCustomOp() { assertThat(list).isEqualTo(List.of(1)); } - @Test - public void testMapAccessorWithBoundVar() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMapAccessorWithBoundVar(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-217 String str = "import java.util.Map;\n" + @@ -2865,8 +2927,10 @@ public void testMapAccessorWithBoundVar() { assertThat(list).isEqualTo(List.of(1)); } - @Test(timeout = 10000) - public void testAgendaGroupSalience() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testAgendaGroupSalience(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-999360 String str = "global java.util.List ruleList\n" + @@ -2910,8 +2974,9 @@ public void testAgendaGroupSalience() { assertThat("third").isEqualTo(ruleList.get(2)); } - @Test - public void test3IdenticalForall() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void test3IdenticalForall(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-999851 String str = "rule \"Rule with forall_1\"\n" + @@ -2943,8 +3008,9 @@ public void test3IdenticalForall() { ksession.fireAllRules(); } - @Test - public void testSegmentInitialization() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSegmentInitialization(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-1011993 String str = "import " + Misc2Test.Resource.class.getCanonicalName() + "\n" + @@ -3013,8 +3079,9 @@ public int getExecutionMode() { } } - @Test - public void testReportErrorOnWrongDateEffective() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testReportErrorOnWrongDateEffective(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-1013545 String drl = // ensure no Locale can parse the Date @@ -3028,8 +3095,9 @@ public void testReportErrorOnWrongDateEffective() { assertThat(errors.isEmpty()).as("Should have an error").isFalse(); } - @Test - public void testDeleteInFromNode() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeleteInFromNode(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "global java.util.Map context\n" + "\n" + @@ -3062,8 +3130,9 @@ public void testDeleteInFromNode() { ks.fireAllRules(); } - @Test - public void testSortWithNot() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSortWithNot(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-200 String str = "import java.util.*; \n" + @@ -3111,8 +3180,9 @@ public void testSortWithNot() { assertThat(list).isEqualTo(Arrays.asList(50, 40, 30, 20, 10)); } - @Test - public void testExistsOr() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExistsOr(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-254 String drl = "package org.drools.test;\n" + "\n" + @@ -3172,8 +3242,9 @@ public void testExistsOr() { } - @Test - public void testFactLeak() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFactLeak(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { //DROOLS-131 String drl = "package org.drools.test; \n" + "global java.util.List list; \n" + @@ -3205,8 +3276,9 @@ public void testFactLeak() throws InterruptedException { } } - @Test - public void testFactStealing() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFactStealing(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drl = "package org.drools.test; \n" + "import org.drools.mvel.compiler.Person; \n " + "global java.util.List list; \n" + @@ -3272,8 +3344,9 @@ public SQLTimestamped() { } } - @Test - public void testEventWithSQLTimestamp() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEventWithSQLTimestamp(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { // DROOLS-10 String str = "import org.drools.mvel.integrationtests.Misc2Test.SQLTimestamped;\n" + @@ -3327,8 +3400,9 @@ public boolean isZ() { } } - @Test - public void testIsGetClash() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIsGetClash(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-18 String str = "import org.drools.mvel.integrationtests.Misc2Test.Foo3;\n" + @@ -3350,8 +3424,9 @@ public void testIsGetClash() { assertThat(errors.size()).isEqualTo(2); } - @Test - public void testCollectAccumulate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCollectAccumulate(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-173 String drl = "import java.util.ArrayList\n" + "\n" + @@ -3483,8 +3558,9 @@ public int hashCode() { } } - @Test - public void testLockOnActive1() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLockOnActive1(KieBaseTestConfiguration kieBaseTestConfiguration) { // the modify changes the hashcode of TradeHeader // this forces the 'from' to think it's new. This results in an insert and a delete propagation from the 'from' // With Property Reactivity enabled by default this also required adding a @watch(*) annotation @@ -3556,8 +3632,9 @@ public void afterMatchFired( AfterMatchFiredEvent event ) { assertThat(fired.get(0)).isEqualTo("Rule1"); } - @Test - public void testLockOnActive2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLockOnActive2(KieBaseTestConfiguration kieBaseTestConfiguration) { // the modify changes the hashcode of TradeHeader // this forces the 'from' to think it's new. This results in an insert and a delete propagation from the 'from' // With Property Reactivity enabled by default this also required adding a @watch(*) annotation @@ -3624,8 +3701,9 @@ public void afterMatchFired( AfterMatchFiredEvent event ) { assertThat(fired.get(1)).isEqualTo("Rule2"); } - @Test - public void testLockOnActiveWithModify() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLockOnActiveWithModify(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "" + "package org.drools.test; \n" + "import org.drools.mvel.compiler.Person; \n" + @@ -3665,8 +3743,9 @@ public void testLockOnActiveWithModify() { assertThat(p.getName()).isEqualTo("john"); } - @Test - public void testLockOnActiveWithModifyNoEager() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLockOnActiveWithModifyNoEager(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-280 String drl = "" + "package org.drools.test; \n" + @@ -3705,8 +3784,9 @@ public void testLockOnActiveWithModifyNoEager() { assertThat(p.getName()).isEqualTo("john"); } - @Test - public void testPrimitiveGlobals() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPrimitiveGlobals(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "package org.drools.mvel.integrationtests\n" + "\n" + "global int foo;\n" + @@ -3719,8 +3799,9 @@ public void testPrimitiveGlobals() { } - @Test - public void testClashingRules() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testClashingRules(KieBaseTestConfiguration kieBaseTestConfiguration) { //DROOLS-287 String drl = "package org.drools.test; \n" + "" + @@ -3733,8 +3814,9 @@ public void testClashingRules() { KieBase kb = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, drl); } - @Test - public void testDontFailOnDuplicatedRuleWithDeclaredTypeError() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDontFailOnDuplicatedRuleWithDeclaredTypeError(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "rule \"Some Rule\"\n" + "when\n" + @@ -3760,8 +3842,9 @@ public void testDontFailOnDuplicatedRuleWithDeclaredTypeError() { } - @Test - public void testBindingComplexExpression() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBindingComplexExpression(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-43 String drl = "package org.drools.test;\n" + "\n" + @@ -3804,8 +3887,9 @@ public void testBindingComplexExpression() { } - @Test - public void testBindingComplexExpressionWithDRL5() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBindingComplexExpressionWithDRL5(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-43 String drl = "package org.drools.test;\n" + "\n" + @@ -3846,8 +3930,9 @@ public void testBindingComplexExpressionWithDRL5() { } - @Test - public void testEvalConstraintWithMvelOperator() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEvalConstraintWithMvelOperator(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "rule \"yeah\" " + "\tdialect \"mvel\"\n when " + "Foo( eval( field soundslike \"water\" ) )" + " then " + "end"; DrlParser drlParser = new DrlParser(); @@ -3862,8 +3947,9 @@ public void testEvalConstraintWithMvelOperator() { assertThat(pd.getConstraint().getDescrs().size()).isEqualTo(1); } - @Test - public void testManyAccumulatesWithSubnetworks() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testManyAccumulatesWithSubnetworks(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "package org.drools.mvel.compiler.tests; \n" + "" + "declare FunctionResult\n" + @@ -3924,8 +4010,9 @@ public void testManyAccumulatesWithSubnetworks() { } - @Test - public void testLinkRiaNodesWithSubSubNetworks() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLinkRiaNodesWithSubSubNetworks(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "package org.drools.mvel.compiler.tests; \n" + "" + "import java.util.*; \n" + @@ -3981,8 +4068,9 @@ public void testLinkRiaNodesWithSubSubNetworks() { } - @Test - public void testDynamicSalienceUpdate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDynamicSalienceUpdate(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "package org.drools.mvel.compiler.tests; \n" + "" + "import java.util.*; \n" + @@ -4035,8 +4123,9 @@ public void testDynamicSalienceUpdate() { ksession.dispose(); } - @Test - public void testInitialFactLeaking() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInitialFactLeaking(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-239 String drl = "global java.util.List list;\n" + "rule R when\n" + @@ -4065,8 +4154,9 @@ public void testInitialFactLeaking() { ksession.dispose(); } - @Test - public void testNoLoopWithNamedConsequences() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNoLoopWithNamedConsequences(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-327 String drl = "import " + Message.class.getCanonicalName() + "\n" + @@ -4090,8 +4180,9 @@ public void testNoLoopWithNamedConsequences() { ksession.fireAllRules(); } - @Test - public void testInsertModifyInteractionsWithLockOnActive() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInsertModifyInteractionsWithLockOnActive(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "package org.drools.mvel.integrationtests;\n" + "import org.drools.mvel.compiler.Message;\n" + @@ -4130,8 +4221,10 @@ public void testInsertModifyInteractionsWithLockOnActive() { assertThat(m2.getMessage3()).isEqualTo("Three"); } - @Test(timeout = 10000) - public void testWumpus1() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testWumpus1(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "import org.drools.mvel.integrationtests.Misc2Test.Hero;\n" + "import org.drools.mvel.integrationtests.Misc2Test.StepForwardCommand;\n" + "global java.util.List list; \n " + @@ -4168,8 +4261,10 @@ public void testWumpus1() { assertThat(hero.getPos()).isEqualTo(2); } - @Test(timeout = 10000) - public void testWumpus2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testWumpus2(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "import org.drools.mvel.integrationtests.Misc2Test.Hero;\n" + "import org.drools.mvel.integrationtests.Misc2Test.StepForwardCommand;\n" + "import org.drools.mvel.integrationtests.Misc2Test.ChangeDirectionCommand;\n" + @@ -4207,8 +4302,10 @@ public void testWumpus2() { assertThat(hero.getPos()).isEqualTo(2); } - @Test(timeout = 10000) - public void testWumpus3() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testWumpus3(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "import org.drools.mvel.integrationtests.Misc2Test.Hero;\n" + "import org.drools.mvel.integrationtests.Misc2Test.StepForwardCommand;\n" + "import org.drools.mvel.integrationtests.Misc2Test.ChangeDirectionCommand;\n" + @@ -4263,8 +4360,10 @@ public void testWumpus3() { assertThat(hero.getPos()).isEqualTo(1); } - @Test(timeout = 10000) - public void testWumpus4() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testWumpus4(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "import org.drools.mvel.integrationtests.Misc2Test.Hero;\n" + "import org.drools.mvel.integrationtests.Misc2Test.StepForwardCommand;\n" + "import org.drools.mvel.integrationtests.Misc2Test.ChangeDirectionCommand;\n" + @@ -4353,8 +4452,9 @@ public static class ChangeDirectionCommand { public static class StepForwardCommand { } - @Test - public void testDynamicSalience() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDynamicSalience(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-334 String drl = "import org.drools.mvel.integrationtests.Misc2Test.SimpleMessage\n" + "\n" + @@ -4421,8 +4521,9 @@ public String toString() { } } - @Test - public void testCollectAndAccumulate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCollectAndAccumulate(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-173 String drl = "import java.util.List\n" + "\n" + @@ -4486,8 +4587,9 @@ public void testCollectAndAccumulate() { assertThat(list.get(3)).isEqualTo(3); } - @Test - public void testMatchingEventsInStreamMode() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMatchingEventsInStreamMode(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-338 String drl = "import org.drools.mvel.integrationtests.Misc2Test.SimpleEvent\n" + @@ -4509,7 +4611,7 @@ public void testMatchingEventsInStreamMode() { "then\n" + "end\n"; - KieBaseTestConfiguration streamConfig = TestParametersUtil.getStreamInstanceOf(kieBaseTestConfiguration); + KieBaseTestConfiguration streamConfig = TestParametersUtil2.getStreamInstanceOf(kieBaseTestConfiguration); KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", streamConfig, drl); KieSession ksession = kbase.newKieSession(); @@ -4531,8 +4633,9 @@ public void matchCancelled( MatchCancelledEvent event ) { assertThat(i.get()).isEqualTo(1); } - @Test - public void testRuleDoesNotRefireOnNewSession() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRuleDoesNotRefireOnNewSession(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-339 String drl = "\n" + "global java.util.List list\n" + @@ -4580,8 +4683,9 @@ public void testRuleDoesNotRefireOnNewSession() { ksession.dispose(); } - @Test - public void testWildcardImportForTypeField() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testWildcardImportForTypeField(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-348 String drl = "import java.util.*\n" + "declare MyType\n" + @@ -4594,8 +4698,9 @@ public void testWildcardImportForTypeField() throws Exception { KieSession ksession = ks.newKieContainer( ks.getRepository().getDefaultReleaseId() ).newKieSession(); } - @Test - public void testWildcardImportForTypeFieldOldApi() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testWildcardImportForTypeFieldOldApi(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-348 String drl = "import java.util.*\n" + "declare MyType\n" + @@ -4606,8 +4711,9 @@ public void testWildcardImportForTypeFieldOldApi() { KieSession ksession = kbase.newKieSession(); } - @Test - public void testTypeCheckInOr() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTypeCheckInOr(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-1029911 String str = "import org.drools.mvel.compiler.*;\n" + "import java.util.*;\n" + @@ -4629,8 +4735,9 @@ public void testTypeCheckInOr() { ksession.fireAllRules(); } - @Test - public void testDynamicNegativeSalienceWithSpace() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDynamicNegativeSalienceWithSpace(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-302 String str = "import " + Person.class.getCanonicalName() + "\n" + @@ -4650,8 +4757,9 @@ public void testDynamicNegativeSalienceWithSpace() { ksession.fireAllRules(); } - @Test - public void testJoinNoLoop() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJoinNoLoop(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-1034094 String str = "import " + Person.class.getCanonicalName() + "\n" + @@ -4676,8 +4784,9 @@ public void testJoinNoLoop() { assertThat(mario.getAge()).isEqualTo(40); } - @Test - public void testConstraintOnSerializable() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testConstraintOnSerializable(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-372 String str = "import org.drools.mvel.integrationtests.Misc2Test.SerializableValue\n" + @@ -4706,8 +4815,10 @@ public Serializable getValue() { } } - @Test(timeout = 10000) - public void testInfiniteLoopUpdatingWithRBTreeIndexing() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testInfiniteLoopUpdatingWithRBTreeIndexing(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-1040032 String drl = "import " + Person.class.getCanonicalName() + "\n" + @@ -4784,9 +4895,10 @@ public Integer getValue() { } } - @Test - @Ignore - public void testJitting() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Disabled + public void testJitting(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-185 String str = " import org.drools.mvel.integrationtests.Misc2Test.AA; " + @@ -4816,8 +4928,9 @@ public void testJitting() { assertThat(list.size()).isEqualTo(100); } - @Test - public void testQueryCorruption() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryCorruption(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "package drl;\n" + @@ -4869,8 +4982,9 @@ public void testQueryCorruption() { } - @Test - public void testPackagingJarWithTypeDeclarations() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPackagingJarWithTypeDeclarations(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // BZ-1054823 String drl1 = "package org.drools.compiler\n" + @@ -4896,8 +5010,9 @@ public void testPackagingJarWithTypeDeclarations() throws Exception { ksession.fireAllRules(); } - @Test - public void testJittingConstraintWithArrayParams() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJittingConstraintWithArrayParams(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // BZ-1057000 String str = "import org.drools.mvel.integrationtests.Misc2Test.Strings\n" + @@ -4977,8 +5092,9 @@ public static int getSize( String s ) { } } - @Test - public void testJittingConstraintInvokingStaticMethod() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJittingConstraintInvokingStaticMethod(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-410 String str = "dialect \"mvel\"\n" + @@ -5041,8 +5157,9 @@ public int getSize() { } } - @Test - public void testGlobalInConstraint() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGlobalInConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "global " + Evaller.class.getCanonicalName() + " evaller;\n" + "global java.util.List list;\n" + @@ -5072,8 +5189,9 @@ public void testGlobalInConstraint() throws Exception { assertThat((int) list.get(0)).isEqualTo(42); } - @Test - public void testStaticInConstraint() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testStaticInConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "import " + Evaller.class.getCanonicalName() + ";\n" + "global java.util.List list;\n" + @@ -5102,8 +5220,9 @@ public void testStaticInConstraint() throws Exception { assertThat((int) list.get(0)).isEqualTo(42); } - @Test - public void testFieldPrecedenceOverGlobal() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFieldPrecedenceOverGlobal(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "import " + EvallerBean.class.getCanonicalName() + ";\n" + "global " + Evaller.class.getCanonicalName() + " evaller;\n" + @@ -5128,8 +5247,9 @@ public void testFieldPrecedenceOverGlobal() throws Exception { assertThat((int) list.get(0)).isEqualTo(42); } - @Test - public void testFieldPrecedenceOverDeclaration() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFieldPrecedenceOverDeclaration(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "import " + Evaller.class.getCanonicalName() + ";\n" + "import " + EvallerBean.class.getCanonicalName() + ";\n" + @@ -5155,8 +5275,9 @@ public void testFieldPrecedenceOverDeclaration() throws Exception { assertThat((int) list.get(0)).isEqualTo(42); } - @Test - public void testContainsOnString() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testContainsOnString(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-388 String str = "global java.util.List list;\n" + @@ -5182,8 +5303,9 @@ public void testContainsOnString() { } - @Test - public void testFunctionJitting() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFunctionJitting(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-404 String str = "global java.util.List list;\n" + @@ -5207,8 +5329,9 @@ public void testFunctionJitting() { assertThat(list.size()).isEqualTo(1); } - @Test - public void testGlobalExtractor() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGlobalExtractor(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package org.test; " + "import java.util.*; " + @@ -5240,8 +5363,9 @@ public void testGlobalExtractor() { assertThat(list.size()).isEqualTo(1); } - @Test - public void testSharedNotWithLeftUpdateAndRightInsert() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSharedNotWithLeftUpdateAndRightInsert(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // BZ-1070092 String str = "import " + Foo.class.getCanonicalName() + ";\n" + @@ -5272,8 +5396,9 @@ public void testSharedNotWithLeftUpdateAndRightInsert() throws Exception { assertThat(f2.getX()).isEqualTo(3); } - @Test - public void testNestedNots1() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNestedNots1(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-444 String str = "package org.test; " + @@ -5323,8 +5448,9 @@ public void testNestedNots1() { assertThat(n).isEqualTo(7); } - @Test - public void testNestedNots2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNestedNots2(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-444 String str = "package org.test; " + @@ -5381,8 +5507,9 @@ public void testNestedNots2() { assertThat(n).isEqualTo(8); } - @Test - public void testNestedNots3() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNestedNots3(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-444 String str = "package org.test; " + @@ -5402,8 +5529,9 @@ public void testNestedNots3() { assertThat(n).isEqualTo(1); } - @Test - public void testExtendingDate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExtendingDate(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-1072629 String str = "import " + MyDate.class.getCanonicalName() + " \n" + "rule 'sample rule' \n" @@ -5427,8 +5555,9 @@ public void setDescription( final String desc ) { } } - @Test - public void testEvalInSubnetwork() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEvalInSubnetwork(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-460 String str = "global java.util.List list;\n" + "\n" + @@ -5463,16 +5592,18 @@ public void testEvalInSubnetwork() { assertThat((int) list.get(0)).isEqualTo(0); } - @Test - public void testRedeclaringRuleAttribute() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRedeclaringRuleAttribute(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-1092084 String str = "rule R salience 10 salience 100 when then end\n"; assertDrlHasCompilationError( str, 1, kieBaseTestConfiguration ); } - @Test - public void testMultilineStatement() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMultilineStatement(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-1092502 String str = "rule \"test\"\n" + "dialect \"mvel\"\n" + @@ -5488,8 +5619,9 @@ public void testMultilineStatement() { assertThat(messages.isEmpty()).as(messages.toString()).isTrue(); } - @Test - public void testExtendsWithStrictModeOff() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExtendsWithStrictModeOff(KieBaseTestConfiguration kieBaseTestConfiguration) { // not for exec-model test. Cannot change DialectConfiguration by kieModuleConfigurationProperties // DROOLS-475 String str = @@ -5545,8 +5677,9 @@ public void testExtendsWithStrictModeOff() { assertThat(kbuilder.hasErrors()).isFalse(); } - @Test - public void testCompilationFailureWithDuplicatedAnnotation() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCompilationFailureWithDuplicatedAnnotation(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-1099896 String str = "declare EventA\n" + " @role(fact)\n" + @@ -5556,8 +5689,9 @@ public void testCompilationFailureWithDuplicatedAnnotation() { assertDrlHasCompilationError( str, 1, kieBaseTestConfiguration ); } - @Test - public void testCrossNoLoopWithNodeSharing() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCrossNoLoopWithNodeSharing(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-501 Propgation context is not set correctly when nodes are shared // This test was looping in 6.1.0-Beta4 String drl = "package org.drools.mvel.compiler.loop " + @@ -5599,8 +5733,9 @@ public void testCrossNoLoopWithNodeSharing() throws Exception { session.dispose(); } - @Test - public void testNotNodesUnlinking() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNotNodesUnlinking(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // BZ-1101471 String drl = "import " + Trailer.class.getCanonicalName() + ";" + "global java.util.List trailerList;" + @@ -5687,8 +5822,9 @@ public void setStatus( TypeStatus status ) { public static class Host { } - @Test - public void testJITIncompatibleTypes() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJITIncompatibleTypes(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // BZ-1101295 String drl = "import " + Host.class.getCanonicalName() + ";\n" + @@ -5756,8 +5892,9 @@ public void setValue( int value ) { } } - @Test - public void testAccumulateWithNodeSharing() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccumulateWithNodeSharing(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-487 String drl = "import " + TypeA.class.getCanonicalName() + ";\n" + @@ -5843,8 +5980,9 @@ public void setType( String type ) { } } - @Test - public void testDeletedEvalLeftTuple() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeletedEvalLeftTuple(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // BZ-1106300 String drl = "import " + Reading.class.getCanonicalName() + ";\n" + @@ -5960,8 +6098,9 @@ public int getValue() { } } - @Test - public void testDeleteFromLeftTuple() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeleteFromLeftTuple(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-518 String drl = "import " + C1.class.getCanonicalName() + ";\n" + @@ -6009,8 +6148,9 @@ public String getValue() { } } - @Test - public void testMethodResolution() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMethodResolution(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-509 String drl = "import " + I1.class.getCanonicalName() + ";\n" + @@ -6028,8 +6168,9 @@ public void testMethodResolution() throws Exception { ksession.fireAllRules(); } - @Test - public void testCorrectErrorMessageOnDeclaredTypeCompilation() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCorrectErrorMessageOnDeclaredTypeCompilation(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-543 String str = "rule R\n" + "salience 10\n" + @@ -6051,8 +6192,9 @@ public void testCorrectErrorMessageOnDeclaredTypeCompilation() throws Exception assertDrlHasCompilationError( str, 1, kieBaseTestConfiguration ); } - @Test - public void testFieldNameStartingWithUnderscore() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFieldNameStartingWithUnderscore(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-554 String str = "import " + Underscore.class.getCanonicalName() + ";\n" + "rule R when\n" + @@ -6077,8 +6219,9 @@ public void set_id( String _id ) { } } - @Test - public void testSharedQueryNode() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSharedQueryNode(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-561 String drl = "query find( Integer $i, String $s )\n" + @@ -6106,8 +6249,9 @@ public void testSharedQueryNode() throws Exception { ksession.fireAllRules(); } - @Test - public void testLeftTupleGetIndex() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLeftTupleGetIndex(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-570 String drl = "rule R1 when\n" + @@ -6130,8 +6274,9 @@ public void testLeftTupleGetIndex() throws Exception { ksession.fireAllRules(); } - @Test - public void testStrOperatorInAccumulate() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testStrOperatorInAccumulate(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-574 String drl = "declare Message\n" + @@ -6186,8 +6331,9 @@ public void testStrOperatorInAccumulate() throws Exception { assertThat(list.contains("group by hi count is 1")).isTrue(); } - @Test - public void testKeywordAsAttribute() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKeywordAsAttribute(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-577 String drl = "package foo.bar;\n" + @@ -6243,8 +6389,9 @@ public void testKeywordAsAttribute() throws Exception { assertThat(list.contains("F060d")).isTrue(); } - @Test - public void testRuleExtendsWithNamedConsequence() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRuleExtendsWithNamedConsequence(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-581 String drl = "package org.drools.test;\n" + @@ -6277,8 +6424,9 @@ public void testRuleExtendsWithNamedConsequence() { assertThat((int) list.get(1)).isEqualTo(10); } - @Test - public void testRuleExtendsWithOverriddenNamedConsequence() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRuleExtendsWithOverriddenNamedConsequence(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-581 String drl = "package org.drools.test;\n" + @@ -6313,8 +6461,9 @@ public void testRuleExtendsWithOverriddenNamedConsequence() { assertThat(list.get(1)).isEqualTo("10"); } - @Test - public void testCustomDynamicSalience() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCustomDynamicSalience(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "package org.drools.test; " + "import " + Person.class.getName() + "; " + "global java.util.List list; " + @@ -6375,8 +6524,9 @@ public boolean isDynamic() { assertThat(list).isEqualTo(Arrays.asList(6, 5, 4, 3, 2, 1)); } - @Test - public void testNotWithSubNetwork() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNotWithSubNetwork(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "rule R when\n" + " $s : String( )\n" + @@ -6404,8 +6554,9 @@ public void testNotWithSubNetwork() { assertThat(ksession.getFactCount()).isEqualTo(0); } - @Test - public void testGenericsInRHSWithModify() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGenericsInRHSWithModify(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-493 String drl = "import java.util.Map;\n" + @@ -6424,8 +6575,9 @@ public void testGenericsInRHSWithModify() { ksession.fireAllRules(); } - @Test - public void testQueryWithAgendaGroup() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryWithAgendaGroup(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-601 String drl = "package org.drools.test; " + @@ -6479,8 +6631,9 @@ public void testQueryWithAgendaGroup() { assertThat(list).isEqualTo(Arrays.asList(42, 99)); } - @Test - public void testQueryUsingQueryWithAgendaGroup() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryUsingQueryWithAgendaGroup(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-601 String drl = "package org.drools.test; " + @@ -6552,8 +6705,9 @@ public void testQueryUsingQueryWithAgendaGroup() { assertThat(list).isEqualTo(Arrays.asList(42, 99)); } - @Test - public void testBitwiseOperator() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBitwiseOperator(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-585 String drl = "global java.util.List list;\n" + @@ -6579,8 +6733,9 @@ public void testBitwiseOperator() { assertThat(list.containsAll(asList(3, 6))).isTrue(); } - @Test - public void testNotSubnetwork() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNotSubnetwork(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-623 String drl = "import " + TypeCC.class.getCanonicalName() + ";\n" + @@ -6590,17 +6745,17 @@ public void testNotSubnetwork() { "when \n" + " $dd : TypeDD( value < 1 )\n" + "then \n" + - " System.out.println(\"Rule R1 Fired\");\n" + - " modify($dd) { setValue(1); }\n" + + " System.out.println(\"Rule R1 Fired\");\n" + + " modify($dd) { setValue(1); }\n" + "end \n" + " \n" + "rule R2 when \n" + " String( ) \n" + " $cc : TypeCC( value < 1 )\n" + " not( \n" + - " $cc_not : TypeCC( ) \n" + - " and \n" + - " $dd_not : TypeDD( value==0 ) \n" + + " $cc_not : TypeCC( ) \n" + + " and \n" + + " $dd_not : TypeDD( value==0 ) \n" + " ) \n" + "then \n" + " System.out.println(\"Rule R2 Fired\");\n" + @@ -6642,8 +6797,9 @@ public static class TypeCC extends ValueContainer { public static class TypeDD extends ValueContainer { } - @Test - public void testClassAccumulator() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testClassAccumulator(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-626 String drl = "global java.util.List list\n" + @@ -6677,8 +6833,9 @@ public void testClassAccumulator() { assertThat(list.containsAll(asList(String.class, Integer.class))).isTrue(); } - @Test - public void testSubnetworkAccumulate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSubnetworkAccumulate(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "import " + StringWrapper.class.getCanonicalName() + ";\n" + "global StringBuilder sb;" + @@ -6758,8 +6915,9 @@ public int compareTo( TestString o ) { } } - @Test - public void testImportInner() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testImportInner(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-677 String drl = "package org.drools.test; " + @@ -6775,9 +6933,10 @@ public void testImportInner() throws Exception { assertThat(errors.isEmpty()).as(errors.toString()).isTrue(); } - @Test + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") //DROOLS-678 - public void testAlphaIndexing() throws Exception { + public void testAlphaIndexing(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drl = " package org.drools.test; " + @@ -6817,8 +6976,9 @@ public void testAlphaIndexing() throws Exception { assertThat(ks.fireAllRules()).isEqualTo(1); } - @Test - public void testMvelConstraintErrorMessageOnAlpha() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMvelConstraintErrorMessageOnAlpha(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-687 String drl = " import org.drools.mvel.compiler.Person; " + @@ -6842,8 +7002,9 @@ public void testMvelConstraintErrorMessageOnAlpha() throws Exception { } } - @Test - public void testMvelConstraintErrorMessageOnBeta() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMvelConstraintErrorMessageOnBeta(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-687 String drl = " import org.drools.mvel.compiler.Person; " + @@ -6869,8 +7030,9 @@ public void testMvelConstraintErrorMessageOnBeta() throws Exception { } } - @Test - public void testPassiveExists() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPassiveExists(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-699 String drl2 = "import " + List.class.getCanonicalName() + ";\n" @@ -6892,8 +7054,9 @@ public void testPassiveExists() { assertThat(ksession.fireAllRules()).isEqualTo(4); } - @Test - public void testFromAfterOr() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFromAfterOr(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-707 String drl2 = "rule \"Disaster Rule\"\n" + @@ -6911,8 +7074,9 @@ public void testFromAfterOr() { assertThat(ksession.fireAllRules()).isEqualTo(1); } - @Test - public void testMalformedAccumulate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMalformedAccumulate(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-725 String str = "rule R when\n" + @@ -6927,8 +7091,9 @@ public void testMalformedAccumulate() { assertDrlHasCompilationError( str, 1, kieBaseTestConfiguration ); } - @Test - public void testDuplicateDeclarationInAccumulate1() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDuplicateDeclarationInAccumulate1(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-727 String drl1 = "import java.util.*\n" + @@ -6943,8 +7108,9 @@ public void testDuplicateDeclarationInAccumulate1() { assertDrlHasCompilationError( drl1, 1, kieBaseTestConfiguration ); } - @Test - public void testDuplicateDeclarationInAccumulate2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDuplicateDeclarationInAccumulate2(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-727 String drl1 = "import java.util.*\n" + @@ -6959,8 +7125,9 @@ public void testDuplicateDeclarationInAccumulate2() { assertDrlHasCompilationError( drl1, 1, kieBaseTestConfiguration ); } - @Test - public void testCompilationFailureOnNonExistingVariable() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCompilationFailureOnNonExistingVariable(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-734 String drl1 = "import java.util.*\n" + @@ -6973,8 +7140,9 @@ public void testCompilationFailureOnNonExistingVariable() { assertDrlHasCompilationError( drl1, 1, kieBaseTestConfiguration ); } - @Test - public void testJittedConstraintStringAndLong() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJittedConstraintStringAndLong(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-740 String drl = " import org.drools.mvel.compiler.Person; " + @@ -6992,8 +7160,9 @@ public void testJittedConstraintStringAndLong() { assertThat(ksession.fireAllRules()).isEqualTo(1); } - @Test - public void testKieBuilderWithClassLoader() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKieBuilderWithClassLoader(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-763 String drl = "import com.billasurf.Person\n" + @@ -7029,8 +7198,9 @@ public void testKieBuilderWithClassLoader() { assertThat((int) list.get(0)).isEqualTo(18); } - @Test - public void testInsertAndDelete() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInsertAndDelete(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "global java.util.List list\n" + "\n" + @@ -7057,8 +7227,9 @@ public void testInsertAndDelete() { assertThat(list.size()).isEqualTo(1); } - @Test - public void testClearActivationGroupCommand() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testClearActivationGroupCommand(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-828 String drl = "package org.kie.test\n" + @@ -7091,8 +7262,9 @@ public void testClearActivationGroupCommand() { assertThat(list.get(0)).isEqualTo("Rule without agenda group executed"); } - @Test - public void testClearActivationGroupCommandNoImmediatePropagation() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testClearActivationGroupCommandNoImmediatePropagation(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-865 String drl = "package org.kie.test\n" + @@ -7138,8 +7310,9 @@ public int getValue() { } } - @Test - public void testDoubleNestedClass() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDoubleNestedClass(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-815 String drl = "import " + $X.$Y.class.getCanonicalName() + ";\n" + @@ -7163,8 +7336,9 @@ public void testDoubleNestedClass() { assertThat(list.get(0)).isEqualTo(42); } - @Test - public void testWrongNodeSharing() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testWrongNodeSharing(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-588 String drl1 = "package test1\n" + @@ -7203,8 +7377,9 @@ public static int parseInt( String s ) { return 0; } - @Test - public void testJittedConstraintComparisonWithIncompatibleObjects() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJittedConstraintComparisonWithIncompatibleObjects(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-858 String drl = "package org.drools.mvel.integrationtests\n" @@ -7262,8 +7437,10 @@ public String toString() { } } - @Test(timeout = 10000L) - public void testFireUntilHaltWithForceEagerActivation() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testFireUntilHaltWithForceEagerActivation(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { String drl = "global java.util.List list\n" + "rule \"String detector\"\n" + " when\n" + @@ -7344,8 +7521,9 @@ public class B1 { public int b3 = 3; } - @Test - public void testSkipHashingOfNestedProperties() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSkipHashingOfNestedProperties(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-870 String drl = "import " + A1.class.getCanonicalName() + "\n" + @@ -7381,8 +7559,9 @@ public void testSkipHashingOfNestedProperties() { assertThat(list.containsAll(asList("1", "2", "3"))).isTrue(); } - @Test - public void testErrorReportWithWrongAccumulateFunction() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testErrorReportWithWrongAccumulateFunction(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-872 String drl = "import " + Cheese.class.getCanonicalName() + "\n" + @@ -7397,8 +7576,9 @@ public void testErrorReportWithWrongAccumulateFunction() { assertDrlHasCompilationError( drl, -1, kieBaseTestConfiguration ); } - @Test - public void testVariableMatchesField() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testVariableMatchesField(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-882 String drl = "declare RegEx\n" + @@ -7428,8 +7608,9 @@ public void testVariableMatchesField() throws Exception { assertThat(ksession.fireAllRules()).isEqualTo(2); } - @Test - public void testEndMethod() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEndMethod(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-889 String drl = "import " + Pattern.class.getCanonicalName() + "\n" + @@ -7476,8 +7657,9 @@ public static class ChildA extends Parent { public static class ChildB extends Parent { } - @Test - public void testDifferentClassesWithOR() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDifferentClassesWithOR(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-897 String drl = "import " + ChildA.class.getCanonicalName() + "\n" + @@ -7505,8 +7687,9 @@ public void testDifferentClassesWithOR() throws Exception { assertThat(childB.getValue()).isEqualTo("Done!"); } - @Test - public void testJittingCollectionCreation() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJittingCollectionCreation(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-900 String drl = "import " + Arrays.class.getCanonicalName() + "\n" + @@ -7531,8 +7714,9 @@ public void testJittingCollectionCreation() { assertThat(list.get(0)).isEqualTo("a"); } - @Test - public void testJittingCollectionCreationInParenthesis() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJittingCollectionCreationInParenthesis(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-900 String drl = "import " + Arrays.class.getCanonicalName() + "\n" + @@ -7557,9 +7741,10 @@ public void testJittingCollectionCreationInParenthesis() { assertThat(list.get(0)).isEqualTo("a"); } - @Test - @Ignore - public void testBetaMemoryLeakOnSegmentUnlinking() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Disabled + public void testBetaMemoryLeakOnSegmentUnlinking(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-915 String drl = "rule R1 when\n" + @@ -7605,8 +7790,9 @@ public void testBetaMemoryLeakOnSegmentUnlinking() { } } - @Test - public void testFunctionInvokingFunction() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFunctionInvokingFunction(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-926 final String drl = "function boolean isOdd(int i) {\n" + @@ -7661,8 +7847,9 @@ public void testFunctionInvokingFunction() throws Exception { } } - @Test - public void testCompilationFailureWithNonExistingField() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCompilationFailureWithNonExistingField(KieBaseTestConfiguration kieBaseTestConfiguration) { // BZ-1271534 String drl = "rule R when\n" + @@ -7673,8 +7860,9 @@ public void testCompilationFailureWithNonExistingField() { assertDrlHasCompilationError( drl, 1, kieBaseTestConfiguration ); } - @Test - public void testPatternMatchingWithFakeImplicitCast() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPatternMatchingWithFakeImplicitCast(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-966 String drl = "rule R1 when\n" + @@ -7689,8 +7877,9 @@ public void testPatternMatchingWithFakeImplicitCast() { assertThat(ksession.fireAllRules()).isEqualTo(1); } - @Test - public void testPatternMatchingWithFakeNullSafe() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPatternMatchingWithFakeNullSafe(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-966 String drl = "rule R1 when\n" + @@ -7705,17 +7894,19 @@ public void testPatternMatchingWithFakeNullSafe() { assertThat(ksession.fireAllRules()).isEqualTo(1); } - @Test - public void testLambdaInRHS() { - checkJava8InRhs("i -> list.add(i)"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLambdaInRHS(KieBaseTestConfiguration kieBaseTestConfiguration) { + checkJava8InRhs(kieBaseTestConfiguration, "i -> list.add(i)"); } - @Test - public void testMethodReferenceInRHS() { - checkJava8InRhs("list::add"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMethodReferenceInRHS(KieBaseTestConfiguration kieBaseTestConfiguration) { + checkJava8InRhs(kieBaseTestConfiguration, "list::add"); } - private void checkJava8InRhs(String expr) { + private void checkJava8InRhs(KieBaseTestConfiguration kieBaseTestConfiguration, String expr) { assumeTrue(System.getProperty("java.version").startsWith( "1.8" )); // BZ-1199965 @@ -7738,8 +7929,9 @@ private void checkJava8InRhs(String expr) { assertThat(list.containsAll(Arrays.asList(1, 2, 3, 4))).isTrue(); } - @Test - public void testCompareToOnInterface() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCompareToOnInterface(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1013 String drl = "import " + StringWrapper.class.getCanonicalName() + "\n" + @@ -7765,8 +7957,9 @@ public void testCompareToOnInterface() { assertThat(list.get(0)).isEqualTo("bbb"); } - @Test - public void testFromEPDontRequireLeftInput() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testFromEPDontRequireLeftInput(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1014 String drl = "rule R when\n" + @@ -7790,8 +7983,9 @@ public void testFromEPDontRequireLeftInput() { } } - @Test - public void testIn() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIn(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1037 String drl = "import " + Person.class.getCanonicalName() + "\n" + @@ -7815,8 +8009,9 @@ public void testIn() { assertThat(list.get(0)).isEqualTo("Bob"); } - @Test - public void testNonSerializableInEvaluatorWrapper() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNonSerializableInEvaluatorWrapper(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // BZ-1315143 String str = "package org.drools.mvel.compiler\n" + "rule B\n" + @@ -7868,8 +8063,9 @@ public void testNonSerializableInEvaluatorWrapper() throws Exception { ksession2.dispose(); } - @Test - public void testWrongNodeSharingWithSameHashCode() throws IllegalAccessException, InstantiationException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testWrongNodeSharingWithSameHashCode(KieBaseTestConfiguration kieBaseTestConfiguration) throws IllegalAccessException, InstantiationException { String drl = "import " + Person.class.getCanonicalName() + ";\n" + @@ -7898,8 +8094,9 @@ public void testWrongNodeSharingWithSameHashCode() throws IllegalAccessException assertThat(b5L.isHappy()).isTrue(); } - @Test - public void testWrongVariableNameWithSameDeclarationName() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testWrongVariableNameWithSameDeclarationName(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1064 String str = "declare Parameter end\n" + @@ -7911,8 +8108,9 @@ public void testWrongVariableNameWithSameDeclarationName() { assertDrlHasCompilationError( str, -1, kieBaseTestConfiguration ); } - @Test - public void testComplexEvals() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testComplexEvals(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1139 String drl = "rule R1 when\n" + @@ -7930,8 +8128,9 @@ public void testComplexEvals() { assertThat(kieSession.fireAllRules()).isEqualTo(1); } - @Test - public void testComplexEvals2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testComplexEvals2(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1139 String drl = "rule R1 when\n" + @@ -7954,8 +8153,9 @@ public void testComplexEvals2() { assertThat(kieSession.fireAllRules()).isEqualTo(4); } - @Test - public void testDeletedRightTupleInChangedBucket() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeletedRightTupleInChangedBucket(KieBaseTestConfiguration kieBaseTestConfiguration) { // PLANNER-488 String drl = "import " + Person.class.getCanonicalName() + "\n" + @@ -7997,8 +8197,9 @@ public void testDeletedRightTupleInChangedBucket() { kieSession.fireAllRules(); } - @Test - public void testJittingFunctionReturningAnInnerClass() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testJittingFunctionReturningAnInnerClass(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1166 String drl = "import " + java.util.function.Function.class.getCanonicalName() + "\n" + @@ -8022,8 +8223,9 @@ public void testJittingFunctionReturningAnInnerClass() { assertThat(kieSession.fireAllRules()).isEqualTo(1); } - @Test - public void testQueryWithEnum() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryWithEnum(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1181 String drl = "import " + AnswerGiver.class.getCanonicalName() + "\n" + @@ -8048,8 +8250,9 @@ public void testQueryWithEnum() { assertThat(kieSession.fireAllRules()).isEqualTo(0); } - @Test - public void testOrQueryWithEnum() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOrQueryWithEnum(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1181 String drl = "import " + AnswerGiver.class.getCanonicalName() + "\n" + @@ -8078,8 +8281,9 @@ public void testOrQueryWithEnum() { assertThat(kieSession.fireAllRules()).isEqualTo(2); } - @Test - public void testModifyWithOr() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModifyWithOr(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1185 String drl = "import " + List.class.getCanonicalName() + "\n" + @@ -8103,8 +8307,9 @@ public void testModifyWithOr() { assertThat(kieSession.fireAllRules()).isEqualTo(1); } - @Test - public void testNormalizeRuleName() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNormalizeRuleName(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1192 String drl = "rule \"rule(hello)\" when\n" + @@ -8119,8 +8324,9 @@ public void testNormalizeRuleName() { assertThat(kieSession.fireAllRules()).isEqualTo(1); } - @Test - public void testWiringClassOnPackageMerge() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testWiringClassOnPackageMerge(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String drl_init = "package init;\n" + "import org.kie.test.TestObject\n" + @@ -8192,8 +8398,9 @@ public void testWiringClassOnPackageMerge() throws Exception { assertThat(list.contains("R2")).isTrue(); } - @Test - public void testReorderRightMemoryOnIndexedField() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testReorderRightMemoryOnIndexedField(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1174 String rule = "import " + Misc2Test.Seat.class.getCanonicalName() + ";\n" + "\n" @@ -8269,8 +8476,9 @@ public Seat setTable(Long table) { } } - @Test - public void testChildLeftTuplesIterationOnLeftUpdate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testChildLeftTuplesIterationOnLeftUpdate(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1186 String drl = "import " + Shift.class.getCanonicalName() + "\n" + @@ -8361,8 +8569,9 @@ public String toString() { } } - @Test - public void test1187() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void test1187(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1187 String drl = "import " + Misc2Test.Shift1187.class.getCanonicalName() + "\n" + "rule insertEmployeeConsecutiveWeekendAssignmentStart when\n" @@ -8459,8 +8668,9 @@ private boolean hasWeekendOnFriday(String employee) { } } - @Test - public void testReportFailingConstraintOnError() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testReportFailingConstraintOnError(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1071 String drl = "import " + Person.class.getCanonicalName() + "\n" + @@ -8499,8 +8709,9 @@ public Integer getValue() { } - @Test - public void testNpeInLessThanComparison() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNpeInLessThanComparison(KieBaseTestConfiguration kieBaseTestConfiguration) { // RHBRMS-2462 String drl = "package com.sample\n" + "import " + TestObject.class.getCanonicalName() + ";\n" @@ -8555,8 +8766,9 @@ public void testNpeInLessThanComparison() { assertThat(list.contains("GreaterThanCompare:null")).isFalse(); } - @Test - public void testUnderscoreDoubleMultiplicationCastedToInt() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUnderscoreDoubleMultiplicationCastedToInt(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1420 String str = "import " + Cheese.class.getCanonicalName() + "\n" + @@ -8586,11 +8798,13 @@ public void testUnderscoreDoubleMultiplicationCastedToInt() { * Helpful to test thread dump when a timeout occur on the JUnit listener. * @throws Exception */ - @Ignore("This test deliberately creates a deadlock, failing the test with a timeout.\n" + + @Disabled("This test deliberately creates a deadlock, failing the test with a timeout.\n" + "Helpful to test thread dump when a timeout occur on the JUnit listener.\n" + "See org.kie.test.util.TestStatusListener#testFailure()") - @Test(timeout=5_000L) - public void testDeadlock() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testDeadlock(KieBaseTestConfiguration kieBaseTestConfiguration) { Object lock1 = 1L; Object lock2 = 2L; Runnable task1 = () -> { @@ -8626,8 +8840,9 @@ public static class MyElement extends AbstractElement implements MyInterface { public void nothing() {} } - @Test - public void test01841522() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void test01841522(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package com.sample\n" + "import " + ElementOperation.class.getCanonicalName() + ";\n" + "import " + AbstractElement.class.getCanonicalName() + ";\n" + @@ -8652,9 +8867,10 @@ public void test01841522() { assertThat(list.size()).isEqualTo(1); } - @Test - @Ignore("This test is supposed to cause a StackOverflow inside mvel but this not always happens") - public void testStackOverflowInMvel() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Disabled("This test is supposed to cause a StackOverflow inside mvel but this not always happens") + public void testStackOverflowInMvel(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1542 String str1 = "import " + Person.class.getName() + ";\n" + "rule R1 when\n" + @@ -8674,8 +8890,9 @@ public void testStackOverflowInMvel() { assertThat(kbuilder.getErrors().toString().contains("StackOverflowError")).isTrue(); } - @Test - public void testMergeMVELDialect() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMergeMVELDialect(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1751 String drl1 = "package com.sample\n" + "import org.drools.mvel.compiler.*;\n" + @@ -8725,8 +8942,9 @@ public void testMergeMVELDialect() { assertThat(fired).isEqualTo(2); } - @Test - public void testCollectWithEagerActivation() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCollectWithEagerActivation(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-4468 String drl = "import java.util.ArrayList\n" + @@ -8779,8 +8997,9 @@ public void testCollectWithEagerActivation() { assertThat(list.contains("R1")).isTrue(); } - @Test - public void testModifyAddToList() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModifyAddToList(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-4447 String str = "import " + Address.class.getCanonicalName() + "\n" + @@ -8806,8 +9025,9 @@ public void testModifyAddToList() { assertThat(martin.getAddresses().size()).isEqualTo(1); } - @Test - public void testKieHelperReleaseId() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKieHelperReleaseId(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // test for KieHelper. not for exec-model String drl = "rule R when\n" + @@ -8827,8 +9047,9 @@ public void testKieHelperReleaseId() throws Exception { assertThat(ksession.fireAllRules()).isEqualTo(1); } - @Test - public void testKieHelperKieModuleModel() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testKieHelperKieModuleModel(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // Test to check whether verify method writes KieModuleModel to KieFileSystem final String drl = diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NamedConsequencesTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NamedConsequencesTest.java index 3e700bb0041..baa56c629cf 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NamedConsequencesTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NamedConsequencesTest.java @@ -19,11 +19,11 @@ package org.drools.mvel.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Stream; import org.drools.mvel.compiler.Cheese; import org.drools.mvel.compiler.Person; @@ -31,11 +31,10 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.Message.Level; @@ -46,30 +45,23 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -@RunWith(Parameterized.class) public class NamedConsequencesTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public NamedConsequencesTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testNamedConsequences() { - List results = executeTestWithCondition("do[t1]"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNamedConsequences(KieBaseTestConfiguration kieBaseTestConfiguration) { + List results = executeTestWithCondition(kieBaseTestConfiguration, "do[t1]"); assertThat(results.size()).isEqualTo(2); assertThat(results.contains("cheddar")).isTrue(); assertThat(results.contains("stilton")).isTrue(); } - private List executeTestWithCondition(String conditionElement) { + private List executeTestWithCondition(KieBaseTestConfiguration kieBaseTestConfiguration, String conditionElement) { String drl = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + @@ -83,10 +75,10 @@ private List executeTestWithCondition(String conditionElement) { " results.add( $a.getType() );\n" + "end\n"; - return executeTestWithDRL(drl); + return executeTestWithDRL(kieBaseTestConfiguration, drl); } - private List executeTestWithDRL(String drl) { + private List executeTestWithDRL(KieBaseTestConfiguration kieBaseTestConfiguration, String drl) { KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, drl); KieSession ksession = kbase.newKieSession(); @@ -105,8 +97,9 @@ private List executeTestWithDRL(String drl) { return results; } - @Test - public void testNonCompilingBreakingConsequences() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNonCompilingBreakingConsequences(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + @@ -124,8 +117,9 @@ public void testNonCompilingBreakingConsequences() { assertThat(kieBuilder.getResults().hasMessages(Level.ERROR)).isTrue(); } - @Test - public void testNonCompilingDuplicatedNamedConsequence() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNonCompilingDuplicatedNamedConsequence(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + @@ -145,8 +139,9 @@ public void testNonCompilingDuplicatedNamedConsequence() { assertThat(kieBuilder.getResults().hasMessages(Level.ERROR)).isTrue(); } - @Test - public void testOutOfScopeNamedConsequences() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOutOfScopeNamedConsequences(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + @@ -164,41 +159,46 @@ public void testOutOfScopeNamedConsequences() { assertThat(kieBuilder.getResults().hasMessages(Level.ERROR)).isTrue(); } - @Test - public void testAllowedIfDo() { - List results = executeTestWithCondition("if ( price < 10 ) do[t1]"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAllowedIfDo(KieBaseTestConfiguration kieBaseTestConfiguration) { + List results = executeTestWithCondition(kieBaseTestConfiguration, "if ( price < 10 ) do[t1]"); assertThat(results.size()).isEqualTo(2); assertThat(results.contains("cheddar")).isTrue(); assertThat(results.contains("stilton")).isTrue(); } - @Test - public void testNotAllowedIfDo() { - List results = executeTestWithCondition("if ( price > 10 ) do[t1]"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNotAllowedIfDo(KieBaseTestConfiguration kieBaseTestConfiguration) { + List results = executeTestWithCondition(kieBaseTestConfiguration, "if ( price > 10 ) do[t1]"); assertThat(results.size()).isEqualTo(1); assertThat(results.contains("cheddar")).isTrue(); } - @Test - public void testAllowedIfBreak() { - List results = executeTestWithCondition("if ( price < 10 ) break[t1]"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAllowedIfBreak(KieBaseTestConfiguration kieBaseTestConfiguration) { + List results = executeTestWithCondition(kieBaseTestConfiguration, "if ( price < 10 ) break[t1]"); assertThat(results.size()).isEqualTo(1); assertThat(results.contains("stilton")).isTrue(); } - @Test - public void testNotAllowedIfBreak() { - List results = executeTestWithCondition("if ( price > 10 ) break[t1]"); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNotAllowedIfBreak(KieBaseTestConfiguration kieBaseTestConfiguration) { + List results = executeTestWithCondition(kieBaseTestConfiguration, "if ( price > 10 ) break[t1]"); assertThat(results.size()).isEqualTo(1); assertThat(results.contains("cheddar")).isTrue(); } - @Test - public void testNamedConsequencesOutsideOR() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNamedConsequencesOutsideOR(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + @@ -214,16 +214,17 @@ public void testNamedConsequencesOutsideOR() { " results.add( $a.getType() );\n" + "end\n"; - List results = executeTestWithDRL(str); + List results = executeTestWithDRL(kieBaseTestConfiguration, str); assertThat(results.size()).isEqualTo(2); assertThat(results.contains("cheddar")).isTrue(); assertThat(results.contains("stilton")).isTrue(); } - @Ignore("Moved to EdgeCaseNonExecModelTest") - @Test - public void testNamedConsequencesInsideOR1() { + @Disabled("Moved to EdgeCaseNonExecModelTest") + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNamedConsequencesInsideOR1(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + @@ -238,16 +239,17 @@ public void testNamedConsequencesInsideOR1() { " results.add( $a.getType() );\n" + "end\n"; - List results = executeTestWithDRL(str); + List results = executeTestWithDRL(kieBaseTestConfiguration, str); assertThat(results.size()).isEqualTo(2); assertThat(results.contains("cheddar")).isTrue(); assertThat(results.contains("stilton")).isTrue(); } - @Ignore("Moved to EdgeCaseNonExecModelTest") - @Test - public void testNamedConsequencesInsideOR2() { + @Disabled("Moved to EdgeCaseNonExecModelTest") + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNamedConsequencesInsideOR2(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + @@ -262,14 +264,15 @@ public void testNamedConsequencesInsideOR2() { " results.add( $b.getType() );\n" + "end\n"; - List results = executeTestWithDRL(str); + List results = executeTestWithDRL(kieBaseTestConfiguration, str); assertThat(results.size()).isEqualTo(1); assertThat(results.contains("cheddar")).isTrue(); } - @Test - public void testOutOfScopeNamedConsequencesWithOr1() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOutOfScopeNamedConsequencesWithOr1(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + @@ -288,8 +291,9 @@ public void testOutOfScopeNamedConsequencesWithOr1() { assertThat(kieBuilder.getResults().hasMessages(Level.ERROR)).isTrue(); } - @Test - public void testOutOfScopeNamedConsequencesWithOr2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOutOfScopeNamedConsequencesWithOr2(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + @@ -308,8 +312,9 @@ public void testOutOfScopeNamedConsequencesWithOr2() { assertThat(kieBuilder.getResults().hasMessages(Level.ERROR)).isTrue(); } - @Test - public void testNonCompilingIFAfterOR() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNonCompilingIFAfterOR(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + @@ -329,8 +334,9 @@ public void testNonCompilingIFAfterOR() { assertThat(kieBuilder.getResults().hasMessages(Level.ERROR)).isTrue(); } - @Test - public void testIfElse1() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIfElse1(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + @@ -346,15 +352,16 @@ public void testIfElse1() { " results.add( $a.getType().toUpperCase() );\n" + "end\n"; - List results = executeTestWithDRL(str); + List results = executeTestWithDRL(kieBaseTestConfiguration, str); assertThat(results.size()).isEqualTo(2); assertThat(results.contains("cheddar")).isTrue(); assertThat(results.contains("STILTON")).isTrue(); } - @Test - public void testIfElseWithConstant() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIfElseWithConstant(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-325 String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + @@ -371,15 +378,16 @@ public void testIfElseWithConstant() { " results.add( $a.getType().toUpperCase() );\n" + "end\n"; - List results = executeTestWithDRL(str); + List results = executeTestWithDRL(kieBaseTestConfiguration, str); assertThat(results.size()).isEqualTo(2); assertThat(results.contains("cheddar")).isTrue(); assertThat(results.contains("STILTON")).isTrue(); } - @Test - public void testIfElseWithMvelAccessor() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIfElseWithMvelAccessor(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-324 String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + @@ -396,15 +404,16 @@ public void testIfElseWithMvelAccessor() { " results.add( $a.getType().toUpperCase() );\n" + "end\n"; - List results = executeTestWithDRL(str); + List results = executeTestWithDRL(kieBaseTestConfiguration, str); assertThat(results.size()).isEqualTo(2); assertThat(results.contains("cheddar")).isTrue(); assertThat(results.contains("STILTON")).isTrue(); } - @Test - public void testIfElse2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIfElse2(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + @@ -420,15 +429,16 @@ public void testIfElse2() { " results.add( $a.getType().toUpperCase() );\n" + "end\n"; - List results = executeTestWithDRL(str); + List results = executeTestWithDRL(kieBaseTestConfiguration, str); assertThat(results.size()).isEqualTo(2); assertThat(results.contains("cheddar")).isTrue(); assertThat(results.contains("STILTON")).isTrue(); } - @Test - public void testIfElseBreak() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIfElseBreak(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + @@ -444,14 +454,15 @@ public void testIfElseBreak() { " results.add( $a.getType().toUpperCase() );\n" + "end\n"; - List results = executeTestWithDRL(str); + List results = executeTestWithDRL(kieBaseTestConfiguration, str); assertThat(results.size()).isEqualTo(1); assertThat(results.contains("STILTON")).isTrue(); } - @Test - public void testNestedIfElseBreak() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNestedIfElseBreak(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + @@ -469,14 +480,15 @@ public void testNestedIfElseBreak() { " results.add( $a.getType().toUpperCase() );\n" + "end\n"; - List results = executeTestWithDRL(str); + List results = executeTestWithDRL(kieBaseTestConfiguration, str); assertThat(results.size()).isEqualTo(1); assertThat(results.contains("STILTON")).isTrue(); } - @Test - public void testIfWithModify() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIfWithModify(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + @@ -490,14 +502,15 @@ public void testIfWithModify() { " results.add( $a.getType() );\n" + "end\n"; - List results = executeTestWithDRL(str); + List results = executeTestWithDRL(kieBaseTestConfiguration, str); assertThat(results.size()).isEqualTo(1); assertThat(results.contains("stilton")).isTrue(); } - @Test - public void testEndlessIfWithModify() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEndlessIfWithModify(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + @@ -514,13 +527,14 @@ public void testEndlessIfWithModify() { " if (results.size() > 10) throw new RuntimeException();\n" + "end\n"; - assertThatThrownBy(() -> executeTestWithDRL(str)) + assertThatThrownBy(() -> executeTestWithDRL(kieBaseTestConfiguration, str)) .isInstanceOf(RuntimeException.class) .hasMessageContaining("Exception executing consequence for rule \"R1\""); } - @Test - public void testIfWithModify2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIfWithModify2(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + @@ -534,14 +548,15 @@ public void testIfWithModify2() { " modify( $a ) { setPrice(15) };\n" + "end\n"; - List results = executeTestWithDRL(str); + List results = executeTestWithDRL(kieBaseTestConfiguration, str); assertThat(results.size()).isEqualTo(1); assertThat(results.contains("stilton")).isTrue(); } - @Test - public void testIfWithModify3() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIfWithModify3(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + @@ -560,14 +575,15 @@ public void testIfWithModify3() { " results.add( $a.getType() );\n" + "end\n"; - List results = executeTestWithDRL(str); + List results = executeTestWithDRL(kieBaseTestConfiguration, str); assertThat(results.size()).isEqualTo(1); assertThat(results.contains("stilton")).isTrue(); } - @Test - public void testIfElseWithModify() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testIfElseWithModify(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + @@ -583,14 +599,15 @@ public void testIfElseWithModify() { " results.add( $a.getType().toUpperCase() );\n" + "end\n"; - List results = executeTestWithDRL(str); + List results = executeTestWithDRL(kieBaseTestConfiguration, str); assertThat(results.size()).isEqualTo(2); assertThat(results.contains("STILTON")).isTrue(); } - @Test - public void testEndlessIfElseWithModify() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEndlessIfElseWithModify(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + @@ -609,13 +626,14 @@ public void testEndlessIfElseWithModify() { " if (results.size() > 10) throw new RuntimeException();\n" + "end\n"; - assertThatThrownBy(() -> executeTestWithDRL(str)) + assertThatThrownBy(() -> executeTestWithDRL(kieBaseTestConfiguration, str)) .isInstanceOf(RuntimeException.class) .hasMessageContaining("Exception executing consequence for rule \"R1\""); } - @Test - public void testNamedConsequenceAfterNotPattern() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNamedConsequenceAfterNotPattern(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-5 String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + @@ -646,8 +664,9 @@ public void testNamedConsequenceAfterNotPattern() { assertThat(results.contains("cheddar")).isTrue(); } - @Test - public void testMultipleIfAfterEval() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMultipleIfAfterEval(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + @@ -665,15 +684,16 @@ public void testMultipleIfAfterEval() { " results.add( $a.getType() );\n" + "end\n"; - List results = executeTestWithDRL(str); + List results = executeTestWithDRL(kieBaseTestConfiguration, str); assertThat(results.size()).isEqualTo(2); assertThat(results.contains("cheddar")).isTrue(); assertThat(results.contains("stilton")).isTrue(); } - @Test - public void testMultipleIfElseInARow() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMultipleIfElseInARow(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-26 String str = "global java.util.List results;" + @@ -728,8 +748,9 @@ public void testMultipleIfElseInARow() { assertThat(results.contains("Car is NOT cheap")).isTrue(); } - @Test - public void testDynamicSalience() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDynamicSalience(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-335 String str = "import " + Fact.class.getCanonicalName() + ";\n" + @@ -795,8 +816,9 @@ public String toString() { } } - @Test - public void testNamedConsequenceOnEvents() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNamedConsequenceOnEvents(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-641 String drl = "import " + StockTick.class.getCanonicalName() + ";\n" + @@ -830,8 +852,9 @@ public void testNamedConsequenceOnEvents() { assertThat(list.containsAll(asList("t1:YYY", "t0:ZZZ"))).isTrue(); } - @Test //(timeout = 10000L) - public void testNoLoop() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNoLoop(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-644 String drl = "import " + Person.class.getCanonicalName() + ";\n" + @@ -872,8 +895,9 @@ public void testNoLoop() { assertThat(list.get(1)).isEqualTo("t0"); } - @Test - public void testMVELBreak() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMVELBreak(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + @@ -887,15 +911,16 @@ public void testMVELBreak() { " results.add( $a.type.toUpperCase() );\n" + "end\n"; - List results = executeTestWithDRL(str); + List results = executeTestWithDRL(kieBaseTestConfiguration, str); System.out.println( results ); assertThat(results.size()).isEqualTo(1); assertThat(results.contains("STILTON")).isTrue(); } - @Test - public void testMVELNoBreak() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMVELNoBreak(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + @@ -909,15 +934,16 @@ public void testMVELNoBreak() { " results.add( $a.type.toUpperCase() );\n" + "end\n"; - List results = executeTestWithDRL(str); + List results = executeTestWithDRL(kieBaseTestConfiguration, str); System.out.println( results ); assertThat(results.size()).isEqualTo(1); assertThat(results.contains("cheddar")).isTrue(); } - @Test - public void testMvelInsertWithNamedConsequence() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMvelInsertWithNamedConsequence(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-726 String drl2 = "package org.drools.compiler\n" + @@ -960,8 +986,9 @@ public void testMvelInsertWithNamedConsequence() { assertThat(counter.get()).isEqualTo(2); } - @Test - public void testDeleteWithBreakingBranch() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeleteWithBreakingBranch(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-1068 String drl = "global java.util.List list;\n" + @@ -990,8 +1017,9 @@ public void testDeleteWithBreakingBranch() throws Exception { assertThat(list.get(0)).isEqualTo("branch"); } - @Test - public void testQueryWithBreakingBranch() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryWithBreakingBranch(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-1115 String drl = "import " + ListHolder.class.getCanonicalName() + ";\n" + @@ -1025,8 +1053,9 @@ public void testQueryWithBreakingBranch() throws Exception { assertThat(list.get(1)).isEqualTo("ok"); } - @Test - public void testInheritance() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInheritance(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "dialect \"mvel\"\n" + "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + @@ -1049,15 +1078,16 @@ public void testInheritance() { " results.add( $a.type );\n" + "end\n"; - List results = executeTestWithDRL(str); + List results = executeTestWithDRL(kieBaseTestConfiguration, str); assertThat(results.size()).isEqualTo(2); assertThat(results.contains("cheddar")).isTrue(); assertThat(results.contains("stilton")).isTrue(); } - @Test - public void testWrongConsequenceName() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testWrongConsequenceName(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NewLineAtEoFTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NewLineAtEoFTest.java index 5ccb5467fa7..3c16c24b066 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NewLineAtEoFTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NewLineAtEoFTest.java @@ -18,14 +18,13 @@ */ package org.drools.mvel.integrationtests; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.Message.Level; @@ -36,18 +35,10 @@ * Tests an error appearing when DLR does not contain a new line at the end of * the file. */ -@RunWith(Parameterized.class) public class NewLineAtEoFTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public NewLineAtEoFTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } private static final String drl = @@ -58,16 +49,18 @@ public static Collection getParameters() { + " System.out.println(\"Hello world!\");\n" + "end\n"; - @Test - public void testNoNewlineAtTheEnd() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNoNewlineAtTheEnd(KieBaseTestConfiguration kieBaseTestConfiguration) { KieBuilder kieBuilder = KieUtil.getKieBuilderFromDrls(kieBaseTestConfiguration, false, drl + "//test"); if (kieBuilder.getResults().hasMessages(Level.ERROR)) { fail(kieBuilder.getResults().getMessages(Level.ERROR).toString()); } } - @Test - public void testNewlineAtTheEnd() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNewlineAtTheEnd(KieBaseTestConfiguration kieBaseTestConfiguration) { KieBuilder kieBuilder = KieUtil.getKieBuilderFromDrls(kieBaseTestConfiguration, false, drl); assertThat(kieBuilder.getResults().hasMessages(Level.ERROR)).isFalse(); } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NodePositionInPathTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NodePositionInPathTest.java index dec094bab13..58be8909392 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NodePositionInPathTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NodePositionInPathTest.java @@ -18,7 +18,7 @@ */ package org.drools.mvel.integrationtests; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.base.base.ClassObjectType; import org.drools.core.impl.InternalRuleBase; @@ -34,30 +34,22 @@ import org.drools.core.reteoo.RuleTerminalNode; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class NodePositionInPathTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public NodePositionInPathTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void test() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void test(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "rule R1 when\n" + " Integer()\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NodesPartitioningTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NodesPartitioningTest.java index 4c2fc022dab..59a75aeaa04 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NodesPartitioningTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NodesPartitioningTest.java @@ -28,40 +28,33 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.builder.KieModule; import org.kie.internal.conf.ParallelExecutionOption; -import java.util.Collection; +import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class NodesPartitioningTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public NodesPartitioningTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void test2Partitions() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void test2Partitions(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = ruleA(1) + ruleB(2) + ruleC(2) + ruleD(1) + ruleD(2) + ruleC(1) + ruleA(2) + ruleB(1); - checkDrl( drl ); + checkDrl(kieBaseTestConfiguration, drl); } - @Test - public void testPartitioningWithSharedNodes() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPartitioningWithSharedNodes(KieBaseTestConfiguration kieBaseTestConfiguration) { StringBuilder sb = new StringBuilder( 400 ); for (int i = 1; i < 4; i++) { sb.append( getRule( i ) ); @@ -69,10 +62,10 @@ public void testPartitioningWithSharedNodes() { for (int i = 1; i < 4; i++) { sb.append( getNotRule( i ) ); } - checkDrl( sb.toString() ); + checkDrl(kieBaseTestConfiguration, sb.toString() ); } - private void checkDrl(String drl) { + private void checkDrl(KieBaseTestConfiguration kieBaseTestConfiguration, String drl) { final KieModule kieModule = KieUtil.getKieModuleFromDrls("test", kieBaseTestConfiguration, drl); final InternalKnowledgeBase kbase = (InternalKnowledgeBase)KieBaseUtil.newKieBaseFromKieModuleWithAdditionalOptions(kieModule, kieBaseTestConfiguration, ParallelExecutionOption.FULLY_PARALLEL); Rete rete = kbase.getRete(); @@ -213,8 +206,9 @@ public String getUuid() { } } - @Test - public void testChangePartitionOfAlphaSourceOfAlpha() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testChangePartitionOfAlphaSourceOfAlpha(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1487 String drl = "import " + Account.class.getCanonicalName() + ";\n" + @@ -233,6 +227,6 @@ public void testChangePartitionOfAlphaSourceOfAlpha() { "then\n" + "end"; - checkDrl( drl ); + checkDrl(kieBaseTestConfiguration, drl); } } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NullCheckOnExistentialNodeTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NullCheckOnExistentialNodeTest.java index da0c638eb85..42443680951 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NullCheckOnExistentialNodeTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NullCheckOnExistentialNodeTest.java @@ -18,14 +18,13 @@ */ package org.drools.mvel.integrationtests; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.rule.FactHandle; @@ -33,18 +32,10 @@ import static org.assertj.core.api.Assertions.assertThat; // DROOLS-4295 -@RunWith(Parameterized.class) public class NullCheckOnExistentialNodeTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public NullCheckOnExistentialNodeTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } public static class A { @@ -71,7 +62,7 @@ public String getValue() { } } - private void check( String drl, int fire1, int fire2 ) { + private void check( KieBaseTestConfiguration kieBaseTestConfiguration, String drl, int fire1, int fire2 ) { KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, drl); KieSession kieSession = kbase.newKieSession(); @@ -93,8 +84,9 @@ private void check( String drl, int fire1, int fire2 ) { assertThat(kieSession.fireAllRules()).isEqualTo(fire2); } - @Test - public void testNot() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNot(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "import " + A.class.getCanonicalName() + ";\n" + "import " + B.class.getCanonicalName() + ";\n" + @@ -106,11 +98,12 @@ public void testNot() { " then\n" + "end"; - check( drl, 0, 1 ); + check(kieBaseTestConfiguration, drl, 0, 1 ); } - @Test - public void testExists() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExists(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "import " + A.class.getCanonicalName() + ";\n" + "import " + B.class.getCanonicalName() + ";\n" + @@ -122,11 +115,12 @@ public void testExists() { " then\n" + "end"; - check( drl, 1, 0 ); + check( kieBaseTestConfiguration, drl, 1, 0 ); } - @Test - public void testNotIndexable() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNotIndexable(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "import " + NullCheckOnExistentialNodeTest.class.getCanonicalName() + ";\n" + "import " + A.class.getCanonicalName() + ";\n" + @@ -139,7 +133,7 @@ public void testNotIndexable() { " then\n" + "end"; - check( drl, 0, 1 ); + check( kieBaseTestConfiguration, drl, 0, 1 ); } public static boolean myPredicate(String s1, String s2) { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NullSafeDereferencingTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NullSafeDereferencingTest.java index ea031126f54..edcdc2764f1 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NullSafeDereferencingTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NullSafeDereferencingTest.java @@ -19,39 +19,30 @@ package org.drools.mvel.integrationtests; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.mvel.compiler.Address; import org.drools.mvel.compiler.Person; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class NullSafeDereferencingTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public NullSafeDereferencingTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testNullSafeBinding() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNullSafeBinding(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.*;\n" + "rule R1 when\n" + " Person( $streetName : address!.street ) \n" + @@ -75,8 +66,9 @@ public void testNullSafeBinding() { ksession.dispose(); } - @Test - public void testNullSafeNullComparison() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNullSafeNullComparison(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.*;\n" + "rule R1 when\n" + " Person( address!.street == null ) \n" + @@ -100,8 +92,9 @@ public void testNullSafeNullComparison() { ksession.dispose(); } - @Test - public void testNullSafeNullComparison2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNullSafeNullComparison2(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.*;\n" + "rule R1 when\n" + " $street : String()\n"+ @@ -127,8 +120,9 @@ public void testNullSafeNullComparison2() { ksession.dispose(); } - @Test - public void testNullSafeWithMethod() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNullSafeWithMethod(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-4095 String str = "import org.drools.mvel.compiler.*;\n" + "rule R1 when\n" + @@ -155,8 +149,9 @@ public void testNullSafeWithMethod() { ksession.dispose(); } - @Test - public void testNullSafeNullComparisonReverse() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNullSafeNullComparisonReverse(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-82 String str = "import org.drools.mvel.compiler.*;\n" + @@ -182,8 +177,9 @@ public void testNullSafeNullComparisonReverse() { ksession.dispose(); } - @Test - public void testNullSafeNullComparisonReverseComplex() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNullSafeNullComparisonReverseComplex(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-82 String str = "import org.drools.mvel.compiler.*;\n" + @@ -209,8 +205,9 @@ public void testNullSafeNullComparisonReverseComplex() { ksession.dispose(); } - @Test - public void testDoubleNullSafe() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDoubleNullSafe(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.*;\n" + "rule R1 when\n" + " Person( address!.street!.length > 15 ) \n" + @@ -238,8 +235,9 @@ public void testDoubleNullSafe() { ksession.dispose(); } - @Test - public void testMixedNullSafes() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMixedNullSafes(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "import org.drools.mvel.compiler.*;\n" + "rule R1 when\n" + " $p : Person( " + @@ -275,8 +273,9 @@ public void testMixedNullSafes() { ksession.dispose(); } - @Test - public void testNullSafeMemberOf() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNullSafeMemberOf(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-50 String str = "declare A\n" + @@ -301,8 +300,9 @@ public void testNullSafeMemberOf() { ksession.dispose(); } - @Test - public void testNullSafeInnerConstraint() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNullSafeInnerConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "declare Content\n" + " complexContent : Content\n" + @@ -342,8 +342,9 @@ public void testNullSafeInnerConstraint() { ksession.dispose(); } - @Test - public void testNullSafeNestedAccessors() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNullSafeNestedAccessors(KieBaseTestConfiguration kieBaseTestConfiguration) { String str = "package org.drools.test; " + "import " + Person.class.getName() + "; " + "global java.util.List list; " + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NullTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NullTest.java index 97b7d0a6c31..da24c8ce52d 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NullTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/NullTest.java @@ -20,8 +20,8 @@ import java.math.BigDecimal; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.mvel.compiler.Attribute; import org.drools.mvel.compiler.Cheese; @@ -32,31 +32,24 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class NullTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public NullTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - // TODO: EM failed with some tests. File JIRAs - return TestParametersUtil.getKieBaseCloudConfigurations(false); + public static Stream parameters() { + // TODO: EM failed with some tests. File JIRAs + return TestParametersUtil2.getKieBaseCloudConfigurations(false).stream(); } - @Test - public void testNullValuesIndexing() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNullValuesIndexing(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_NullValuesIndexing.drl"); KieSession ksession = kbase.newKieSession(); @@ -74,8 +67,9 @@ public void testNullValuesIndexing() throws Exception { assertThat(pete.getStatus()).as("Indexing with null values is not working correctly.").isEqualTo("OK"); } - @Test - public void testNullBehaviour() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNullBehaviour(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "null_behaviour.drl"); KieSession session = kbase.newKieSession(); @@ -88,8 +82,9 @@ public void testNullBehaviour() throws Exception { session.fireAllRules(); } - @Test - public void testNullConstraint() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNullConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "null_constraint.drl"); KieSession session = kbase.newKieSession(); @@ -108,8 +103,9 @@ public void testNullConstraint() throws Exception { assertThat(((List) session.getGlobal("messages")).size()).isEqualTo(2); } - @Test - public void testNullBinding() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNullBinding(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_nullBindings.drl"); KieSession ksession = kbase.newKieSession(); @@ -126,8 +122,9 @@ public void testNullBinding() throws Exception { assertThat(list.get(0)).isEqualTo("OK"); } - @Test - public void testNullConstantLeft() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNullConstantLeft(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3627 final String str = "import org.drools.mvel.compiler.*;\n" + "rule R1 when\n" + @@ -145,8 +142,9 @@ public void testNullConstantLeft() { ksession.dispose(); } - @Test - public void testNullFieldOnCompositeSink() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNullFieldOnCompositeSink(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_NullFieldOnCompositeSink.drl"); KieSession ksession = kbase.newKieSession(); @@ -162,8 +160,9 @@ public void testNullFieldOnCompositeSink() throws Exception { assertThat(((List) ksession.getGlobal("list")).get(0)).isEqualTo("X"); } - @Test - public void testNullHandling() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNullHandling(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_NullHandling.drl"); KieSession session = kbase.newKieSession(); @@ -194,8 +193,9 @@ public void testNullHandling() throws Exception { assertThat(((List) session.getGlobal("list")).size()).isEqualTo(4); } - @Test - public void testNullHashing() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNullHashing(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_NullHashing.drl"); KieSession ksession = kbase.newKieSession(); @@ -211,8 +211,9 @@ public void testNullHashing() throws Exception { assertThat(results.size()).isEqualTo(3); } - @Test - public void testBindingToNullFieldWithEquality() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBindingToNullFieldWithEquality(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3396 final String str = "package org.drools.mvel.compiler.test; \n" + "\n" + @@ -251,8 +252,9 @@ public void testBindingToNullFieldWithEquality() { ksession.dispose(); } - @Test - public void testArithmeticExpressionWithNull() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testArithmeticExpressionWithNull(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3568 final String str = "import " + PrimitiveBean.class.getCanonicalName() + ";\n" + "rule R when\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ObjectTypeNodeTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ObjectTypeNodeTest.java index 1fb7283169e..8df563fa121 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ObjectTypeNodeTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ObjectTypeNodeTest.java @@ -18,33 +18,25 @@ */ package org.drools.mvel.integrationtests; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; -@RunWith(Parameterized.class) public class ObjectTypeNodeTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public ObjectTypeNodeTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testDeterministicOTNOrdering() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeterministicOTNOrdering(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // JBRULES-3632 String str = "package indexingproblem.remove.me.anditworks;\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/OutOfMemoryTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/OutOfMemoryTest.java index e5d6b4933b4..f937c8f7fad 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/OutOfMemoryTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/OutOfMemoryTest.java @@ -19,8 +19,8 @@ package org.drools.mvel.integrationtests; import java.io.FileWriter; -import java.util.Collection; import java.util.HashMap; +import java.util.stream.Stream; import org.drools.core.SessionConfiguration; import org.drools.kiesession.debug.SessionInspector; @@ -29,15 +29,13 @@ import org.drools.mvel.compiler.Person; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.runtime.KieSession; -import org.kie.api.runtime.conf.KeepReferenceOption; import org.kie.api.runtime.rule.FactHandle; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,18 +43,10 @@ import static org.assertj.core.api.Assertions.fail; /** Run all the tests with the ReteOO engine implementation */ -@RunWith(Parameterized.class) public class OutOfMemoryTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public OutOfMemoryTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } private static Logger logger = LoggerFactory.getLogger(OutOfMemoryTest.class); @@ -65,9 +55,10 @@ public static Collection getParameters() { * This test can take a while (> 1 minute). * @throws Exception */ - @Test - @Ignore - public void testStatefulSessionsCreation() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Disabled + public void testStatefulSessionsCreation(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_OutOfMemoryError.drl"); int i = 0; @@ -87,9 +78,10 @@ public void testStatefulSessionsCreation() throws Exception { } - @Test - @Ignore - public void testAgendaLoop() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Disabled + public void testAgendaLoop(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_OutOfMemoryError.drl"); KieSession ksession = kbase.newKieSession(); @@ -103,9 +95,10 @@ public void testAgendaLoop() throws Exception { //Thread.currentThread().wait(); } - @Test - @Ignore("dump_tuples.mvel no longer seems to work") - public void testMemoryLeak() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Disabled("dump_tuples.mvel no longer seems to work") + public void testMemoryLeak(KieBaseTestConfiguration kieBaseTestConfiguration) { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_MemoryLeak.drl"); KieSession ksession = kbase.newKieSession(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PackageInMultipleResourcesTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PackageInMultipleResourcesTest.java index f30b5f4c213..665f16b7143 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PackageInMultipleResourcesTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PackageInMultipleResourcesTest.java @@ -18,37 +18,29 @@ */ package org.drools.mvel.integrationtests; -import java.util.Collection; import java.util.List; import java.util.stream.Collectors; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.definition.KiePackage; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class PackageInMultipleResourcesTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public PackageInMultipleResourcesTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testSamePackageRulesInDRLAndRF() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSamePackageRulesInDRLAndRF(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-6785 KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "rf_test_rules.drl", "rf_test_rueflow.rf"); @@ -59,8 +51,9 @@ public void testSamePackageRulesInDRLAndRF() { assertThat(ruleNames).contains("RuleFlow-Split-example-xxx-DROOLS_DEFAULT", "Left Rule", "Right Rule"); } - @Test - public void testDifferentPackagesRulesInDRLAndRF() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDifferentPackagesRulesInDRLAndRF(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-6797 KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "rf_test_rules_different_pkg.drl", "rf_test_rueflow.rf"); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ParallelBuildTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ParallelBuildTest.java index 08c0b8685b6..e9d7942828e 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ParallelBuildTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ParallelBuildTest.java @@ -19,32 +19,23 @@ package org.drools.mvel.integrationtests; import java.util.Arrays; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.Message; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class ParallelBuildTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public ParallelBuildTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } private final List> classes = Arrays.asList( @@ -62,8 +53,9 @@ public static Collection getParameters() { java.io.File.class ); - @Test - public void testParallelBuild() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testParallelBuild(KieBaseTestConfiguration kieBaseTestConfiguration) { StringBuilder sb = new StringBuilder(); int rc = 0; for (Class c : classes) { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ParallelCompilationTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ParallelCompilationTest.java index 7d9720e05c0..9a6581451d9 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ParallelCompilationTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ParallelCompilationTest.java @@ -27,18 +27,18 @@ import java.util.concurrent.ExecutorCompletionService; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; -@RunWith(Parameterized.class) public class ParallelCompilationTest { private static final int PARALLEL_THREADS = 5; @@ -46,29 +46,24 @@ public class ParallelCompilationTest { private ExecutorService executor; - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public ParallelCompilationTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Before + @BeforeEach public void setUp() throws Exception { executor = Executors.newFixedThreadPool(PARALLEL_THREADS); } - @After + @AfterEach public void tearDown() throws Exception { executor.shutdownNow(); } - @Test(timeout=10000) - public void testConcurrentRuleAdditions() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testConcurrentRuleAdditions(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { parallelExecute(BuildExecutor.getSolvers(kieBaseTestConfiguration)); } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ParallelEvaluationTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ParallelEvaluationTest.java index c6e5a5f9fcf..2c620922ea9 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ParallelEvaluationTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ParallelEvaluationTest.java @@ -22,35 +22,25 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.builder.KieModule; import org.kie.api.runtime.KieSession; import org.kie.internal.conf.ParallelExecutionOption; import java.util.Arrays; -import java.util.Collection; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class ParallelEvaluationTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public ParallelEvaluationTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } private String getRule(int i, String rhs) { @@ -76,8 +66,9 @@ private String getNotRule(int i) { "end\n"; } - @Test - public void testSalience() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSalience(KieBaseTestConfiguration kieBaseTestConfiguration) { int ruleNr = 20; StringBuilder sb = new StringBuilder( 400 ); sb.append( "global java.util.List list;\n" ); @@ -106,8 +97,9 @@ public void testSalience() { assertThat(list).isEqualTo(expected); } - @Test - public void testSalienceWithInserts() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSalienceWithInserts(KieBaseTestConfiguration kieBaseTestConfiguration) { int ruleNr = 20; StringBuilder sb = new StringBuilder( 400 ); sb.append( "global java.util.List list;\n" ); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ParallelExecutionTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ParallelExecutionTest.java index aa93a943854..ef2c04abeba 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ParallelExecutionTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ParallelExecutionTest.java @@ -33,11 +33,11 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.builder.KieModule; import org.kie.api.runtime.KieSession; @@ -48,29 +48,30 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.List; -import java.util.concurrent.*; +import java.util.concurrent.Callable; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class ParallelExecutionTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public ParallelExecutionTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test(timeout = 40000L) - public void test() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void test(KieBaseTestConfiguration kieBaseTestConfiguration) { StringBuilder sb = new StringBuilder( 400 ); sb.append( "global java.util.List list;\n" ); for (int i = 0; i < 10; i++) { @@ -100,8 +101,10 @@ public void test() { assertThat(list.size()).isEqualTo(10); } - @Test(timeout = 40000L) - public void testWithInsertions() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void testWithInsertions(KieBaseTestConfiguration kieBaseTestConfiguration) { StringBuilder sb = new StringBuilder( 4000 ); sb.append( "global java.util.List list;\n" ); int ruleNr = 200; @@ -129,8 +132,10 @@ public void testWithInsertions() { assertThat(list.size()).isEqualTo(ruleNr); } - @Test(timeout = 40000L) - public void testWithDeletes() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void testWithDeletes(KieBaseTestConfiguration kieBaseTestConfiguration) { StringBuilder sb = new StringBuilder( 400 ); sb.append( "global java.util.List list;\n" ); for (int i = 1; i < 11; i++) { @@ -159,8 +164,10 @@ public void testWithDeletes() { assertThat(list.size()).isEqualTo(20); } - @Test(timeout = 40000L) - public void testWithAsyncInsertions() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void testWithAsyncInsertions(KieBaseTestConfiguration kieBaseTestConfiguration) { StringBuilder sb = new StringBuilder( 4000 ); sb.append( "global java.util.List list;\n" ); int ruleNr = 200; @@ -213,8 +220,10 @@ private String getNotRule(int i) { "end\n"; } - @Test(timeout = 40000L) - public void testFireUntilHalt() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void testFireUntilHalt(KieBaseTestConfiguration kieBaseTestConfiguration) { StringBuilder sb = new StringBuilder( 400 ); sb.append( "global java.util.List list;\n" ); for (int i = 0; i < 10; i++) { @@ -256,9 +265,11 @@ public void testFireUntilHalt() { } } - @Test(timeout = 40000L) - @Ignore("this test is failing on Jenkins but not locally, we need to figure out why") - public void testFireUntilHalt2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + @Disabled("this test is failing on Jenkins but not locally, we need to figure out why") + public void testFireUntilHalt2(KieBaseTestConfiguration kieBaseTestConfiguration) { int rulesNr = 4; int factsNr = 1; int fireNr = rulesNr * factsNr; @@ -360,8 +371,10 @@ public void setValue( int value ) { } } - @Test(timeout = 40000L) - public void testFireUntilHaltWithAsyncInsert() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void testFireUntilHaltWithAsyncInsert(KieBaseTestConfiguration kieBaseTestConfiguration) { StringBuilder sb = new StringBuilder( 400 ); sb.append( "global java.util.List list;\n" ); for (int i = 0; i < 10; i++) { @@ -405,8 +418,10 @@ public void testFireUntilHaltWithAsyncInsert() { } } - @Test(timeout = 40000L) - public void testDisableParallelismOnSinglePartition() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void testDisableParallelismOnSinglePartition(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "rule R1 when\n" + " $i : Integer( this == 4 )" + @@ -431,8 +446,10 @@ public void testDisableParallelismOnSinglePartition() { assertThat(((InternalWorkingMemory) ksession).getAgenda().isParallelAgenda()).isFalse(); } - @Test(timeout = 40000L) - public void testEventsExpiration() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void testEventsExpiration(KieBaseTestConfiguration kieBaseTestConfiguration) { StringBuilder sb = new StringBuilder( 400 ); sb.append( "global java.util.List list;\n" ); sb.append( "import " + MyEvent.class.getCanonicalName() + ";\n" ); @@ -444,7 +461,7 @@ public void testEventsExpiration() { KieSessionConfiguration sessionConfig = RuleBaseFactory.newKnowledgeSessionConfiguration(); sessionConfig.setOption( ClockTypeOption.get( ClockType.PSEUDO_CLOCK.getId() ) ); - KieBaseTestConfiguration streamConfig = TestParametersUtil.getStreamInstanceOf(kieBaseTestConfiguration); + KieBaseTestConfiguration streamConfig = TestParametersUtil2.getStreamInstanceOf(kieBaseTestConfiguration); final KieModule kieModule = KieUtil.getKieModuleFromDrls("test", streamConfig, sb.toString()); final KieBase kbase = KieBaseUtil.newKieBaseFromKieModuleWithAdditionalOptions(kieModule, streamConfig, ParallelExecutionOption.FULLY_PARALLEL ); KieSession ksession = kbase.newKieSession(sessionConfig, null); @@ -475,8 +492,10 @@ public void testEventsExpiration() { assertThat(ksession.getFactCount()).isEqualTo(0L); } - @Test(timeout = 40000L) - public void testImmediateEventsExpiration() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void testImmediateEventsExpiration(KieBaseTestConfiguration kieBaseTestConfiguration) { StringBuilder sb = new StringBuilder( 400 ); sb.append( "global java.util.List list;\n" ); sb.append( "import " + MyEvent.class.getCanonicalName() + ";\n" ); @@ -488,7 +507,7 @@ public void testImmediateEventsExpiration() { KieSessionConfiguration sessionConfig = RuleBaseFactory.newKnowledgeSessionConfiguration(); sessionConfig.setOption( ClockTypeOption.get( ClockType.PSEUDO_CLOCK.getId() ) ); - KieBaseTestConfiguration streamConfig = TestParametersUtil.getStreamInstanceOf(kieBaseTestConfiguration); + KieBaseTestConfiguration streamConfig = TestParametersUtil2.getStreamInstanceOf(kieBaseTestConfiguration); final KieModule kieModule = KieUtil.getKieModuleFromDrls("test", streamConfig, sb.toString()); final KieBase kbase = KieBaseUtil.newKieBaseFromKieModuleWithAdditionalOptions(kieModule, streamConfig, ParallelExecutionOption.FULLY_PARALLEL ); KieSession ksession = kbase.newKieSession(sessionConfig, null); @@ -562,8 +581,10 @@ private String getRuleWithEventForExpiration(int i) { "end\n"; } - @Test(timeout = 40000L) - public void testFireUntilHaltWithExpiration() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void testFireUntilHaltWithExpiration(KieBaseTestConfiguration kieBaseTestConfiguration) { StringBuilder sb = new StringBuilder( 400 ); sb.append( "global java.util.List list;\n" ); sb.append( "import " + MyEvent.class.getCanonicalName() + ";\n" ); @@ -582,7 +603,7 @@ public void testFireUntilHaltWithExpiration() { KieSessionConfiguration sessionConfig = RuleBaseFactory.newKnowledgeSessionConfiguration(); sessionConfig.setOption( ClockTypeOption.get( ClockType.PSEUDO_CLOCK.getId() ) ); - KieBaseTestConfiguration streamConfig = TestParametersUtil.getStreamInstanceOf(kieBaseTestConfiguration); + KieBaseTestConfiguration streamConfig = TestParametersUtil2.getStreamInstanceOf(kieBaseTestConfiguration); final KieModule kieModule = KieUtil.getKieModuleFromDrls("test", streamConfig, sb.toString()); final KieBase kbase = KieBaseUtil.newKieBaseFromKieModuleWithAdditionalOptions(kieModule, streamConfig, ParallelExecutionOption.FULLY_PARALLEL ); KieSession ksession = kbase.newKieSession(sessionConfig, null); @@ -650,9 +671,11 @@ public void testFireUntilHaltWithExpiration() { } } - @Test(timeout = 40000L) - @Ignore("this test is failing on Jenkins but not locally, we need to figure out why") - public void testFireUntilHaltWithExpiration2() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + @Disabled("this test is failing on Jenkins but not locally, we need to figure out why") + public void testFireUntilHaltWithExpiration2(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { String drl = "import " + A.class.getCanonicalName() + "\n" + "import " + B.class.getCanonicalName() + "\n" + @@ -692,7 +715,7 @@ public void testFireUntilHaltWithExpiration2() throws InterruptedException { KieSessionConfiguration sessionConfig = RuleBaseFactory.newKnowledgeSessionConfiguration(); sessionConfig.setOption( ClockTypeOption.get( ClockType.PSEUDO_CLOCK.getId() ) ); - KieBaseTestConfiguration streamConfig = TestParametersUtil.getStreamInstanceOf(kieBaseTestConfiguration); + KieBaseTestConfiguration streamConfig = TestParametersUtil2.getStreamInstanceOf(kieBaseTestConfiguration); final KieModule kieModule = KieUtil.getKieModuleFromDrls("test", streamConfig, drl); final KieBase kbase = KieBaseUtil.newKieBaseFromKieModuleWithAdditionalOptions(kieModule, streamConfig, ParallelExecutionOption.FULLY_PARALLEL ); KieSession ksession = kbase.newKieSession(sessionConfig, null); @@ -725,8 +748,10 @@ public void testFireUntilHaltWithExpiration2() throws InterruptedException { } } - @Test(timeout = 40000L) - public void testWithUpdates() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void testWithUpdates(KieBaseTestConfiguration kieBaseTestConfiguration) { StringBuilder sb = new StringBuilder( 400 ); sb.append( "global java.util.List list;\n" ); for (int i = 0; i < 10; i++) { @@ -762,8 +787,10 @@ public void testWithUpdates() { assertThat(list.size()).isEqualTo(10); } - @Test(timeout = 40000L) - public void testDisableParallelismWithAgendaGroups() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void testDisableParallelismWithAgendaGroups(KieBaseTestConfiguration kieBaseTestConfiguration) { StringBuilder sb = new StringBuilder( 400 ); sb.append( "global java.util.List list;\n" ); sb.append( "rule first\n" + @@ -796,8 +823,10 @@ public void testDisableParallelismWithAgendaGroups() { assertThat(list.size()).isEqualTo(10); } - @Test(timeout = 40000L) - public void testDisableParallelismWithSalience() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void testDisableParallelismWithSalience(KieBaseTestConfiguration kieBaseTestConfiguration) { StringBuilder sb = new StringBuilder( 400 ); sb.append( "global java.util.List list;\n" ); for (int i = 0; i < 10; i++) { @@ -826,8 +855,10 @@ public void testDisableParallelismWithSalience() { assertThat(Arrays.asList(9, 8, 7, 6, 5, 4, 3, 2, 1, 0)).isEqualTo(list); } - @Test(timeout = 40000L) - public void testMultipleParallelKieSessionsWithInsertions() throws InterruptedException, ExecutionException, TimeoutException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void testMultipleParallelKieSessionsWithInsertions(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException, ExecutionException, TimeoutException { final int NUMBER_OF_PARALLEL_SESSIONS = 5; /* Create KIE base */ @@ -870,8 +901,10 @@ private Callable getMultipleParallelKieSessionsWithInsertionsCallable(KieB }; } - @Test(timeout = 40000L) - public void testMultipleParallelKieSessionsWithUpdates() throws InterruptedException, ExecutionException, TimeoutException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void testMultipleParallelKieSessionsWithUpdates(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException, ExecutionException, TimeoutException { final int NUMBER_OF_PARALLEL_SESSIONS = 5; /* Create KIE base */ @@ -923,8 +956,10 @@ private Callable getMultipleParallelKieSessionsWithUpdatesCallable(KieBase }; } - @Test(timeout = 40000L) - public void testMultipleParallelKieSessionsWithDeletes() throws InterruptedException, ExecutionException, TimeoutException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void testMultipleParallelKieSessionsWithDeletes(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException, ExecutionException, TimeoutException { final int NUMBER_OF_PARALLEL_SESSIONS = 5; /* Create KIE base */ @@ -969,8 +1004,10 @@ private Callable getMultipleParallelKieSessionsWithDeletesCallable(KieBase }; } - @Test(timeout = 40000L) - public void testMultipleParallelKieSessionsFireUntilHalt() throws InterruptedException, ExecutionException, TimeoutException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void testMultipleParallelKieSessionsFireUntilHalt(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException, ExecutionException, TimeoutException { final int NUMBER_OF_PARALLEL_SESSIONS = 5; /* Create KIE base */ @@ -1031,8 +1068,10 @@ private Callable getMultipleParallelKieSessionsFireUntilHaltCallable(KieBa }; } - @Test(timeout = 40000L) - public void testMultipleParallelKieSessionsFireUntilHaltWithAsyncInsert() throws InterruptedException, ExecutionException, TimeoutException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(40000) + public void testMultipleParallelKieSessionsFireUntilHaltWithAsyncInsert(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException, ExecutionException, TimeoutException { final int NUMBER_OF_PARALLEL_SESSIONS = 5; /* Create KIE base */ diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ParserTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ParserTest.java index 48e302c8a31..c13f104f11e 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ParserTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/ParserTest.java @@ -24,7 +24,7 @@ import org.drools.compiler.compiler.DescrBuildError; import org.drools.drl.parser.DrlParser; import org.drools.drl.parser.ParserError; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.io.ResourceType; import org.kie.internal.builder.KnowledgeBuilder; import org.kie.internal.builder.KnowledgeBuilderError; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PassiveQueryTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PassiveQueryTest.java index 69619b86107..e26f203f6ff 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PassiveQueryTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PassiveQueryTest.java @@ -19,8 +19,8 @@ package org.drools.mvel.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.core.common.InternalWorkingMemory; import org.drools.core.common.Memory; @@ -32,10 +32,9 @@ import org.drools.core.reteoo.Rete; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.rule.FactHandle; @@ -43,22 +42,15 @@ import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class PassiveQueryTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public PassiveQueryTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testPassiveQuery() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPassiveQuery(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "global java.util.List list\n" + "query Q (Integer i)\n" + @@ -93,8 +85,9 @@ public void testPassiveQuery() throws Exception { assertThat((int) list.get(0)).isEqualTo(2); } - @Test - public void testPassiveQueryNoDataDriven() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPassiveQueryNoDataDriven(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "global java.util.List list\n" + "query Q (Integer i)\n" + @@ -119,8 +112,9 @@ public void testPassiveQueryNoDataDriven() throws Exception { assertThat(list.size()).isEqualTo(1); } - @Test - public void testPassiveQueryDataDriven() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPassiveQueryDataDriven(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "global java.util.List list\n" + "query Q (Integer i)\n" + @@ -145,8 +139,9 @@ public void testPassiveQueryDataDriven() throws Exception { assertThat(list.size()).isEqualTo(0); } - @Test - public void testReactiveQueryDataDriven() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testReactiveQueryDataDriven(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "global java.util.List list\n" + "query Q (Integer i)\n" + @@ -171,8 +166,9 @@ public void testReactiveQueryDataDriven() throws Exception { assertThat(list.size()).isEqualTo(1); } - @Test - public void testPassiveQueryDataDrivenWithBeta() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPassiveQueryDataDrivenWithBeta(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "global java.util.List list\n" + "query Q (Integer i)\n" + @@ -199,8 +195,9 @@ public void testPassiveQueryDataDrivenWithBeta() throws Exception { assertThat(list.size()).isEqualTo(0); } - @Test - public void testPassiveQueryNodeSharing() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPassiveQueryNodeSharing(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "global java.util.List list\n" + "query Q (Integer i)\n" + @@ -232,8 +229,9 @@ public void testPassiveQueryNodeSharing() throws Exception { assertThat(list.get(0)).isEqualTo("R2"); } - @Test - public void testPassiveQueryNodeSharing2() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPassiveQueryNodeSharing2(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "global java.util.List list\n" + "query Q (Integer i)\n" + @@ -278,8 +276,9 @@ public void testPassiveQueryNodeSharing2() throws Exception { assertThat(list.containsAll(asList("R2a", "R2b"))).isTrue(); } - @Test - public void testPassiveQueryUsingSegmentPropagator() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPassiveQueryUsingSegmentPropagator(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "global java.util.List list\n" + "query Q (Integer i)\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PathEndNodeTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PathEndNodeTest.java index a42bdef04fe..a90ce62e670 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PathEndNodeTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PathEndNodeTest.java @@ -18,7 +18,7 @@ */ package org.drools.mvel.integrationtests; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.base.base.ClassObjectType; import org.drools.kiesession.rulebase.InternalKnowledgeBase; @@ -31,30 +31,22 @@ import org.drools.base.rule.EntryPointId; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class PathEndNodeTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public PathEndNodeTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testSubNetworkSharing() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSubNetworkSharing(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "package org.test \n" + "rule xxx \n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PhreakConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PhreakConcurrencyTest.java index ba9601a8ffc..2da4c2e653b 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PhreakConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PhreakConcurrencyTest.java @@ -42,8 +42,9 @@ import org.drools.core.reteoo.SegmentMemory; import org.drools.mvel.CommonTestMethodBase; import org.drools.mvel.compiler.StockTick; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.rule.EntryPoint; @@ -53,7 +54,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -@Ignore +@Disabled public class PhreakConcurrencyTest extends CommonTestMethodBase { // This test already fails with standard-drl (probably not maintained) so not enhanced for exec-model @@ -159,7 +160,8 @@ public Boolean call() throws Exception { } } - @Test(timeout = 10000) + @Test + @Timeout(10000) public void testMultipleConcurrentEPs2() { String str = "global java.util.List results\n" + "\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PolymorphismTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PolymorphismTest.java index 41dbe7c3bbc..801fdec66b9 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PolymorphismTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PolymorphismTest.java @@ -18,36 +18,28 @@ */ package org.drools.mvel.integrationtests; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.rule.FactHandle; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class PolymorphismTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public PolymorphismTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseStreamConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseStreamConfigurations(true).stream(); } - @Test - public void testModifySubclassOverWindow() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModifySubclassOverWindow(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1501 String drl = "declare Number @role( event ) end\n" + "declare Integer @role( event ) end\n" + @@ -70,8 +62,9 @@ public void testModifySubclassOverWindow() { assertThat(fired).isEqualTo(2); } - @Test - public void testModifySubclass() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModifySubclass(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1501 String drl = "import " + A.class.getCanonicalName() + "\n;" + "import " + B.class.getCanonicalName() + "\n;" + @@ -110,8 +103,9 @@ public void testModifySubclass() { assertThat(ksession.getObjects().size()).isEqualTo(0); } - @Test - public void testModifySubclass2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModifySubclass2(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1501 String drl = "import " + A.class.getCanonicalName() + "\n;" + "import " + B.class.getCanonicalName() + "\n;" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PropertyReactivityBlockerTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PropertyReactivityBlockerTest.java index 1bb13d108f1..ca466a114af 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PropertyReactivityBlockerTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PropertyReactivityBlockerTest.java @@ -19,10 +19,10 @@ package org.drools.mvel.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Stream; import org.drools.core.event.DebugAgendaEventListener; import org.drools.core.reteoo.ReteDumper; @@ -31,32 +31,24 @@ import org.drools.mvel.compiler.Person; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.rule.FactHandle; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class PropertyReactivityBlockerTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public PropertyReactivityBlockerTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test() - public void testA_NotWorking() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testA_NotWorking(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-644 String drl = "import " + Person.class.getCanonicalName() + ";\n" + @@ -90,8 +82,9 @@ public void testA_NotWorking() { assertThat(list.get(0)).isEqualTo("t0"); } - @Test() - public void testAbis_NotWorking() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAbis_NotWorking(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-644 String drl = "import " + Person.class.getCanonicalName() + ";\n" + @@ -133,8 +126,9 @@ public void testAbis_NotWorking() { assertThat(list.get(0)).isEqualTo("t0"); } - @Test() - public void testA_Working() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testA_Working(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-644 String drl = "import " + Person.class.getCanonicalName() + ";\n" + @@ -168,8 +162,9 @@ public void testA_Working() { assertThat(list.get(0)).isEqualTo("t0"); } - @Test() - public void testAbis_Working() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAbis_Working(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-644 String drl = "import " + Person.class.getCanonicalName() + ";\n" + @@ -210,8 +205,9 @@ public void testAbis_Working() { assertThat(list.get(0)).isEqualTo("t0"); } - @Test() - public void testUpdateRewrittenWithCorrectBitMaskAndCorrectClass() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUpdateRewrittenWithCorrectBitMaskAndCorrectClass(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "import " + Cell.class.getCanonicalName() + ";\n" + "import " + Neighbor.class.getCanonicalName() + ";\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PropertyReactivityTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PropertyReactivityTest.java index 68eafe9efa2..220014fde2b 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PropertyReactivityTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PropertyReactivityTest.java @@ -21,20 +21,19 @@ import java.math.BigDecimal; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; -import org.drools.kiesession.session.StatefulKnowledgeSessionImpl; import org.drools.mvel.compiler.Address; import org.drools.mvel.compiler.Person; import org.drools.mvel.compiler.State; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.Message; @@ -46,22 +45,16 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -@RunWith(Parameterized.class) public class PropertyReactivityTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public PropertyReactivityTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test(timeout=10000) - public void testComposedConstraint() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testComposedConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) { final String str = "package org.drools.test;\n" + "\n" + @@ -82,8 +75,10 @@ public void testComposedConstraint() { assertThat(k2.getD()).isEqualTo(1); } - @Test(timeout=10000) - public void testScrambleProperties() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testScrambleProperties(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-91 final String str = "package org.drools.test\n" + @@ -238,8 +233,10 @@ public Klass2( final int b, final int c, final int d, final int e ) { } - @Test(timeout=10000) - public void testScrambleWithInterfaces() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testScrambleWithInterfaces(KieBaseTestConfiguration kieBaseTestConfiguration) { /* * K1 a b c d e f 1000 * I1 c d f 10 @@ -327,8 +324,10 @@ public void testScrambleWithInterfaces() { assertThat(list.size()).isEqualTo(5); } - @Test(timeout=10000) - public void testScrambleWithInterfacesAndObject() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testScrambleWithInterfacesAndObject(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-91 final String str = "package org.drools.test;\n" + @@ -377,8 +376,10 @@ public void testScrambleWithInterfacesAndObject() { assertThat(list.get(1)).isEqualTo("Klass2"); } - @Test(timeout=10000) - public void testRepeatedPatternWithPR() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testRepeatedPatternWithPR(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3705 final String str1 = "package org.test;\n" + @@ -430,8 +431,10 @@ public void testRepeatedPatternWithPR() { assertThat(list.contains(new BigDecimal(5))).isTrue(); } - @Test(timeout=10000) - public void testPRWithCollections() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testPRWithCollections(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-135 final String str1 = "package org.test;\n" + "import java.util.*\n" + @@ -523,8 +526,10 @@ public void testPRWithCollections() { } - @Test(timeout=10000) - public void testPRWithPositionalUnification() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testPRWithPositionalUnification(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-247 final String str1 = "package org.test;\n" + @@ -602,12 +607,15 @@ public void testPRWithPositionalUnification() { * Tests the use of PR on constraints involving 'virtual' properties * of a POJO: calculated properties without a setter. * Because getFullName doesn't have a setter, and we are not using + * @param kieBaseTestConfiguration * @watch in the rule nor @Modified in setName() or in setLastName(), there * are no way that rule 'Find Heisenberg' gets activated because a modification * or a Klass3 object. */ - @Test(timeout=10000) - public void testPRConstraintOnAttributesWithoutSetter(){ + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testPRConstraintOnAttributesWithoutSetter(KieBaseTestConfiguration kieBaseTestConfiguration){ final String str = "package org.drools.test;\n" + "\n" + @@ -656,9 +664,12 @@ public void testPRConstraintOnAttributesWithoutSetter(){ * nor setLastName() @Modifies fullName. We are explicitly using @watches * in the rule involving fullName to be aware of modifications in the name * and/or lastName of a Klass3 object. + * @param kieBaseTestConfiguration */ - @Test(timeout=10000) - public void testPRConstraintOnAttributesWithoutSetterUsingWatches(){ + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testPRConstraintOnAttributesWithoutSetterUsingWatches(KieBaseTestConfiguration kieBaseTestConfiguration){ final String str = "package org.drools.test;\n" + "\n" + @@ -705,9 +716,12 @@ public void testPRConstraintOnAttributesWithoutSetterUsingWatches(){ * of a POJO: calculated properties without a setter. * getFullName doesn't have a setter but Klass4 states that setName() * and setLastName() both @Modifies fullName. + * @param kieBaseTestConfiguration */ - @Test(timeout=10000) - public void testPRConstraintOnAttributesWithoutSetterUsingModifies(){ + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testPRConstraintOnAttributesWithoutSetterUsingModifies(KieBaseTestConfiguration kieBaseTestConfiguration){ final String str = "package org.drools.test;\n" + "\n" + @@ -753,12 +767,15 @@ public void testPRConstraintOnAttributesWithoutSetterUsingModifies(){ * Tests the use of PR on bindings involving 'virtual' properties * of a POJO: calculated properties without a setter. * Because getFullName doesn't have a setter, and we are not using + * @param kieBaseTestConfiguration * @watch in the rule nor @Modified in setName() or in setLastName(), there * are no way that rule 'Get Person name' gets activated because a modification * or a Klass3 object. */ - @Test(timeout=10000) - public void testPRBindingOnAttributesWithoutSetter(){ + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testPRBindingOnAttributesWithoutSetter(KieBaseTestConfiguration kieBaseTestConfiguration){ final String str = "package org.drools.test;\n" + "\n" + @@ -806,9 +823,12 @@ public void testPRBindingOnAttributesWithoutSetter(){ * getFullName doesn't have a setter but we are explicitly using @watches * annotation in 'Get Person name' rule. After the name of Kalss3 instance is * modified, rule 'Get Person name' must be re-activated. + * @param kieBaseTestConfiguration */ - @Test(timeout=10000) - public void testPRBindingOnAttributesWithoutSetterUsingWatches(){ + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testPRBindingOnAttributesWithoutSetterUsingWatches(KieBaseTestConfiguration kieBaseTestConfiguration){ final String str = "package org.drools.test;\n" + "\n" + @@ -856,9 +876,12 @@ public void testPRBindingOnAttributesWithoutSetterUsingWatches(){ * getFullName doesn't have a setter but we are explicitly using @Modifies * in Klass4's setName() and setLastName(). After the name of Kalss4 * instance is modified, rule 'Get Person name' must be re-activated. + * @param kieBaseTestConfiguration */ - @Test(timeout=10000) - public void testPRBindingOnAttributesWithoutSetterUsingModifies(){ + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testPRBindingOnAttributesWithoutSetterUsingModifies(KieBaseTestConfiguration kieBaseTestConfiguration){ final String str = "package org.drools.test;\n" + "\n" + @@ -901,8 +924,10 @@ public void testPRBindingOnAttributesWithoutSetterUsingModifies(){ } - @Test(timeout=10000) - public void testPRBindingOnNonexistingAttributes(){ + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testPRBindingOnNonexistingAttributes(KieBaseTestConfiguration kieBaseTestConfiguration){ final String str = "package org.drools.test;\n" + "\n" + @@ -924,8 +949,10 @@ public void testPRBindingOnNonexistingAttributes(){ assertThat(errors.isEmpty()).as("Should have an error").isFalse(); } - @Test(timeout=10000) - public void testPRBindingOnNonexistingWatchedAttribute(){ + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testPRBindingOnNonexistingWatchedAttribute(KieBaseTestConfiguration kieBaseTestConfiguration){ final String str = "package org.drools.test;\n" + "\n" + @@ -946,8 +973,10 @@ public void testPRBindingOnNonexistingWatchedAttribute(){ assertThat(errors.isEmpty()).as("Should have an error").isFalse(); } - @Test(timeout=10000) - public void testModifyAfterInsertWithPropertyReactive() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testModifyAfterInsertWithPropertyReactive(KieBaseTestConfiguration kieBaseTestConfiguration) { final String rule1 = "\n" + "package com.sample;\n" + @@ -1082,8 +1111,10 @@ public String getFullName(){ } } - @Test(timeout=10000) - public void testIndexedNotWatchedProperty() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testIndexedNotWatchedProperty(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-569 final String rule1 = "package com.sample;\n" + @@ -1129,8 +1160,9 @@ public void testIndexedNotWatchedProperty() { assertThat(list.get(0)).isEqualTo("3"); } - @Test - public void testModifyWithGetter() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testModifyWithGetter(KieBaseTestConfiguration kieBaseTestConfiguration) { final String rule1 = "package foo.bar\n" + "import " + Person.class.getName() + "\n" + @@ -1155,8 +1187,10 @@ public void testModifyWithGetter() { assertThat(p.getAddress().getStreet()).isEqualTo("foo"); } - @Test(timeout = 10000L) - public void testMoreThan64Fields() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testMoreThan64Fields(KieBaseTestConfiguration kieBaseTestConfiguration) { final StringBuilder fields = new StringBuilder(); for (int i = 10; i < 100; i++) { fields.append(" a").append(i).append(" : int\n"); @@ -1188,8 +1222,10 @@ public void testMoreThan64Fields() { assertThat(list.size()).isEqualTo(1); } - @Test(timeout = 10000L) - public void testMoreThan64FieldsMultipleFirings() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testMoreThan64FieldsMultipleFirings(KieBaseTestConfiguration kieBaseTestConfiguration) { final StringBuilder fields = new StringBuilder(); for (int i = 10; i < 100; i++) { fields.append(" a").append(i).append(" : int\n"); @@ -1221,8 +1257,10 @@ public void testMoreThan64FieldsMultipleFirings() { assertThat(list.size()).isEqualTo(10); } - @Test(timeout = 10000L) - public void testMoreThan64FieldsWithWatch() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testMoreThan64FieldsWithWatch(KieBaseTestConfiguration kieBaseTestConfiguration) { final StringBuilder fields = new StringBuilder(); for (int i = 10; i < 100; i++) { fields.append(" a").append(i).append(" : int\n"); @@ -1254,8 +1292,9 @@ public void testMoreThan64FieldsWithWatch() { assertThat(list.size()).isEqualTo(1); } - @Test - public void testPropReactiveAnnotationOnDifferentDrl() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPropReactiveAnnotationOnDifferentDrl(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-800 final String str1 = "package org.jboss.ddoyle.drools.propertyreactive;\n" + @@ -1359,8 +1398,9 @@ public String toString() { } } - @Test - public void testPropReactiveWithParentClassNotImplementingChildInterface() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPropReactiveWithParentClassNotImplementingChildInterface(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1090 final String str1 = "import " + DummyBeanInterface.class.getCanonicalName() + "\n" + @@ -1401,8 +1441,9 @@ public void testPropReactiveWithParentClassNotImplementingChildInterface() { ksession.fireAllRules(); } - @Test - public void testPropReactiveUpdate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPropReactiveUpdate(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1275 final String str1 = "import " + Klass.class.getCanonicalName() + "\n" + @@ -1433,8 +1474,9 @@ public void testPropReactiveUpdate() { assertThat(list.size()).isEqualTo(2); } - @Test - public void testSetterInConcreteClass() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSetterInConcreteClass(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1368 final String drl = "import " + BaseFact.class.getCanonicalName() + ";\n" + "import " + MyFact.class.getCanonicalName() + ";\n" @@ -1508,8 +1550,9 @@ public Shuttle setDestination(final StopOrHub destination) { } - @Test - public void testSetterInConcreteClass2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSetterInConcreteClass2(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1369 final String drl = "package org.test;\n" + "import " + BusStop.class.getCanonicalName() + ";\n" @@ -1546,8 +1589,9 @@ public void testSetterInConcreteClass2() { assertThat(kieSession.fireAllRules()).isEqualTo(1); } - @Test - public void testWatchFieldInExternalPattern() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testWatchFieldInExternalPattern(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1445 final String drl = "import " + Person.class.getCanonicalName() + ";\n" + @@ -1578,8 +1622,9 @@ public void testWatchFieldInExternalPattern() { assertThat(list.get(0)).isEqualTo("t0"); } - @Test - public void testWatchFieldInExternalPatternWithNoConstraints() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testWatchFieldInExternalPatternWithNoConstraints(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-2333 final String drl = "import " + Person.class.getCanonicalName() + ";\n" + @@ -1610,8 +1655,9 @@ public void testWatchFieldInExternalPatternWithNoConstraints() { assertThat(list.get(0)).isEqualTo("t0"); } - @Test - public void testWatchFieldInExternalNotPattern() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testWatchFieldInExternalNotPattern(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1445 final String drl = "import " + Person.class.getCanonicalName() + ";\n" + @@ -1642,8 +1688,9 @@ public void testWatchFieldInExternalNotPattern() { assertThat(list.get(0)).isEqualTo("t0"); } - @Test - public void testPropertyChangeSupportNewAPI() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPropertyChangeSupportNewAPI(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_PropertyChangeTypeDecl.drl"); KieSession session = kbase.newKieSession(); @@ -1671,8 +1718,9 @@ public void testPropertyChangeSupportNewAPI() throws Exception { assertThat(state.getPropertyChangeListeners().length).isEqualTo(0); } - @Test - public void testAccumulateWithPR() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccumulateWithPR(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "declare A end\n" + " " + @@ -1694,8 +1742,9 @@ public void testAccumulateWithPR() { assertThat(errors.isEmpty()).as(errors.toString()).isTrue(); } - @Test - public void testUpdateOnNonExistingProperty() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUpdateOnNonExistingProperty(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-2170 final String str1 = "import " + Klass.class.getCanonicalName() + "\n" + @@ -1719,8 +1768,10 @@ public void testUpdateOnNonExistingProperty() { } } - @Test(timeout = 5000L) - public void testPRAfterAccumulate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testPRAfterAccumulate(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-2427 final String str1 = "import " + Order.class.getCanonicalName() + "\n" + @@ -1805,8 +1856,9 @@ public void setAnother( int another ) { } } - @Test - public void testGetterWithoutArgShouldBePropReactve() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGetterWithoutArgShouldBePropReactve(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-4288 final String str1 = "import " + StrangeGetter.class.getCanonicalName() + "\n" + @@ -1826,8 +1878,9 @@ public void testGetterWithoutArgShouldBePropReactve() { assertThat(ksession.fireAllRules(3)).isEqualTo(1); } - @Test - public void testGetterWithArgShouldNotBePropReactve() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGetterWithArgShouldNotBePropReactve(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-4288 final String str1 = "import " + StrangeGetter.class.getCanonicalName() + "\n" + @@ -1847,8 +1900,9 @@ public void testGetterWithArgShouldNotBePropReactve() { assertThat(ksession.fireAllRules(3)).isEqualTo(3); } - @Test - public void testComment() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testComment(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-3583 final String str1 = "package com.example\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PropertySpecificTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PropertySpecificTest.java index b2f09b3de22..771422916f3 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PropertySpecificTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PropertySpecificTest.java @@ -21,12 +21,12 @@ import java.math.BigDecimal; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.EnumMap; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Stream; import org.drools.base.base.ClassObjectType; import org.drools.core.common.InternalWorkingMemory; @@ -45,10 +45,10 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.Message.Level; @@ -57,22 +57,16 @@ import org.kie.api.definition.type.PropertyReactive; import org.kie.api.runtime.KieSession; -import static org.assertj.core.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.assertj.core.api.Assertions.within; import static org.drools.base.reteoo.PropertySpecificUtil.calculateNegativeMask; import static org.drools.base.reteoo.PropertySpecificUtil.calculatePositiveMask; -@RunWith(Parameterized.class) public class PropertySpecificTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public PropertySpecificTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } public static List getSettableProperties(InternalWorkingMemory workingMemory, ObjectTypeNode objectTypeNode) { @@ -88,8 +82,9 @@ public static Class getNodeClass( ObjectTypeNode objectTypeNode ) { return objectType instanceof ClassObjectType ? ((ClassObjectType)objectType).getClassType() : null; } - @Test - public void testRTNodeEmptyLHS() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRTNodeEmptyLHS(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule = "package org.drools.mvel.integrationtests\n" + "rule r1\n" + "when\n" + @@ -108,8 +103,9 @@ public void testRTNodeEmptyLHS() { assertThat(rtNode.getInferredMask()).isEqualTo(AllSetBitMask.get()); } - @Test - public void testRTNodeNoConstraintsNoPropertySpecific() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRTNodeNoConstraintsNoPropertySpecific(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule = "package org.drools.mvel.integrationtests\n" + "import " + Person.class.getCanonicalName() + "\n" + "rule r1\n" + @@ -134,8 +130,9 @@ public void testRTNodeNoConstraintsNoPropertySpecific() { assertThat(rtNode.getInferredMask()).isEqualTo(AllSetBitMask.get()); } - @Test - public void testRTNodeWithConstraintsNoPropertySpecific() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRTNodeWithConstraintsNoPropertySpecific(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule = "package org.drools.mvel.integrationtests\n" + "import " + Person.class.getCanonicalName() + "\n" + "rule r1\n" + @@ -165,8 +162,9 @@ public void testRTNodeWithConstraintsNoPropertySpecific() { assertThat(rtNode.getInferredMask()).isEqualTo(AllSetBitMask.get()); } - @Test - public void testBetaNodeNoConstraintsNoPropertySpecific() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBetaNodeNoConstraintsNoPropertySpecific(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule = "package org.drools.mvel.integrationtests\n" + "import " + Person.class.getCanonicalName() + "\n" + "import " + Cheese.class.getCanonicalName() + "\n" + @@ -192,8 +190,9 @@ public void testBetaNodeNoConstraintsNoPropertySpecific() { assertThat(betaNode.getRightInferredMask()).isEqualTo(AllSetBitMask.get()); } - @Test - public void testBetaNodeWithConstraintsNoPropertySpecific() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBetaNodeWithConstraintsNoPropertySpecific(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule = "package org.drools.mvel.integrationtests\n" + "import " + Person.class.getCanonicalName() + "\n" + "import " + Cheese.class.getCanonicalName() + "\n" + @@ -223,8 +222,9 @@ public void testBetaNodeWithConstraintsNoPropertySpecific() { assertThat(betaNode.getRightInferredMask()).isEqualTo(AllSetBitMask.get()); } - @Test - public void testInitialFactBetaNodeWithRightInputAdapter() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInitialFactBetaNodeWithRightInputAdapter(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule = "package org.drools.mvel.integrationtests\n" + "import " + Person.class.getCanonicalName() + "\n" + "import " + Cheese.class.getCanonicalName() + "\n" + @@ -248,8 +248,9 @@ public void testInitialFactBetaNodeWithRightInputAdapter() { assertThat(betaNode.getRightInferredMask()).isEqualTo(AllSetBitMask.get()); } - @Test - public void testPersonFactBetaNodeWithRightInputAdapter() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPersonFactBetaNodeWithRightInputAdapter(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule = "package org.drools.mvel.integrationtests\n" + "import " + Person.class.getCanonicalName() + "\n" + "import " + Cheese.class.getCanonicalName() + "\n" + @@ -281,8 +282,9 @@ public void testPersonFactBetaNodeWithRightInputAdapter() { assertThat(betaNode.getRightInferredMask()).isEqualTo(AllSetBitMask.get()); } - @Test - public void testSharedAlphanodeWithBetaNodeConstraintsNoPropertySpecific() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSharedAlphanodeWithBetaNodeConstraintsNoPropertySpecific(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule = "package org.drools.mvel.integrationtests\n" + "import " + Person.class.getCanonicalName() + "\n" + "import " + Cheese.class.getCanonicalName() + "\n" + @@ -336,7 +338,7 @@ public void testSharedAlphanodeWithBetaNodeConstraintsNoPropertySpecific() { } - private KieBase getKnowledgeBase(String... rules) { + private KieBase getKnowledgeBase(KieBaseTestConfiguration kieBaseTestConfiguration, String... rules) { String rule = "package org.drools.mvel.integrationtests\n" + "global java.util.List list;\n" + "declare A\n" + @@ -379,10 +381,11 @@ private KieBase getKnowledgeBase(String... rules) { return kbase; } - @Test - public void testRtnNoConstraintsNoWatches() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRtnNoConstraintsNoWatches(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "A()"; - KieBase kbase = getKnowledgeBase(rule1); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration,rule1); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); ObjectTypeNode otn = getObjectTypeNode(kbase, "A" ); @@ -395,10 +398,11 @@ public void testRtnNoConstraintsNoWatches() { assertThat(rtNode.getInferredMask()).isEqualTo(EmptyBitMask.get()); } - @Test - public void testRtnNoConstraintsWithWatches() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRtnNoConstraintsWithWatches(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "A() @watch(a)"; - KieBase kbase = getKnowledgeBase(rule1); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); ObjectTypeNode otn = getObjectTypeNode(kbase, "A" ); @@ -413,10 +417,11 @@ public void testRtnNoConstraintsWithWatches() { assertThat(rtNode.getInferredMask()).isEqualTo(calculatePositiveMask(otn.getObjectType(), list("a"), sp)); } - @Test - public void testRtnWithConstraintsNoWatches() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRtnWithConstraintsNoWatches(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "A( a == 10 )"; - KieBase kbase = getKnowledgeBase(rule1); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); ObjectTypeNode otn = getObjectTypeNode(kbase, "A" ); @@ -435,10 +440,11 @@ public void testRtnWithConstraintsNoWatches() { assertThat(rtNode.getInferredMask()).isEqualTo(calculatePositiveMask(otn.getObjectType(), list("a"), sp)); // rtn infers from alpha } - @Test - public void testRtnWithConstraintsWithWatches() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRtnWithConstraintsWithWatches(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "A( a == 10 ) @watch(b)"; - KieBase kbase = getKnowledgeBase(rule1); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); ObjectTypeNode otn = getObjectTypeNode(kbase, "A" ); @@ -457,11 +463,12 @@ public void testRtnWithConstraintsWithWatches() { assertThat(rtNode.getInferredMask()).isEqualTo(calculatePositiveMask(otn.getObjectType(), list("a", "b"), sp)); } - @Test - public void testRtnSharedAlphaNoWatches() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRtnSharedAlphaNoWatches(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "A( a == 10, b == 15 )"; String rule2 = "A( a == 10, i == 20 )"; - KieBase kbase = getKnowledgeBase(rule1, rule2); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1, rule2); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); ObjectTypeNode otn = getObjectTypeNode(kbase, "A" ); @@ -508,7 +515,7 @@ public void testRtnSharedAlphaNoWatches() { assertThat(rtNode2.getInferredMask()).isEqualTo(calculatePositiveMask(otn.getObjectType(), list("a", "i"), sp)); // have to rebuild to remove r1 - kbase = getKnowledgeBase(rule1, rule2); + kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1, rule2); kbase.removeRule( "org.drools.mvel.integrationtests", "r1" ); otn = getObjectTypeNode(kbase, "A" ); @@ -527,11 +534,12 @@ public void testRtnSharedAlphaNoWatches() { assertThat(rtNode1.getInferredMask()).isEqualTo(calculatePositiveMask(otn.getObjectType(), list("a", "b"), sp)); } - @Test - public void testRtnSharedAlphaWithWatches() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRtnSharedAlphaWithWatches(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "A( a == 10, b == 15 ) @watch(c, !a)"; String rule2 = "A( a == 10, i == 20 ) @watch(s, !i)"; - KieBase kbase = getKnowledgeBase(rule1, rule2); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1, rule2); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); ObjectTypeNode otn = getObjectTypeNode(kbase, "A" ); @@ -580,7 +588,7 @@ public void testRtnSharedAlphaWithWatches() { assertThat(rtNode2.getNegativeMask()).isEqualTo(calculateNegativeMask(otn.getObjectType(), list("!i"), sp)); // have to rebuild to remove r1 - kbase = getKnowledgeBase(rule1, rule2); + kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1, rule2); kbase.removeRule( "org.drools.mvel.integrationtests", "r1" ); otn = getObjectTypeNode(kbase, "A" ); @@ -600,10 +608,11 @@ public void testRtnSharedAlphaWithWatches() { assertThat(rtNode1.getNegativeMask()).isEqualTo(calculateNegativeMask(otn.getObjectType(), list("!a"), sp)); } - @Test - public void testBetaNoConstraintsNoWatches() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBetaNoConstraintsNoWatches(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "B() A()"; - KieBase kbase = getKnowledgeBase(rule1); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); ObjectTypeNode otn = getObjectTypeNode(kbase, "A" ); @@ -617,10 +626,11 @@ public void testBetaNoConstraintsNoWatches() { assertThat(betaNode.getLeftInferredMask()).isEqualTo(EmptyBitMask.get()); } - @Test - public void testBetaNoConstraintsWithWatches() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBetaNoConstraintsWithWatches(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "B() @watch(a) A() @watch(a)"; - KieBase kbase = getKnowledgeBase(rule1); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); ObjectTypeNode otn = getObjectTypeNode(kbase, "A" ); @@ -635,10 +645,11 @@ public void testBetaNoConstraintsWithWatches() { assertThat(betaNode.getLeftInferredMask()).isEqualTo(calculatePositiveMask(otn.getObjectType(), list("a"), sp)); } - @Test - public void testBetaWithConstraintsNoWatches() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBetaWithConstraintsNoWatches(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "$b : B(a == 15) A( a == 10, b == $b.b )"; - KieBase kbase = getKnowledgeBase(rule1); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); ObjectTypeNode otn = getObjectTypeNode(kbase, "A" ); @@ -663,10 +674,11 @@ public void testBetaWithConstraintsNoWatches() { assertThat(betaNode.getLeftInferredMask()).isEqualTo(calculatePositiveMask(otn.getObjectType(), list("a", "b"), sp)); } - @Test - public void testBetaWithConstraintsWithWatches() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBetaWithConstraintsWithWatches(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "$b : B( a == 15) @watch(c) A( a == 10, b == $b.b ) @watch(s)"; - KieBase kbase = getKnowledgeBase(rule1); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); ObjectTypeNode otn = getObjectTypeNode(kbase, "A" ); @@ -693,10 +705,11 @@ public void testBetaWithConstraintsWithWatches() { assertThat(betaNode.getLeftInferredMask()).isEqualTo(calculatePositiveMask(otn.getObjectType(), list("a", "b", "c"), sp)); } - @Test - public void testBetaWithConstraintsWithNegativeWatches() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBetaWithConstraintsWithNegativeWatches(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "$b : B( a == 15) @watch(c, !a) A( a == 10, b == $b.b ) @watch(s, !a, !b)"; - KieBase kbase = getKnowledgeBase(rule1); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); ObjectTypeNode otn = getObjectTypeNode(kbase, "A" ); @@ -723,11 +736,12 @@ public void testBetaWithConstraintsWithNegativeWatches() { assertThat(betaNode.getLeftNegativeMask()).isEqualTo(calculateNegativeMask(otn.getObjectType(), list("!a"), sp)); } - @Test - public void testBetaSharedAlphaNoWatches() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBetaSharedAlphaNoWatches(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "$b : B( a == 15) @watch(c, !a) A( a == 10, s == 15, b == $b.b )"; String rule2 = "$b : B( a == 15) @watch(j, !i) A( a == 10, i == 20, b == $b.b )"; - KieBase kbase = getKnowledgeBase(rule1, rule2); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1, rule2); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); ObjectTypeNode otn = getObjectTypeNode(kbase, "A" ); @@ -781,7 +795,7 @@ public void testBetaSharedAlphaNoWatches() { assertThat(betaNode1.getLeftNegativeMask()).isEqualTo(calculateNegativeMask(otn.getObjectType(), list("!a"), sp)); // have to rebuild to remove r1 - kbase = getKnowledgeBase(rule1, rule2); + kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1, rule2); kbase.removeRule( "org.drools.mvel.integrationtests", "r1" ); otn = getObjectTypeNode(kbase, "A" ); @@ -803,11 +817,12 @@ public void testBetaSharedAlphaNoWatches() { assertThat(betaNode2.getLeftNegativeMask()).isEqualTo(calculateNegativeMask(otn.getObjectType(), list("!i"), sp)); } - @Test - public void testBetaSharedAlphaWithWatches() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBetaSharedAlphaWithWatches(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "$b : B( a == 15) @watch(c, !a) A( a == 10, b == 15, b == $b.b ) @watch(c, !b)"; String rule2 = "$b : B( a == 15) @watch(j) A( a == 10, i == 20, b == $b.b ) @watch(s, !a)"; - KieBase kbase = getKnowledgeBase(rule1, rule2); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1, rule2); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); ObjectTypeNode otn = getObjectTypeNode(kbase, "A" ); @@ -866,7 +881,7 @@ public void testBetaSharedAlphaWithWatches() { assertThat(betaNode2.getLeftNegativeMask()).isEqualTo(EmptyBitMask.get()); // have to rebuild to remove r1 - kbase = getKnowledgeBase(rule1, rule2); + kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1, rule2); kbase.removeRule( "org.drools.mvel.integrationtests", "r1" ); otn = getObjectTypeNode(kbase, "A" ); @@ -889,12 +904,13 @@ public void testBetaSharedAlphaWithWatches() { assertThat(betaNode1.getLeftNegativeMask()).isEqualTo(calculateNegativeMask(otn.getObjectType(), list("!a"), sp)); } - @Test - public void testComplexBetaSharedAlphaWithWatches() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testComplexBetaSharedAlphaWithWatches(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "$b : B( b == 15) @watch(i) A( a == 10, b == 15 ) @watch(c)"; String rule2 = "$b : B( b == 15) @watch(j) A( a == 10, i == 20 ) @watch(s)"; String rule3 = "$b : B( c == 15) @watch(k) A( a == 10, i == 20, b == 10 ) @watch(j)"; - KieBase kbase = getKnowledgeBase(rule1, rule2, rule3); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1, rule2, rule3); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); ObjectTypeNode otn = getObjectTypeNode(kbase, "A" ); @@ -945,12 +961,13 @@ public void testComplexBetaSharedAlphaWithWatches() { assertThat(betaNode3.getLeftInferredMask()).isEqualTo(calculatePositiveMask(otn.getObjectType(), list("c", "k"), sp)); } - @Test - public void testComplexBetaSharedAlphaWithWatchesRemoveR1() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testComplexBetaSharedAlphaWithWatchesRemoveR1(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "$b : B( b == 15) @watch(i) A( a == 10, b == 15 ) @watch(c)"; String rule2 = "$b : B( b == 15) @watch(j) A( a == 10, i == 20 ) @watch(s)"; String rule3 = "$b : B( c == 15) @watch(k) A( a == 10, i == 20, b == 10 ) @watch(j)"; - KieBase kbase = getKnowledgeBase(rule1, rule2, rule3); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1, rule2, rule3); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); kbase.removeRule( "org.drools.mvel.integrationtests", "r0" ); @@ -989,12 +1006,13 @@ public void testComplexBetaSharedAlphaWithWatchesRemoveR1() { assertThat(betaNode3.getLeftInferredMask()).isEqualTo(calculatePositiveMask(otn.getObjectType(), list("c", "k"), sp)); } - @Test - public void testComplexBetaSharedAlphaWithWatchesRemoveR2() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testComplexBetaSharedAlphaWithWatchesRemoveR2(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "$b : B( b == 15) @watch(i) A( a == 10, b == 15 ) @watch(c)"; String rule2 = "$b : B( b == 15) @watch(j) A( a == 10, i == 20 ) @watch(s)"; String rule3 = "$b : B( c == 15) @watch(k) A( a == 10, i == 20, b == 10 ) @watch(j)"; - KieBase kbase = getKnowledgeBase(rule1, rule2, rule3); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1, rule2, rule3); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); kbase.removeRule( "org.drools.mvel.integrationtests", "r1" ); @@ -1039,12 +1057,13 @@ public void testComplexBetaSharedAlphaWithWatchesRemoveR2() { } - @Test - public void testComplexBetaSharedAlphaWithWatchesRemoveR3() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testComplexBetaSharedAlphaWithWatchesRemoveR3(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "$b : B( b == 15) @watch(i) A( a == 10, b == 15 ) @watch(c)"; String rule2 = "$b : B( b == 15) @watch(j) A( a == 10, i == 20 ) @watch(s)"; String rule3 = "$b : B( c == 15) @watch(k) A( a == 10, i == 20, b == 10 ) @watch(j)"; - KieBase kbase = getKnowledgeBase(rule1, rule2, rule3); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1, rule2, rule3); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); kbase.removeRule( "org.drools.mvel.integrationtests", "r2" ); @@ -1085,8 +1104,9 @@ public void testComplexBetaSharedAlphaWithWatchesRemoveR3() { assertThat(betaNode2.getLeftInferredMask()).isEqualTo(calculatePositiveMask(otn.getObjectType(), list("b", "j"), sp)); } - @Test - public void testPropertySpecificSimplified() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPropertySpecificSimplified(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String rule = "package org.drools.mvel.integrationtests\n" + "dialect \"mvel\"\n" + "declare A\n" + @@ -1133,8 +1153,9 @@ public void testPropertySpecificSimplified() throws Exception { ksession.dispose(); } - @Test - public void testWatchNothing() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testWatchNothing(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String rule = "package org.drools.mvel.integrationtests\n" + "dialect \"mvel\"\n" + "declare A\n" + @@ -1181,8 +1202,9 @@ public void testWatchNothing() throws Exception { ksession.dispose(); } - @Test - public void testWrongPropertyNameInWatchAnnotation() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testWrongPropertyNameInWatchAnnotation(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String rule = "package org.drools.mvel.integrationtests\n" + "dialect \"mvel\"\n" + "declare A\n" + @@ -1211,8 +1233,9 @@ public void testWrongPropertyNameInWatchAnnotation() throws Exception { assertThat(kieBuilder.getResults().hasMessages(Level.ERROR)).isTrue(); } - @Test - public void testDuplicatePropertyNamesInWatchAnnotation() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDuplicatePropertyNamesInWatchAnnotation(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String rule = "package org.drools.mvel.integrationtests\n" + "dialect \"mvel\"\n" + "declare A\n" + @@ -1241,8 +1264,9 @@ public void testDuplicatePropertyNamesInWatchAnnotation() throws Exception { assertThat(kieBuilder.getResults().hasMessages(Level.ERROR)).isTrue(); } - @Test - public void testWrongUasgeOfWatchAnnotationOnNonPropertySpecificClass() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testWrongUasgeOfWatchAnnotationOnNonPropertySpecificClass(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String rule = "package org.drools.mvel.integrationtests\n" + "dialect \"mvel\"\n" + "declare A\n" + @@ -1277,8 +1301,9 @@ public void testWrongUasgeOfWatchAnnotationOnNonPropertySpecificClass() throws E assertThat(kieBuilder.getResults().hasMessages(Level.ERROR)).isTrue(); } - @Test - public void testPropertySpecificJavaBean() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPropertySpecificJavaBean(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String rule = "package org.drools.mvel.integrationtests\n" + "import " + PropertySpecificTest.C.class.getCanonicalName() + "\n" + "declare A\n" + @@ -1319,8 +1344,10 @@ public void testPropertySpecificJavaBean() throws Exception { ksession.dispose(); } - @Test(timeout = 5000) - public void testPropertySpecificOnAlphaNode() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(5000) + public void testPropertySpecificOnAlphaNode(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String rule = "package org.drools.mvel.integrationtests\n" + "import " + PropertySpecificTest.C.class.getCanonicalName() + "\n" + "rule R1\n" + @@ -1344,8 +1371,10 @@ public void testPropertySpecificOnAlphaNode() throws Exception { ksession.dispose(); } - @Test(timeout = 5000) - public void testPropertySpecificWithUpdate() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(5000) + public void testPropertySpecificWithUpdate(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String rule = "package org.drools.mvel.integrationtests\n" + "import " + PropertySpecificTest.C.class.getCanonicalName() + "\n" + "rule R1\n" + @@ -1370,8 +1399,9 @@ public void testPropertySpecificWithUpdate() throws Exception { ksession.dispose(); } - @Test - public void testInfiniteLoop() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testInfiniteLoop(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String rule = "package org.drools.mvel.integrationtests\n" + "import " + PropertySpecificTest.C.class.getCanonicalName() + "\n" + "global java.util.concurrent.atomic.AtomicInteger counter\n" + @@ -1399,8 +1429,9 @@ public void testInfiniteLoop() throws Exception { .hasMessageContaining("Exception executing consequence for rule \"R1\""); } - @Test - public void testClassReactive() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testClassReactive(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String rule = "package org.drools.mvel.integrationtests\n" + "global java.util.concurrent.atomic.AtomicInteger counter\n" + "declare B\n" + @@ -1437,8 +1468,10 @@ public void testClassReactive() throws Exception { .hasMessageContaining("Exception executing consequence for rule \"R1\""); } - @Test(timeout = 5000) - public void testSharedWatchAnnotation() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(5000) + public void testSharedWatchAnnotation(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String rule = "package org.drools.mvel.integrationtests\n" + "declare A\n" + " @propertyReactive\n" + @@ -1515,8 +1548,9 @@ public void setS(String s) { } } - @Test - public void testBetaNodePropagation() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBetaNodePropagation(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String rule = "package org.drools.mvel.integrationtests\n" + "import " + PropertySpecificTest.Hero.class.getCanonicalName() + "\n" + "import " + PropertySpecificTest.MoveCommand.class.getCanonicalName() + "\n" + @@ -1551,8 +1585,10 @@ public void testBetaNodePropagation() throws Exception { assertThat(hero.getPosition()).isEqualTo(2); } - @Test(timeout = 5000) - public void testPropSpecOnPatternWithThis() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(5000) + public void testPropSpecOnPatternWithThis(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String rule = "package org.drools.mvel.integrationtests\n" + "declare A\n" + " @propertyReactive\n" + @@ -1587,8 +1623,9 @@ public void testPropSpecOnPatternWithThis() throws Exception { assertThat(rules).isEqualTo(1); } - @Test - public void testPropSpecOnBetaNode() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPropSpecOnBetaNode(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String rule = "package org.drools.mvel.integrationtests\n" + "declare A\n" + " @propertyReactive\n" + @@ -1630,8 +1667,10 @@ public void testPropSpecOnBetaNode() throws Exception { assertThat(rules).isEqualTo(3); } - @Test(timeout = 5000) - public void testConfig() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(5000) + public void testConfig(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String rule = "package org.drools.mvel.integrationtests\n" + "declare A\n" + " i : int\n" + @@ -1660,8 +1699,9 @@ public void testConfig() throws Exception { assertThat(rules).isEqualTo(1); } - @Test - public void testEmptyBetaConstraint() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEmptyBetaConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String rule = "package org.drools.mvel.integrationtests\n" + "import " + PropertySpecificTest.Hero.class.getCanonicalName() + "\n" + "import " + PropertySpecificTest.Cell.class.getCanonicalName() + "\n" + @@ -1710,8 +1750,10 @@ public void testEmptyBetaConstraint() throws Exception { assertThat(rules).isEqualTo(2); } - @Test (timeout = 5000) - public void testNoConstraint() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(5000) + public void testNoConstraint(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String rule = "package org.drools.mvel.integrationtests\n" + "import " + PropertySpecificTest.Cell.class.getCanonicalName() + "\n" + "rule R1 when\n" + @@ -1729,8 +1771,10 @@ public void testNoConstraint() throws Exception { assertThat(rules).isEqualTo(1); } - @Test(timeout = 5000) - public void testNodeSharing() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(5000) + public void testNodeSharing(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String rule = "package org.drools.mvel.integrationtests\n" + "import " + PropertySpecificTest.Cell.class.getCanonicalName() + "\n" + "rule R1 when\n" + @@ -1890,8 +1934,10 @@ public ObjectTypeNode getObjectTypeNode(KieBase kbase, String nodeName) { return null; } - @Test(timeout = 5000) - public void testNoConstraint2() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(5000) + public void testNoConstraint2(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String rule = "package org.drools.mvel.integrationtests\n" + "import " + PropertySpecificTest.Order.class.getCanonicalName() + "\n" + "import " + PropertySpecificTest.OrderItem.class.getCanonicalName() + "\n" + @@ -1920,8 +1966,10 @@ public void testNoConstraint2() throws Exception { assertThat(order1.isDiscounted()).isTrue(); } - @Test(timeout = 5000) - public void testFrom() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(5000) + public void testFrom(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String rule = "package org.drools.mvel.integrationtests\n" + "import " + PropertySpecificTest.Order.class.getCanonicalName() + "\n" + "import " + PropertySpecificTest.OrderItem.class.getCanonicalName() + "\n" + @@ -1954,8 +2002,10 @@ public void testFrom() throws Exception { assertThat(order1.isDiscounted()).isTrue(); } - @Test(timeout = 5000) - public void testAccumulate() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(5000) + public void testAccumulate(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String rule = "package org.drools.mvel.integrationtests\n" + "import " + PropertySpecificTest.Order.class.getCanonicalName() + "\n" + "import " + PropertySpecificTest.OrderItem.class.getCanonicalName() + "\n" + @@ -2055,10 +2105,11 @@ public double getValue() { } } - @Test - public void testBetaWithWatchAfterBeta() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBetaWithWatchAfterBeta(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "$b : B(a == 15) @watch(k) C() A(i == $b.j) @watch(b, c)"; - KieBase kbase = getKnowledgeBase(rule1); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); ObjectTypeNode otnA = getObjectTypeNode(kbase, "A" ); @@ -2078,10 +2129,11 @@ public void testBetaWithWatchAfterBeta() { assertThat(betaNodeC.getLeftInferredMask()).isEqualTo(calculatePositiveMask(otnC.getObjectType(), list("a", "j", "k"), sp)); } - @Test - public void testBetaAfterBetaWithWatch() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBetaAfterBetaWithWatch(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "$b : B(a == 15) @watch(k) A(i == $b.j) @watch(b, c) C()"; - KieBase kbase = getKnowledgeBase(rule1); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); ObjectTypeNode otnA = getObjectTypeNode(kbase, "A" ); @@ -2101,11 +2153,12 @@ public void testBetaAfterBetaWithWatch() { assertThat(betaNodeC.getLeftInferredMask()).isEqualTo(AllSetBitMask.get()); } - @Test - public void test2DifferentAlphaWatchBeforeSameBeta() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void test2DifferentAlphaWatchBeforeSameBeta(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "B(a == 15) @watch(b) C()"; String rule2 = "B(a == 15) @watch(c) C()"; - KieBase kbase = getKnowledgeBase(rule1, rule2); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1, rule2); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); ObjectTypeNode otn = getObjectTypeNode(kbase, "B" ); @@ -2147,11 +2200,12 @@ public void test2DifferentAlphaWatchBeforeSameBeta() { assertThat(betaNodeC2.getLeftInferredMask()).isEqualTo(calculatePositiveMask(otn.getObjectType(), list("a", "c"), sp)); } - @Test - public void testSameBetasWith2RTNSinks() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSameBetasWith2RTNSinks(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "B(a == 15) C() A()"; String rule2 = "B(a == 15) C() A() @watch(b, c)"; - KieBase kbase = getKnowledgeBase(rule1, rule2); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1, rule2); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); ObjectTypeNode otnA = getObjectTypeNode(kbase, "A" ); @@ -2185,11 +2239,12 @@ public void testSameBetasWith2RTNSinks() { assertThat(betaNodeC.getSinkPropagator().getSinks().length).isEqualTo(1); } - @Test - public void testBetaWith2BetaSinks() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBetaWith2BetaSinks(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule1 = "B(a == 15) @watch(b) A() @watch(i) C()"; String rule2 = "B(a == 15) @watch(c) A() @watch(j) D()"; - KieBase kbase = getKnowledgeBase(rule1, rule2); + KieBase kbase = getKnowledgeBase(kieBaseTestConfiguration, rule1, rule2); InternalWorkingMemory wm = ((InternalWorkingMemory)kbase.newKieSession()); ObjectTypeNode otnB = getObjectTypeNode(kbase, "B" ); @@ -2234,19 +2289,22 @@ public void testBetaWith2BetaSinks() { assertThat(alphaNode.getInferredMask()).isEqualTo(calculatePositiveMask(otnB.getObjectType(), list("a", "b"), sp)); } - @Test(timeout = 5000) - public void testBetaWith2RTNSinksExecNoLoop() throws Exception { - testBetaWith2RTNSinksExec(false); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(5000) + public void testBetaWith2RTNSinksExecNoLoop(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + testBetaWith2RTNSinksExec(kieBaseTestConfiguration, false); } - @Test - public void testBetaWith2RTNSinksExecInfiniteLoop() throws Exception { - assertThatThrownBy(() -> testBetaWith2RTNSinksExec(true)) + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBetaWith2RTNSinksExecInfiniteLoop(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + assertThatThrownBy(() -> testBetaWith2RTNSinksExec(kieBaseTestConfiguration, true)) .isInstanceOf(RuntimeException.class) .hasMessageContaining("Exception executing consequence for rule \"R1\""); } - private void testBetaWith2RTNSinksExec(boolean addInfiniteLoopWatch) throws Exception { + private void testBetaWith2RTNSinksExec(KieBaseTestConfiguration kieBaseTestConfiguration, boolean addInfiniteLoopWatch) throws Exception { String rule = "package org.drools.mvel.integrationtests\n" + "global java.util.concurrent.atomic.AtomicInteger counter\n" + "declare A\n" + @@ -2312,19 +2370,22 @@ private void testBetaWith2RTNSinksExec(boolean addInfiniteLoopWatch) throws Exce } } - @Test(timeout = 5000) - public void testBetaWith2BetaSinksExecNoLoop() throws Exception { - testBetaWith2BetaSinksExec(false); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(5000) + public void testBetaWith2BetaSinksExecNoLoop(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + testBetaWith2BetaSinksExec(kieBaseTestConfiguration, false); } - @Test - public void testBetaWith2BetaSinksExecInfiniteLoop() throws Exception { - assertThatThrownBy(() -> testBetaWith2BetaSinksExec(true)) + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testBetaWith2BetaSinksExecInfiniteLoop(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { + assertThatThrownBy(() -> testBetaWith2BetaSinksExec(kieBaseTestConfiguration, true)) .isInstanceOf(RuntimeException.class) .hasMessageContaining("Exception executing consequence for rule \"R1\""); } - private void testBetaWith2BetaSinksExec(boolean addInfiniteLoopWatch) throws Exception { + private void testBetaWith2BetaSinksExec(KieBaseTestConfiguration kieBaseTestConfiguration, boolean addInfiniteLoopWatch) throws Exception { String rule = "package org.drools.mvel.integrationtests\n" + "global java.util.concurrent.atomic.AtomicInteger counter\n" + "declare A\n" + @@ -2397,8 +2458,10 @@ private void testBetaWith2BetaSinksExec(boolean addInfiniteLoopWatch) throws Exc } } - @Test(timeout = 5000) - public void testTypeDeclarationInitializationForPropertyReactive() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(5000) + public void testTypeDeclarationInitializationForPropertyReactive(KieBaseTestConfiguration kieBaseTestConfiguration) { // JBRULES-3686 String rule = "package org.drools.mvel.integrationtests\n" + "import java.util.Map;\n" + @@ -2527,8 +2590,9 @@ public static enum Parameter { PARAM_A, PARAM_B } - @Test - public void testRemovedPendingActivation() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRemovedPendingActivation(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule = "declare Person\n" + "@propertyReactive\n" + " name : String\n" + @@ -2580,8 +2644,8 @@ public void testRemovedPendingActivation() { public static class LongFact { - private Long longVal; - private Long longDiff; + private Long longVal; + private Long longDiff; public LongFact( int i) { this.longVal = new Long(i); @@ -2630,8 +2694,9 @@ public void setBdVal( BigDecimal bdVal ) { } } - @Test - public void testAccLong() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccLong(KieBaseTestConfiguration kieBaseTestConfiguration) { String rule = "package com.sample.rules\n" + "import " + LongFact.class.getCanonicalName() + "\n" + @@ -2667,8 +2732,9 @@ public void testAccLong() { assertThat(cnt).isEqualTo(NUM-1); } - @Test - public void testAccBigDecimal() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAccBigDecimal(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-4896 String rule = "package com.sample.rules\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PseudoClockEventsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PseudoClockEventsTest.java index abefd503958..3f4fa5d95e6 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PseudoClockEventsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PseudoClockEventsTest.java @@ -18,8 +18,8 @@ */ package org.drools.mvel.integrationtests; -import java.util.Collection; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; import org.drools.core.impl.RuleBaseFactory; import org.drools.core.time.impl.PseudoClockScheduler; @@ -27,17 +27,16 @@ import org.drools.mvel.compiler.StockTickInterface; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.event.rule.AfterMatchFiredEvent; import org.kie.api.event.rule.AgendaEventListener; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.KieSessionConfiguration; import org.kie.api.runtime.conf.ClockTypeOption; -import org.kie.api.time.SessionClock; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; @@ -47,18 +46,10 @@ /** * Tests related to the pseudo session clock */ -@RunWith(Parameterized.class) public class PseudoClockEventsTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public PseudoClockEventsTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseStreamConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseStreamConfigurations(true).stream(); } private static final String evalFirePseudoClockDeclaration = @@ -72,8 +63,8 @@ public static Collection getParameters() { private static final String evalFirePseudoClockRuleA = "rule A\n" + "when\n" + - " $a: StockTick( $priceA: price )\n" + - " $b: StockTick( $priceA < price )\n" + + " $a: StockTick( $priceA: price )\n" + + " $b: StockTick( $priceA < price )\n" + "then \n" + " System.out.println(\"Rule A fired by thread \" + Thread.currentThread().getName() + \": \" + $a + \", \" + $b);\n" + "end\n" + @@ -81,20 +72,22 @@ public static Collection getParameters() { private static final String evalFirePseudoClockRuleB = "rule B\n" + "when\n" + - " $a: StockTick()\n" + - " not( StockTick( this after[1,10s] $a ) )\n" + + " $a: StockTick()\n" + + " not( StockTick( this after[1,10s] $a ) )\n" + "then \n" + " System.out.println(\"Rule B fired by thread \" + Thread.currentThread().getName());\n" + "end\n" + ""; int evalFirePseudoClockStockCount = 5; - @Test(timeout = 10000) - public void testEvenFirePseudoClockRuleA() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testEvenFirePseudoClockRuleA(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { AgendaEventListener ael = mock(AgendaEventListener.class); - processStocks(evalFirePseudoClockStockCount, ael, + processStocks(kieBaseTestConfiguration, evalFirePseudoClockStockCount, ael, evalFirePseudoClockDeclaration + evalFirePseudoClockRuleA); verify(ael, @@ -102,12 +95,14 @@ public void testEvenFirePseudoClockRuleA() throws Exception { any(AfterMatchFiredEvent.class)); } - @Test(timeout = 10000) - public void testEvenFirePseudoClockRuleB() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testEvenFirePseudoClockRuleB(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { AgendaEventListener ael = mock(AgendaEventListener.class); - processStocks(evalFirePseudoClockStockCount, ael, + processStocks(kieBaseTestConfiguration, evalFirePseudoClockStockCount, ael, evalFirePseudoClockDeclaration + evalFirePseudoClockRuleB); verify(ael, @@ -115,12 +110,14 @@ public void testEvenFirePseudoClockRuleB() throws Exception { any(AfterMatchFiredEvent.class)); } - @Test(timeout = 60000) - public void testEvenFirePseudoClockRulesAB() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(60000) + public void testEvenFirePseudoClockRulesAB(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { AgendaEventListener ael = mock(AgendaEventListener.class); - processStocks(evalFirePseudoClockStockCount, ael, + processStocks(kieBaseTestConfiguration, evalFirePseudoClockStockCount, ael, evalFirePseudoClockDeclaration + evalFirePseudoClockRuleA + evalFirePseudoClockRuleB); final int expectedActivationCount = evalFirePseudoClockStockCount * (evalFirePseudoClockStockCount - 1) / 2 @@ -130,7 +127,7 @@ public void testEvenFirePseudoClockRulesAB() throws Exception { any(AfterMatchFiredEvent.class)); } - private int processStocks(int stockCount, AgendaEventListener agendaEventListener, String drlContentString) + private int processStocks(KieBaseTestConfiguration kieBaseTestConfiguration, int stockCount, AgendaEventListener agendaEventListener, String drlContentString) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, drlContentString); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/Query2Test.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/Query2Test.java index 4939d04b708..3d8b52be0c5 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/Query2Test.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/Query2Test.java @@ -18,35 +18,27 @@ */ package org.drools.mvel.integrationtests; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.mvel.compiler.Order; import org.drools.mvel.compiler.OrderItem; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; -@RunWith(Parameterized.class) public class Query2Test { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public Query2Test(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testEvalRewrite() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEvalRewrite(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = "" + "package org.drools.mvel.compiler;\n" + "global java.util.List results;\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/Query3Test.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/Query3Test.java index c2065204a59..a4910e43043 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/Query3Test.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/Query3Test.java @@ -19,15 +19,13 @@ package org.drools.mvel.integrationtests; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.rule.FactHandle; @@ -35,27 +33,15 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class Query3Test { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public Query3Test(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } private KieBase knowledgeBase; - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception { + public void setUp(KieBaseTestConfiguration kieBaseTestConfiguration) { String text = ""; text += "package org.drools.integrationtests\n"; text += "import " + Query3Test.Bar.class.getCanonicalName() + "\n"; @@ -101,8 +87,10 @@ private void doIt(Object o1, } } - @Test - public void testDifferent() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDifferent(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); Foo foo = new Foo(); foo.setId( "x" ); Bar bar = new Bar(); @@ -115,8 +103,10 @@ public void testDifferent() { false ); } - @Test - public void testDifferentWithUpdate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDifferentWithUpdate(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); Foo foo = new Foo(); foo.setId( "x" ); Bar bar = new Bar(); @@ -129,8 +119,10 @@ public void testDifferentWithUpdate() { false ); } - @Test - public void testSame() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSame(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); Foo foo = new Foo(); foo.setId( "x" ); Foo foo2 = new Foo(); @@ -143,8 +135,10 @@ public void testSame() { false ); } - @Test - public void testSameWithUpdate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testSameWithUpdate(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); Foo foo = new Foo(); foo.setId( "x" ); Foo foo2 = new Foo(); @@ -157,8 +151,10 @@ public void testSameWithUpdate() { false ); } - @Test - public void testExtends() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExtends(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); Foo foo = new Foo(); foo.setId( "x" ); Foo2 foo2 = new Foo2(); @@ -171,8 +167,10 @@ public void testExtends() { false ); } - @Test - public void testExtendsWithUpdate() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExtendsWithUpdate(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); Foo foo = new Foo(); foo.setId( "x" ); Foo2 foo2 = new Foo2(); @@ -185,8 +183,10 @@ public void testExtendsWithUpdate() { false ); } - @Test - public void testExtendsWithRetract() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testExtendsWithRetract(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); Foo foo = new Foo(); foo.setId( "x" ); Foo2 foo2 = new Foo2(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/QueryCepFireUntilHaltTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/QueryCepFireUntilHaltTest.java index 1c9f56d1121..4f873733112 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/QueryCepFireUntilHaltTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/QueryCepFireUntilHaltTest.java @@ -18,19 +18,18 @@ */ package org.drools.mvel.integrationtests; -import java.util.Collection; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; @@ -46,18 +45,10 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class QueryCepFireUntilHaltTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public QueryCepFireUntilHaltTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseStreamConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseStreamConfigurations(true).stream(); } private KieSession ksession; @@ -68,8 +59,7 @@ public static Collection getParameters() { private ExecutorService executorService; - @Before - public void prepare() { + public void prepare(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "package org.drools.mvel.integrationtests\n" + "import " + TestEvent.class.getCanonicalName() + "\n" + "declare TestEvent\n" + @@ -119,14 +109,20 @@ private void stopEngine() { executorService.shutdownNow(); } - @Test(timeout = 10000L) - public void noResultTest() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void noResultTest(KieBaseTestConfiguration kieBaseTestConfiguration) { + prepare(kieBaseTestConfiguration); QueryResults results = ksession.getQueryResults("EventsFromStream"); assertThat(results.size()).isEqualTo(0); } - @Test(timeout = 10000L) - public void withResultTest() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void withResultTest(KieBaseTestConfiguration kieBaseTestConfiguration) { + prepare(kieBaseTestConfiguration); secondEntryPoint.insert(new TestEvent("minusOne")); clock.advanceTime(5, TimeUnit.SECONDS); @@ -143,8 +139,11 @@ public void withResultTest() { assertThat(results.size()).isEqualTo(1); } - @Test(timeout = 10000L) - public void withNoResultTest() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void withNoResultTest(KieBaseTestConfiguration kieBaseTestConfiguration) { + prepare(kieBaseTestConfiguration); secondEntryPoint.insert(new TestEvent("minusOne")); clock.advanceTime(5, TimeUnit.SECONDS); @@ -162,7 +161,7 @@ public void withNoResultTest() { assertThat(results.size()).isEqualTo(0); } - @After + @AfterEach public void cleanup() { this.stopEngine(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/QueryInRHSCepTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/QueryInRHSCepTest.java index 912064a98cf..71f2234d5aa 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/QueryInRHSCepTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/QueryInRHSCepTest.java @@ -19,7 +19,6 @@ package org.drools.mvel.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.CompletionService; @@ -27,14 +26,15 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.builder.KieBuilder; @@ -50,32 +50,25 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class QueryInRHSCepTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public QueryInRHSCepTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; + public static Stream parameters() { + return TestParametersUtil2.getKieBaseStreamConfigurations(true).stream(); } - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseStreamConfigurations(true); - } - private KieSession ksession; + private KieSession ksession; private SessionPseudoClock clock; - private List myGlobal; - + private List myGlobal; + public static class QueryItemPojo { - // empty pojo. - } + // empty pojo. + } - public static class SolicitFirePojo { - // empty pojo. - } - - private void prepare1() { + public static class SolicitFirePojo { + // empty pojo. + } + + private void prepare1(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "package org.drools.mvel.integrationtests\n" + "import " + SolicitFirePojo.class.getCanonicalName() + "\n" + "import " + QueryItemPojo.class.getCanonicalName() + "\n" + @@ -84,7 +77,7 @@ private void prepare1() { " @role( event )\n" + "end\n" + "query \"myQuery\"\n" + - " $r : QueryItemPojo()\n" + + " $r : QueryItemPojo()\n" + "end\n" + "rule \"drools-usage/WLHxG8S\"\n" + " no-loop\n" + @@ -117,10 +110,11 @@ private void prepare1() { ksession.setGlobal("myGlobal", myGlobal); } - @Test - public void withResultOfSize1Test() { - prepare1(); - clock.advanceTime(1, TimeUnit.SECONDS); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void withResultOfSize1Test(KieBaseTestConfiguration kieBaseTestConfiguration) { + prepare1(kieBaseTestConfiguration); + clock.advanceTime(1, TimeUnit.SECONDS); ksession.insert(new QueryItemPojo()); ksession.insert(new SolicitFirePojo()); int fired = ksession.fireAllRules(); @@ -128,10 +122,11 @@ public void withResultOfSize1Test() { assertThat(myGlobal.size()).isEqualTo(1); assertThat(((QueryResults) myGlobal.get(0)).size()).isEqualTo(1); } - @Test - public void withResultOfSize1AnotherTest() { - prepare1(); - clock.advanceTime(1, TimeUnit.SECONDS); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void withResultOfSize1AnotherTest(KieBaseTestConfiguration kieBaseTestConfiguration) { + prepare1(kieBaseTestConfiguration); + clock.advanceTime(1, TimeUnit.SECONDS); ksession.insert(new SolicitFirePojo()); ksession.insert(new QueryItemPojo()); int fired = ksession.fireAllRules(); @@ -139,10 +134,11 @@ public void withResultOfSize1AnotherTest() { assertThat(myGlobal.size()).isEqualTo(1); assertThat(((QueryResults) myGlobal.get(0)).size()).isEqualTo(1); } - @Test - public void withResultOfSize0Test() { - prepare1(); - clock.advanceTime(1, TimeUnit.SECONDS); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void withResultOfSize0Test(KieBaseTestConfiguration kieBaseTestConfiguration) { + prepare1(kieBaseTestConfiguration); + clock.advanceTime(1, TimeUnit.SECONDS); ksession.insert(new SolicitFirePojo()); int fired = ksession.fireAllRules(); assertThat(fired).isEqualTo(1); @@ -150,14 +146,15 @@ public void withResultOfSize0Test() { assertThat(((QueryResults) myGlobal.get(0)).size()).isEqualTo(0); } - @Test - public void withInsertBeforeQueryCloudTest() { - String drl = "package org.drools.mvel.integrationtests\n" + + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void withInsertBeforeQueryCloudTest(KieBaseTestConfiguration kieBaseTestConfiguration) { + String drl = "package org.drools.mvel.integrationtests\n" + "import " + SolicitFirePojo.class.getCanonicalName() + "\n" + "import " + QueryItemPojo.class.getCanonicalName() + "\n" + "global java.util.List myGlobal \n"+ "query \"myQuery\"\n" + - " $r : QueryItemPojo()\n" + + " $r : QueryItemPojo()\n" + "end\n" + "rule \"drools-usage/WLHxG8S\"\n" + " no-loop\n" + @@ -198,8 +195,10 @@ public void withInsertBeforeQueryCloudTest() { assertThat(((QueryResults) myGlobal.get(0)).size()).isEqualTo(2); // notice 1 is manually inserted, 1 get inserted from rule's RHS, for a total of 2. } - @Test(timeout = 10000L) - public void testParallelQueryCallFromRuleAndAPI() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + @Timeout(10000) + public void testParallelQueryCallFromRuleAndAPI(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "global java.util.List myGlobal \n"+ "query \"myQuery\"\n" + @@ -212,7 +211,7 @@ public void testParallelQueryCallFromRuleAndAPI() { " myGlobal.add(drools.getKieRuntime().getQueryResults(\"myQuery\"));\n"+ "end\n"; - KieBaseTestConfiguration cloudConfig = TestParametersUtil.getCloudInstanceOf(kieBaseTestConfiguration); + KieBaseTestConfiguration cloudConfig = TestParametersUtil2.getCloudInstanceOf(kieBaseTestConfiguration); KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", cloudConfig, drl); KieSession kSession = kbase.newKieSession(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/QueryTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/QueryTest.java index 008f6644108..75bc7302f29 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/QueryTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/QueryTest.java @@ -39,12 +39,11 @@ import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; import org.drools.testcoverage.common.util.KieUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Before; -import org.junit.Test; -import org.junit.rules.TestName; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.builder.KieBuilder; import org.kie.api.builder.Message; @@ -73,30 +72,20 @@ import java.util.Set; import java.util.TreeSet; import java.util.stream.Collectors; +import java.util.stream.Stream; import java.util.stream.StreamSupport; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class QueryTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public QueryTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @org.junit.Rule - public TestName testName = new TestName(); - - @Before - public void before() { - System.out.println( "] " + testName.getMethodName()); + @BeforeEach + public void before(TestInfo info) { + System.out.println( "] " + info.getTestMethod().get().getName()); } private static QueryResults getQueryResults(KieSession session, String queryName, Object... arguments ) throws Exception { @@ -172,8 +161,9 @@ private static JAXBContext getJaxbContext( Class... classes ) throws Exceptio return JAXBContext.newInstance(jaxbClasses); } - @Test - public void testQuery2() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQuery2(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_Query.drl"); KieSession session = kbase.newKieSession(); @@ -184,8 +174,9 @@ public void testQuery2() throws Exception { assertThat(results.iterator().next().get("assertedobj")).isEqualTo(new InsertedObject("value1" )); } - @Test - public void testQueryWithParams() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryWithParams(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_QueryWithParams.drl"); KieSession session = kbase.newKieSession(); @@ -215,8 +206,9 @@ public void testQueryWithParams() throws Exception { assertThat(results.iterator().next().get("assertedobj")).isEqualTo(new InsertedObject( "value2" )); } - @Test - public void testQueryWithMultipleResultsOnKnowledgeApi() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryWithMultipleResultsOnKnowledgeApi(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.drools.mvel.compiler.test \n"; str += "import org.drools.mvel.compiler.Cheese \n"; @@ -284,8 +276,9 @@ public void testQueryWithMultipleResultsOnKnowledgeApi() throws Exception { assertThat(newSet).isEqualTo(set); } - @Test - public void testTwoQuerries() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTwoQuerries(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // @see JBRULES-410 More than one Query definition causes an incorrect // Rete network to be built. KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_TwoQuerries.drl"); @@ -311,8 +304,9 @@ public void testTwoQuerries() throws Exception { assertThat(results.size()).isEqualTo(1); } - @Test - public void testDoubleQueryWithExists() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDoubleQueryWithExists(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_DoubleQueryWithExists.drl"); KieSession session = kbase.newKieSession(); @@ -385,8 +379,9 @@ public void testDoubleQueryWithExists() throws Exception { assertThat(results.size()).isEqualTo(2); } - @Test - public void testQueryWithCollect() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryWithCollect(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_Query.drl"); KieSession session = kbase.newKieSession(); session.fireAllRules(); @@ -400,8 +395,9 @@ public void testQueryWithCollect() throws Exception { assertThat(list.size()).isEqualTo(2); } - @Test - public void testDroolsQueryCleanup() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDroolsQueryCleanup(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_QueryMemoryLeak.drl"); KieSession ksession = kbase.newKieSession(); @@ -444,8 +440,9 @@ public void testDroolsQueryCleanup() throws Exception { assertThat(it.hasNext()).isFalse(); } - @Test - public void testQueriesWithVariableUnification() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueriesWithVariableUnification(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.drools.mvel.compiler.test \n"; str += "import org.drools.mvel.compiler.Person \n"; @@ -528,8 +525,9 @@ public void testQueriesWithVariableUnification() throws Exception { assertThat(names.contains("darth")).isTrue(); } - @Test - public void testQueriesWithVariableUnificationOnPatterns() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueriesWithVariableUnificationOnPatterns(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.drools.mvel.compiler.test \n"; str += "import org.drools.mvel.compiler.Person \n"; @@ -582,8 +580,9 @@ public void testQueriesWithVariableUnificationOnPatterns() throws Exception { assertThat(names.contains("darth")).isTrue(); } - @Test - public void testQueriesWithVariableUnificationOnNestedFields() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueriesWithVariableUnificationOnNestedFields(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.drools.mvel.compiler.test \n"; str += "import org.drools.mvel.compiler.Person \n"; @@ -625,8 +624,9 @@ public void testQueriesWithVariableUnificationOnNestedFields() throws Exception assertThat(names.contains("darth")).isTrue(); } - @Test - public void testOpenQuery() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOpenQuery(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String str = ""; str += "package org.drools.mvel.compiler.test \n"; str += "import org.drools.mvel.compiler.Cheese \n"; @@ -788,17 +788,19 @@ public void rowInserted( Row row ) { assertThat(updated.size()).isEqualTo(1); } - @Test - public void testStandardQueryListener() throws IOException, ClassNotFoundException { - runQueryListenerTest( QueryListenerOption.STANDARD ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testStandardQueryListener(KieBaseTestConfiguration kieBaseTestConfiguration) throws IOException, ClassNotFoundException { + runQueryListenerTest(kieBaseTestConfiguration, QueryListenerOption.STANDARD ); } - @Test - public void testNonCloningQueryListener() throws IOException, ClassNotFoundException { - runQueryListenerTest( QueryListenerOption.LIGHTWEIGHT ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNonCloningQueryListener(KieBaseTestConfiguration kieBaseTestConfiguration) throws IOException, ClassNotFoundException { + runQueryListenerTest(kieBaseTestConfiguration, QueryListenerOption.LIGHTWEIGHT ); } - public void runQueryListenerTest( QueryListenerOption option ) throws IOException, ClassNotFoundException { + public void runQueryListenerTest(KieBaseTestConfiguration kieBaseTestConfiguration , QueryListenerOption option) throws IOException, ClassNotFoundException { String str = ""; str += "package org.drools.mvel.integrationtests\n"; str += "import " + Cheese.class.getCanonicalName() + " \n"; @@ -828,8 +830,9 @@ public void runQueryListenerTest( QueryListenerOption option ) throws IOExceptio } } - @Test - public void testQueryWithEval() throws IOException, ClassNotFoundException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryWithEval(KieBaseTestConfiguration kieBaseTestConfiguration) throws IOException, ClassNotFoundException { // [Regression in 5.2.0.M2]: NPE during rule evaluation on MVELPredicateExpression.evaluate(MVELPredicateExpression.java:82) String str = "package org.drools.mvel.integrationtests\n" + @@ -860,8 +863,9 @@ public void testQueryWithEval() throws IOException, ClassNotFoundException { ksession.dispose(); } - @Test - public void testQueryWithIncompatibleArgs() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryWithIncompatibleArgs(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "global java.util.List list; " + "" + "query foo( String $s, String $s, String $s ) end " + @@ -878,8 +882,9 @@ public void testQueryWithIncompatibleArgs() { assertThat(errors.size()).isEqualTo(2); } - @Test - public void testQueryWithSyntaxError() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryWithSyntaxError(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "global java.util.List list; " + "" + "query foo( Integer $i ) end " + @@ -896,8 +901,9 @@ public void testQueryWithSyntaxError() { assertThat(errors.size()).isEqualTo(1); } - @Test - public void testQueryWithWrongParamNumber() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryWithWrongParamNumber(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "global java.util.List list; " + "" + "query foo( Integer $i ) end " + @@ -917,8 +923,9 @@ public void testQueryWithWrongParamNumber() { - @Test - public void testGlobalsInQueries() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testGlobalsInQueries(KieBaseTestConfiguration kieBaseTestConfiguration) { String drl = "\n" + "package com.sample\n" + "\n" + @@ -962,8 +969,9 @@ public void testGlobalsInQueries() { } - @Test - public void testQueryWithClassArg() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryWithClassArg(KieBaseTestConfiguration kieBaseTestConfiguration) { //DROOLS-590 String drl = "global java.util.List list; " + "" + @@ -1001,8 +1009,9 @@ public void testQueryWithClassArg() { assertThat(list).isEqualTo(Arrays.asList("aa", "bb")); } - @Test - public void testPassGlobalToNestedQuery() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testPassGlobalToNestedQuery(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-851 String drl = "global java.util.List list;\n" + "global Integer number;\n" + @@ -1035,8 +1044,9 @@ public void testPassGlobalToNestedQuery() { assertThat(list).isEqualTo(List.of("Bye")); } - @Test - public void testQueryWithAccessorAsArgument() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryWithAccessorAsArgument(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-414 String str = "import org.drools.mvel.compiler.Person\n" + @@ -1073,8 +1083,9 @@ public void testQueryWithAccessorAsArgument() throws Exception { } } - @Test - public void testQueryWithExpressionAsArgument() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryWithExpressionAsArgument(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-414 String str = "import org.drools.mvel.compiler.Person\n" + @@ -1114,8 +1125,9 @@ public void testQueryWithExpressionAsArgument() throws Exception { } } - @Test - public void testNotExistingDeclarationInQuery() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testNotExistingDeclarationInQuery(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-414 String drl = "import org.drools.compiler.Person\n" + @@ -1138,8 +1150,9 @@ public void testNotExistingDeclarationInQuery() { assertThat(errors.isEmpty()).as("Should have an error").isFalse(); } - @Test - public void testQueryInSubnetwork() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryInSubnetwork(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1386 String str = "query myquery(Integer $i)\n" + " $i := Integer()\n" + @@ -1168,8 +1181,9 @@ public void testQueryInSubnetwork() { ksession.fireAllRules(); } - @Test - public void testOpenQueryNoParams() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testOpenQueryNoParams(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // RHDM-717 String str = ""; str += "package org.drools.mvel.compiler.test \n"; @@ -1295,8 +1309,9 @@ public Question getQuestion() { } } - @Test - public void testQueryWithOptionalOr() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryWithOptionalOr(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-1386 String str = "package org.test\n" + @@ -1325,8 +1340,9 @@ public void testQueryWithOptionalOr() { assertThat(row.get("$visible")).isSameAs(questionVisible); } - @Test - public void testQueryWithFrom() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testQueryWithFrom(KieBaseTestConfiguration kieBaseTestConfiguration) { final String drl = "import org.drools.mvel.compiler.oopath.model.Thing;\n" + "query isContainedIn( Thing $x, Thing $y )\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SerializedPackageMergeTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SerializedPackageMergeTest.java index 9a12a704b4f..476d4aee881 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SerializedPackageMergeTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SerializedPackageMergeTest.java @@ -36,7 +36,7 @@ import org.drools.kiesession.rulebase.InternalKnowledgeBase; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; import org.drools.mvel.compiler.Message; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.definition.KiePackage; import org.kie.api.io.ResourceType; import org.kie.api.runtime.KieSession; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/TemporalOperatorTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/TemporalOperatorTest.java index 0d1f5c2221e..381f7b2e8ef 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/TemporalOperatorTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/TemporalOperatorTest.java @@ -25,62 +25,58 @@ import java.time.ZoneId; import java.time.ZonedDateTime; import java.util.ArrayList; -import java.util.Collection; import java.util.Date; import java.util.List; import java.util.Locale; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class TemporalOperatorTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public TemporalOperatorTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testAfterWithLocalDateTime() { - checkTemporalConstraint( "localDateTime after $t1.localDateTime" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAfterWithLocalDateTime(KieBaseTestConfiguration kieBaseTestConfiguration) { + checkTemporalConstraint(kieBaseTestConfiguration, "localDateTime after $t1.localDateTime" ); } - @Test - public void testAfterWithZonedDateTime() { - checkTemporalConstraint( "zonedDateTime after $t1.zonedDateTime" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAfterWithZonedDateTime(KieBaseTestConfiguration kieBaseTestConfiguration) { + checkTemporalConstraint(kieBaseTestConfiguration, "zonedDateTime after $t1.zonedDateTime" ); } - @Test - public void testAfterWithDate() { - checkTemporalConstraint( "date after $t1.date" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAfterWithDate(KieBaseTestConfiguration kieBaseTestConfiguration) { + checkTemporalConstraint(kieBaseTestConfiguration, "date after $t1.date" ); } - @Test - public void testAfterWithDateUsingOr() { - checkTemporalConstraint( "date == null || date after $t1.date" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAfterWithDateUsingOr(KieBaseTestConfiguration kieBaseTestConfiguration) { + checkTemporalConstraint(kieBaseTestConfiguration, "date == null || date after $t1.date" ); } - @Test - public void testAfterMixDateAndLocaldateTime() { - checkTemporalConstraint( "date after $t1.localDateTime" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAfterMixDateAndLocaldateTime(KieBaseTestConfiguration kieBaseTestConfiguration) { + checkTemporalConstraint(kieBaseTestConfiguration, "date after $t1.localDateTime" ); } - public void checkTemporalConstraint(String constraint) { + public void checkTemporalConstraint(KieBaseTestConfiguration kieBaseTestConfiguration, String constraint) { String str = "import " + TimestampedObject.class.getCanonicalName() + ";\n" + "global java.util.List list;\n" + "rule R when\n" + @@ -109,31 +105,35 @@ public void checkTemporalConstraint(String constraint) { } } - @Test - public void testCompareMaxLocalDates() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCompareMaxLocalDates(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-6431 - checkMaxDate( "localDate == LocalDate.MAX" ); + checkMaxDate(kieBaseTestConfiguration, "localDate == LocalDate.MAX" ); } - @Test - public void testCompareTimeAndMaxLocalDates() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCompareTimeAndMaxLocalDates(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-6431 - checkMaxDate( "localDateTime == LocalDate.MAX" ); + checkMaxDate(kieBaseTestConfiguration, "localDateTime == LocalDate.MAX" ); } - @Test - public void testCompareLocalDatesAndMaxTime() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCompareLocalDatesAndMaxTime(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-6431 - checkMaxDate( "localDate == LocalDateTime.MAX" ); + checkMaxDate(kieBaseTestConfiguration, "localDate == LocalDateTime.MAX" ); } - @Test - public void testCompareMaxLocalDateTimes() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCompareMaxLocalDateTimes(KieBaseTestConfiguration kieBaseTestConfiguration) { // DROOLS-6431 - checkMaxDate( "localDateTime == LocalDateTime.MAX" ); + checkMaxDate(kieBaseTestConfiguration, "localDateTime == LocalDateTime.MAX" ); } - private void checkMaxDate(String constraint) { + private void checkMaxDate(KieBaseTestConfiguration kieBaseTestConfiguration, String constraint) { String str = "import " + TimestampedObject.class.getCanonicalName() + ";\n" + "import " + LocalDate.class.getCanonicalName() + ";\n" + @@ -185,60 +185,70 @@ public Date getDate() { } } - @Test - public void testAfterWithConstant() { - checkConstantTemporalConstraint( "date after \"01-Jan-1970\"" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAfterWithConstant(KieBaseTestConfiguration kieBaseTestConfiguration) { + checkConstantTemporalConstraint(kieBaseTestConfiguration, "date after \"01-Jan-1970\"" ); } - @Test - public void testAfterWithConstantUsingOR() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAfterWithConstantUsingOR(KieBaseTestConfiguration kieBaseTestConfiguration) { // RHBRMS-2799 - checkConstantTemporalConstraint( "date == null || date after \"01-Jan-1970\"" ); + checkConstantTemporalConstraint(kieBaseTestConfiguration, "date == null || date after \"01-Jan-1970\"" ); } - @Test - public void testAfterWithLocalDateTimeUsingOr() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAfterWithLocalDateTimeUsingOr(KieBaseTestConfiguration kieBaseTestConfiguration) { // RHBRMS-2799 - checkConstantTemporalConstraint( "localDateTime == null || localDateTime after \"01-Jan-1970\"" ); + checkConstantTemporalConstraint(kieBaseTestConfiguration, "localDateTime == null || localDateTime after \"01-Jan-1970\"" ); } - @Test - public void testAfterWithLocalDateTimeWithLiteral() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAfterWithLocalDateTimeWithLiteral(KieBaseTestConfiguration kieBaseTestConfiguration) { // RHBRMS-2799 - checkConstantTemporalConstraint( "localDateTime after \"01-Jan-1970\"" ); + checkConstantTemporalConstraint(kieBaseTestConfiguration, "localDateTime after \"01-Jan-1970\"" ); } - @Test - public void testDateAfterWithLiteral() { - checkConstantTemporalConstraint( "date after \"01-Jan-1970\"" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDateAfterWithLiteral(KieBaseTestConfiguration kieBaseTestConfiguration) { + checkConstantTemporalConstraint(kieBaseTestConfiguration, "date after \"01-Jan-1970\"" ); } - @Test - public void testAfterWithLocalDateWithLiteral() { - checkConstantTemporalConstraint( "localDate after \"01-Jan-1970\"" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testAfterWithLocalDateWithLiteral(KieBaseTestConfiguration kieBaseTestConfiguration) { + checkConstantTemporalConstraint(kieBaseTestConfiguration, "localDate after \"01-Jan-1970\"" ); } - @Test - public void testComparisonWithLocalDateTimeAndLiteral() { - checkConstantTemporalConstraint( "localDate > \"01-Jan-1970\"" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testComparisonWithLocalDateTimeAndLiteral(KieBaseTestConfiguration kieBaseTestConfiguration) { + checkConstantTemporalConstraint(kieBaseTestConfiguration, "localDate > \"01-Jan-1970\"" ); } - @Test - public void testComparisonWithLocalDate() { - checkConstantTemporalConstraint( "localDate > org.drools.mvel.integrationtests.TemporalOperatorTest.parseDateAsLocal(\"01-Jan-1970\")" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testComparisonWithLocalDate(KieBaseTestConfiguration kieBaseTestConfiguration) { + checkConstantTemporalConstraint(kieBaseTestConfiguration, "localDate > org.drools.mvel.integrationtests.TemporalOperatorTest.parseDateAsLocal(\"01-Jan-1970\")" ); } - @Test - public void testComparisonWithLocalDateAndLiteral() { - checkConstantTemporalConstraint( "localDateTime > \"01-Jan-1970\"" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testComparisonWithLocalDateAndLiteral(KieBaseTestConfiguration kieBaseTestConfiguration) { + checkConstantTemporalConstraint(kieBaseTestConfiguration, "localDateTime > \"01-Jan-1970\"" ); } - @Test - public void testComparisonWithLocalDateTime() { - checkConstantTemporalConstraint( "localDateTime > org.drools.mvel.integrationtests.TemporalOperatorTest.parseTimeAsLocal(\"01-Jan-1970\")" ); + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testComparisonWithLocalDateTime(KieBaseTestConfiguration kieBaseTestConfiguration) { + checkConstantTemporalConstraint(kieBaseTestConfiguration, "localDateTime > org.drools.mvel.integrationtests.TemporalOperatorTest.parseTimeAsLocal(\"01-Jan-1970\")" ); } - public void checkConstantTemporalConstraint(String constraint) { + public void checkConstantTemporalConstraint(KieBaseTestConfiguration kieBaseTestConfiguration, String constraint) { String str = "import " + TimestampedObject.class.getCanonicalName() + ";\n" + "global java.util.List list;\n" + "rule R when\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/TreeTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/TreeTest.java index b64851037a7..2e3d5b27008 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/TreeTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/TreeTest.java @@ -18,36 +18,28 @@ */ package org.drools.mvel.integrationtests; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.mvel.compiler.Cheese; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class TreeTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public TreeTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testUnbalancedTrees() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testUnbalancedTrees(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_UnbalancedTrees.drl"); KieSession wm = kbase.newKieSession(); try { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/TypeDeclarationTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/TypeDeclarationTest.java index f2e8c46e006..a1f783238ab 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/TypeDeclarationTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/TypeDeclarationTest.java @@ -18,36 +18,28 @@ */ package org.drools.mvel.integrationtests; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.definition.type.FactType; import org.kie.api.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class TypeDeclarationTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public TypeDeclarationTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void testRecursiveDeclaration() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testRecursiveDeclaration(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String rule = "package org.drools.compiler\n" + "declare Node\n" + " value: String\n" + @@ -77,8 +69,9 @@ public void testRecursiveDeclaration() throws Exception { assertThat(rules).isEqualTo(1); } - @Test - public void testCircularDeclaration() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCircularDeclaration(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { String rule = "package org.drools.mvel.compiler.test\n" + "declare FactA\n" + " fieldB: FactB\n" + @@ -108,8 +101,9 @@ public void testCircularDeclaration() throws Exception { assertThat(rules).isEqualTo(1); } - @Test - public void testCircularDeclarationWithExtension() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testCircularDeclarationWithExtension(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { // DROOLS-640 String drl = "package org.drools.mvel.compiler.test\n" + "declare FactA\n" + diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/UnlinkingTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/UnlinkingTest.java index 9bdb03f6129..74474af50c9 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/UnlinkingTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/UnlinkingTest.java @@ -19,38 +19,30 @@ package org.drools.mvel.integrationtests; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.drools.core.common.InternalFactHandle; import org.drools.mvel.compiler.Person; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class UnlinkingTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public UnlinkingTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Test - public void multipleJoinsUsingSameOTN() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void multipleJoinsUsingSameOTN(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_LRUnlinking.drl"); final KieSession wmOne = kbase.newKieSession(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/VarargsTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/VarargsTest.java index bb502f0c94f..1978c74f6e7 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/VarargsTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/VarargsTest.java @@ -18,18 +18,17 @@ */ package org.drools.mvel.integrationtests; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Set; +import java.util.stream.Stream; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.definition.type.Modifies; import org.kie.api.definition.type.PropertyReactive; @@ -37,22 +36,15 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class VarargsTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public VarargsTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - - @Test - public void testStrStartsWith() throws Exception { + + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testStrStartsWith(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "varargs.drl"); KieSession ksession = kbase.newKieSession(); @@ -65,8 +57,9 @@ public void testStrStartsWith() throws Exception { assertThat(inv.isI3()).isTrue(); } - @Test - public void testVarargs() throws Exception { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testVarargs(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception { KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "varargs2.drl"); KieSession ksession = kbase.newKieSession(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/WindowTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/WindowTest.java index e792d8c9cf9..cbbe45424a6 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/WindowTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/WindowTest.java @@ -20,19 +20,17 @@ import java.io.Serializable; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; import org.drools.core.impl.RuleBaseFactory; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.KieSessionConfiguration; @@ -42,18 +40,10 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class WindowTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public WindowTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseStreamConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseStreamConfigurations(true).stream(); } private KieSession ksession; @@ -133,8 +123,7 @@ public static Collection getParameters() { " result.add($eventCount);\n" + "end\n"; - @Before - public void initialization() { + public void initialization(KieBaseTestConfiguration kieBaseTestConfiguration) { KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, drl); KieSessionConfiguration ksconfig = RuleBaseFactory @@ -146,13 +135,15 @@ public void initialization() { clock = ksession.getSessionClock(); } - @After + @AfterEach public void clean() { ksession.dispose(); } - @Test - public void testTimeWindow() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testTimeWindow(KieBaseTestConfiguration KieBaseTestConfiguration) throws InterruptedException { + initialization(KieBaseTestConfiguration); EntryPoint entryPoint = ksession.getEntryPoint("EventStream"); final long results[] = new long[] { 1, 2, 3, 3, 3 }; TestEvent event; @@ -167,8 +158,10 @@ public void testTimeWindow() throws InterruptedException { } } - @Test - public void testLengthWindow() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testLengthWindow(KieBaseTestConfiguration kieBaseTestConfiguration) { + initialization(kieBaseTestConfiguration); EntryPoint entryPoint = ksession.getEntryPoint("EventStream"); TestEvent event; @@ -181,8 +174,10 @@ public void testLengthWindow() { } } - @Test - public void testDeclaredTimeWindowInQuery() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclaredTimeWindowInQuery(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initialization(kieBaseTestConfiguration); final long results[] = new long[] { 1, 2, 3, 4, 5, 5, 5, 5, 5, 5 }; EntryPoint entryPoint = ksession.getEntryPoint("EventStream"); TestEvent event; @@ -197,8 +192,10 @@ public void testDeclaredTimeWindowInQuery() throws InterruptedException { } } - @Test - public void testDeclaredLengthWindowInQuery() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclaredLengthWindowInQuery(KieBaseTestConfiguration kieBaseTestConfiguration) { + initialization(kieBaseTestConfiguration); EntryPoint entryPoint = ksession.getEntryPoint("EventStream"); TestEvent event; @@ -211,8 +208,10 @@ public void testDeclaredLengthWindowInQuery() { } } - @Test - public void testDeclaredTimeWindowInRule() throws InterruptedException { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclaredTimeWindowInRule(KieBaseTestConfiguration kieBaseTestConfiguration) throws InterruptedException { + initialization(kieBaseTestConfiguration); final long results[] = new long[] { 1, 2, 3, 4, 5, 5, 5, 5, 5, 5 }; EntryPoint entryPoint = ksession.getEntryPoint("EventStream"); List result = new ArrayList(); @@ -228,8 +227,10 @@ public void testDeclaredTimeWindowInRule() throws InterruptedException { } } - @Test - public void testDeclaredLengthWindowInRule() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testDeclaredLengthWindowInRule(KieBaseTestConfiguration kieBaseTestConfiguration) { + initialization(kieBaseTestConfiguration); EntryPoint entryPoint = ksession.getEntryPoint("EventStream"); List result = new ArrayList(); ksession.setGlobal("result", result); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/WorkingMemoryActionsSerializationTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/WorkingMemoryActionsSerializationTest.java index 5996d2da270..eb13b9c6a60 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/WorkingMemoryActionsSerializationTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/WorkingMemoryActionsSerializationTest.java @@ -20,21 +20,19 @@ import java.io.Serializable; import java.util.Arrays; -import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Stream; import org.drools.core.rule.consequence.KnowledgeHelper; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.event.rule.AfterMatchFiredEvent; import org.kie.api.event.rule.DefaultAgendaEventListener; @@ -43,20 +41,13 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -@Ignore -@RunWith(Parameterized.class) +@Disabled public class WorkingMemoryActionsSerializationTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public WorkingMemoryActionsSerializationTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); - } private static final List RULES = Arrays.asList("enableRecording", "saveRecord", "processEvent", "ignoreEvent"); //rules expected to be executed private KieSession ksession; private KieBase kbase; @@ -109,8 +100,7 @@ public static Collection getParameters() { " //side effects go here\n" + "end"; - @Before - public void before() { + public void setUp(KieBaseTestConfiguration kieBaseTestConfiguration) { ruleCalls.clear(); KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, drl); @@ -140,14 +130,16 @@ public void afterMatchFired(final AfterMatchFiredEvent event) { } - @After + @AfterEach public void after() { ksession.halt(); ksession.dispose(); } - @Test - public void testMultipleFires() { + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testMultipleFires(KieBaseTestConfiguration kieBaseTestConfiguration) { + setUp(kieBaseTestConfiguration); playAnEvent("discardCard"); checkExecutions(RULES, Arrays.asList(1, 1, 1, 0)); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/XSDResourceTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/XSDResourceTest.java index f2ae29adab7..1aa0b966d2f 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/XSDResourceTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/XSDResourceTest.java @@ -18,13 +18,14 @@ */ package org.drools.mvel.integrationtests; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.kie.api.KieBase; import org.kie.api.KieServices; import org.kie.api.runtime.KieContainer; import static org.assertj.core.api.Assertions.assertThat; + /** * Tests KIE package compilation when there is a XSD resource (BZ 1120972) - manifests only when using * KieClasspathContainer. diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/eventgenerator/SimpleEventGeneratorTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/eventgenerator/SimpleEventGeneratorTest.java index f8516c55e47..974330e656c 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/eventgenerator/SimpleEventGeneratorTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/eventgenerator/SimpleEventGeneratorTest.java @@ -19,39 +19,31 @@ package org.drools.mvel.integrationtests.eventgenerator; import java.io.IOException; -import java.util.Collection; +import java.util.stream.Stream; import org.drools.drl.parser.DroolsParserException; import org.drools.mvel.integrationtests.eventgenerator.Event.EventType; import org.drools.testcoverage.common.util.KieBaseTestConfiguration; import org.drools.testcoverage.common.util.KieBaseUtil; -import org.drools.testcoverage.common.util.TestParametersUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.drools.testcoverage.common.util.TestParametersUtil2; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) public class SimpleEventGeneratorTest { - private final KieBaseTestConfiguration kieBaseTestConfiguration; - - public SimpleEventGeneratorTest(final KieBaseTestConfiguration kieBaseTestConfiguration) { - this.kieBaseTestConfiguration = kieBaseTestConfiguration; - } - - @Parameterized.Parameters(name = "KieBase type={0}") - public static Collection getParameters() { - return TestParametersUtil.getKieBaseCloudConfigurations(true); + public static Stream parameters() { + return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream(); } private final static String TEST_RULE_FILE = "test_eventGenerator.drl"; - @Test - public void testEventGenerationMaxItems() throws DroolsParserException, IOException, Exception{ + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEventGenerationMaxItems(KieBaseTestConfiguration kieBaseTestConfiguration) throws DroolsParserException, IOException, Exception{ KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, TEST_RULE_FILE); KieSession ksession = kbase.newKieSession(); @@ -63,8 +55,9 @@ public void testEventGenerationMaxItems() throws DroolsParserException, IOExcept assertThat(10).isEqualTo(ksession.getQueryResults("all inserted events").size()); } - @Test - public void testEventGenerationMaxTime() throws DroolsParserException, IOException, Exception{ + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEventGenerationMaxTime(KieBaseTestConfiguration kieBaseTestConfiguration) throws DroolsParserException, IOException, Exception{ KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, TEST_RULE_FILE); KieSession ksession = kbase.newKieSession(); @@ -76,8 +69,9 @@ public void testEventGenerationMaxTime() throws DroolsParserException, IOExcepti assertThat(ksession.getQueryResults("all inserted events with generation time < 1 min").size()).isEqualTo(ksession.getQueryResults("all inserted events").size()); } - @Test - public void testEventGenerationMaxTimeAndMaxItems() throws DroolsParserException, IOException, Exception{ + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEventGenerationMaxTimeAndMaxItems(KieBaseTestConfiguration kieBaseTestConfiguration) throws DroolsParserException, IOException, Exception{ KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, TEST_RULE_FILE); KieSession ksession = kbase.newKieSession(); @@ -90,8 +84,9 @@ public void testEventGenerationMaxTimeAndMaxItems() throws DroolsParserException assertThat(ksession.getQueryResults("all inserted events with generation time < 1 min").size() <= 10).isTrue(); } - @Test - public void testEventGenerationDelayedMaxItems() throws DroolsParserException, IOException, Exception{ + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEventGenerationDelayedMaxItems(KieBaseTestConfiguration kieBaseTestConfiguration) throws DroolsParserException, IOException, Exception{ KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, TEST_RULE_FILE); KieSession ksession = kbase.newKieSession(); @@ -103,8 +98,9 @@ public void testEventGenerationDelayedMaxItems() throws DroolsParserException, I assertThat(10).isEqualTo(ksession.getQueryResults("all inserted events").size()); } - @Test - public void testEventGenerationDelayedMaxTime() throws DroolsParserException, IOException, Exception{ + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEventGenerationDelayedMaxTime(KieBaseTestConfiguration kieBaseTestConfiguration) throws DroolsParserException, IOException, Exception{ KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, TEST_RULE_FILE); KieSession ksession = kbase.newKieSession(); @@ -116,8 +112,9 @@ public void testEventGenerationDelayedMaxTime() throws DroolsParserException, IO assertThat(ksession.getQueryResults("all inserted events with 2 min < generation time < 3 min").size()).isEqualTo(ksession.getQueryResults("all inserted events").size()); } - @Test - public void testEventGenerationDelayedMaxTimeAndMaxItems() throws DroolsParserException, IOException, Exception{ + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEventGenerationDelayedMaxTimeAndMaxItems(KieBaseTestConfiguration kieBaseTestConfiguration) throws DroolsParserException, IOException, Exception{ KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, TEST_RULE_FILE); KieSession ksession = kbase.newKieSession(); @@ -130,8 +127,9 @@ public void testEventGenerationDelayedMaxTimeAndMaxItems() throws DroolsParserEx assertThat(ksession.getQueryResults("all inserted events with 2 min < generation time < 3 min").size() <= 10).isTrue(); } - @Test - public void testEventGenerationGlobalMaxTime() throws DroolsParserException, IOException, Exception{ + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEventGenerationGlobalMaxTime(KieBaseTestConfiguration kieBaseTestConfiguration) throws DroolsParserException, IOException, Exception{ KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, TEST_RULE_FILE); KieSession ksession = kbase.newKieSession(); @@ -144,8 +142,9 @@ public void testEventGenerationGlobalMaxTime() throws DroolsParserException, IOE assertThat(ksession.getQueryResults("all inserted events with generation time < 1 min").size()).isEqualTo(ksession.getQueryResults("all inserted events").size()); } - @Test - public void testEventGenerationMultipleSources() throws DroolsParserException, IOException, Exception{ + @ParameterizedTest(name = "KieBase type={0}") + @MethodSource("parameters") + public void testEventGenerationMultipleSources(KieBaseTestConfiguration kieBaseTestConfiguration) throws DroolsParserException, IOException, Exception{ KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, TEST_RULE_FILE); KieSession ksession = kbase.newKieSession(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/marshalling/InputStreamMarkResetTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/marshalling/InputStreamMarkResetTest.java index 03e385f362a..0779b2a3840 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/marshalling/InputStreamMarkResetTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/marshalling/InputStreamMarkResetTest.java @@ -27,7 +27,7 @@ import java.util.Date; import java.util.Objects; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/DeleteTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/DeleteTest.java index 999661fbd9e..bc1fa201f40 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/DeleteTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/session/DeleteTest.java @@ -19,7 +19,6 @@ package org.drools.mvel.integrationtests.session; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.stream.Stream; @@ -36,8 +35,6 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.kie.api.KieBase; import org.kie.api.runtime.KieSession; import org.kie.api.runtime.rule.FactHandle;