Skip to content

Commit

Permalink
More tests migrated to Junit5
Browse files Browse the repository at this point in the history
  • Loading branch information
pibizza committed Nov 4, 2024
1 parent c7a57ce commit 563ce66
Show file tree
Hide file tree
Showing 16 changed files with 104 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import org.drools.core.impl.InternalRuleBase;
import org.drools.core.impl.RuleBaseFactory;
import org.drools.kiesession.rulebase.KnowledgeBaseFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.kie.api.KieBase;
import org.kie.api.KieBaseConfiguration;
import org.kie.api.conf.EventProcessingOption;
Expand Down Expand Up @@ -57,7 +57,7 @@ public class DynamicEvalTest {
KieBaseConfiguration baseConfig;
KieSessionConfiguration sessionConfig;

@Before
@BeforeEach
public void setUp() throws Exception {

baseConfig = RuleBaseFactory.newKnowledgeBaseConfiguration();
Expand Down Expand Up @@ -91,7 +91,7 @@ public void loadPackages( Resource res, ResourceType type ) {

}

@After
@AfterEach
public void tearDown() {
if (session != null) {
session.dispose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,30 @@

public class AgendaFilterTest {

public static Stream<KieBaseTestConfiguration> parameters() {
public static Stream<KieBaseTestConfiguration> parameters() {
return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream();
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void testAgendaFilterRuleNameStartsWith(KieBaseTestConfiguration kieBaseTestConfiguration) {
testAgendaFilter(kieBaseTestConfiguration, new RuleNameStartsWithAgendaFilter("B"), "Bbb");
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void testAgendaFilterRuleNameEndsWith(KieBaseTestConfiguration kieBaseTestConfiguration) {
testAgendaFilter(kieBaseTestConfiguration, new RuleNameEndsWithAgendaFilter("a"), "Aaa");
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void testAgendaFilterRuleNameMatches(KieBaseTestConfiguration kieBaseTestConfiguration) {
testAgendaFilter(kieBaseTestConfiguration, new RuleNameMatchesAgendaFilter(".*b."), "Bbb");
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void testAgendaFilterRuleNameEquals(KieBaseTestConfiguration kieBaseTestConfiguration) {
testAgendaFilter(kieBaseTestConfiguration, new RuleNameEqualsAgendaFilter("Aaa"), "Aaa");
}
Expand All @@ -93,7 +93,7 @@ private void testAgendaFilter(KieBaseTestConfiguration kieBaseTestConfiguration,
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void testDirectFiringIgnoresAgendaFilter(KieBaseTestConfiguration kieBaseTestConfiguration) {
// DROOLS-6510
String str =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ public void tearDown() {
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void updateTheOnlyFactTest(KieBaseTestConfiguration kieBaseTestConfiguration) {
setUp(kieBaseTestConfiguration);
setUp(kieBaseTestConfiguration);
final Person person = new Person("George", 18);
final FactHandle factPerson = ksession.insert(person);
assertThat(ksession.getObjects()).hasSize(1);
Expand All @@ -80,9 +80,9 @@ public void updateTheOnlyFactTest(KieBaseTestConfiguration kieBaseTestConfigurat
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void updateWithNullTest(KieBaseTestConfiguration kieBaseTestConfiguration) {
setUp(kieBaseTestConfiguration);
setUp(kieBaseTestConfiguration);
final Person person = new Person("George", 18);
final FactHandle factPerson = ksession.insert(person);
verifyFactsPresentInSession(1, Person.class);
Expand All @@ -91,9 +91,9 @@ public void updateWithNullTest(KieBaseTestConfiguration kieBaseTestConfiguration
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void updateWithDifferentClassGetQueryResultsTest(KieBaseTestConfiguration kieBaseTestConfiguration) {
setUp(kieBaseTestConfiguration);
setUp(kieBaseTestConfiguration);
final Person person = new Person("George", 18);
final FactHandle fact = ksession.insert(person);

Expand All @@ -114,9 +114,9 @@ public void updateWithDifferentClassGetQueryResultsTest(KieBaseTestConfiguration
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void updateWithDifferentClassGetObjectsTest(KieBaseTestConfiguration kieBaseTestConfiguration) {
setUp(kieBaseTestConfiguration);
setUp(kieBaseTestConfiguration);
final Person person = new Person("George", 18);
final FactHandle factPerson = ksession.insert(person);
final Person personToBeVerified = verifyFactsPresentInSession(1, Person.class).get(0);
Expand All @@ -131,9 +131,9 @@ public void updateWithDifferentClassGetObjectsTest(KieBaseTestConfiguration kieB
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void updateFireRulesTest(KieBaseTestConfiguration kieBaseTestConfiguration) {
setUp(kieBaseTestConfiguration);
setUp(kieBaseTestConfiguration);
final Person george = new Person("George", 17);
final Person henry = new Person("Henry", 25);
final FactHandle georgeFact = ksession.insert(george);
Expand All @@ -158,9 +158,9 @@ public void updateFireRulesTest(KieBaseTestConfiguration kieBaseTestConfiguratio
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void updateFactOnRuleFireTest(KieBaseTestConfiguration kieBaseTestConfiguration) {
setUp(kieBaseTestConfiguration);
setUp(kieBaseTestConfiguration);
final Cheese camembert = new Cheese("Camembert", 19);
final Cheese cheddar = new Cheese("Cheddar", 45);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static Stream<KieBaseTestConfiguration> parameters() {
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void testCrossProductRemovingIdentityEquals(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception {
KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_CrossProductRemovingIdentityEquals.drl");
KieSession session = kbase.newKieSession();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ public void setUp(KieBaseTestConfiguration kieBaseTestConfiguration) {

@AfterEach
public void tearDown() {
if (ksession != null) {
ksession.dispose();
}
if (ksession != null) {
ksession.dispose();
}
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void deleteFactTest(KieBaseTestConfiguration kieBaseTestConfiguration) {
setUp(kieBaseTestConfiguration);
setUp(kieBaseTestConfiguration);
ksession.insert(new Person("Petr", 25));

FactHandle george = ksession.insert(new Person("George", 19));
Expand All @@ -91,9 +91,9 @@ public void deleteFactTest(KieBaseTestConfiguration kieBaseTestConfiguration) {
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void deleteFactTwiceTest(KieBaseTestConfiguration kieBaseTestConfiguration) {
setUp(kieBaseTestConfiguration);
setUp(kieBaseTestConfiguration);
FactHandle george = ksession.insert(new Person("George", 19));
QueryResults results = ksession.getQueryResults("countPerson");
assertThat(results).isNotEmpty();
Expand All @@ -110,16 +110,16 @@ public void deleteFactTwiceTest(KieBaseTestConfiguration kieBaseTestConfiguratio
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void deleteNullFactTest(KieBaseTestConfiguration kieBaseTestConfiguration) {
setUp(kieBaseTestConfiguration);
setUp(kieBaseTestConfiguration);
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() ->ksession.delete(null));
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void deleteUpdatedFactTest(KieBaseTestConfiguration kieBaseTestConfiguration) {
setUp(kieBaseTestConfiguration);
setUp(kieBaseTestConfiguration);
FactHandle person = ksession.insert(new Person("George", 18));

ksession.update(person, new Person("John", 21));
Expand All @@ -135,9 +135,9 @@ public void deleteUpdatedFactTest(KieBaseTestConfiguration kieBaseTestConfigurat
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void deleteUpdatedFactDifferentClassTest(KieBaseTestConfiguration kieBaseTestConfiguration) {
setUp(kieBaseTestConfiguration);
setUp(kieBaseTestConfiguration);
FactHandle fact = ksession.insert(new Person("George", 18));

assertThat(ksession.getObjects()).hasSize(1);
Expand All @@ -154,7 +154,7 @@ public void deleteUpdatedFactDifferentClassTest(KieBaseTestConfiguration kieBase
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void testRetractLeftTuple(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception {
// JBRULES-3420
final String str =
Expand Down Expand Up @@ -194,7 +194,7 @@ public void testRetractLeftTuple(KieBaseTestConfiguration kieBaseTestConfigurati
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void testAssertRetract(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception {
// postponed while I sort out KnowledgeHelperFixer
KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "assert_retract.drl");
Expand Down Expand Up @@ -222,7 +222,7 @@ public void testAssertRetract(KieBaseTestConfiguration kieBaseTestConfiguration)
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void testEmptyAfterRetractInIndexedMemory(KieBaseTestConfiguration kieBaseTestConfiguration) {
String str = "";
str += "package org.simple \n";
Expand Down Expand Up @@ -252,7 +252,7 @@ public void testEmptyAfterRetractInIndexedMemory(KieBaseTestConfiguration kieBas
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void testModifyRetractAndModifyInsert(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception {
KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_ModifyRetractInsert.drl");
KieSession ksession = kbase.newKieSession();
Expand All @@ -272,7 +272,7 @@ public void testModifyRetractAndModifyInsert(KieBaseTestConfiguration kieBaseTes
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void testModifyRetractWithFunction(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception {
KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_RetractModifyWithFunction.drl");
KieSession ksession = kbase.newKieSession();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static Stream<KieBaseTestConfiguration> parameters() {
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void testEntryPointWithVarIN(KieBaseTestConfiguration kieBaseTestConfiguration) {
final String str = "package org.drools.mvel.compiler.test;\n" +
"\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static Stream<KieBaseTestConfiguration> parameters() {
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
// this isn't possible, we can only narrow with type safety, not widen.
// unless typesafe=false is used
public void testAccessFieldsFromSubClass(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception {
Expand Down Expand Up @@ -72,7 +72,7 @@ public void testAccessFieldsFromSubClass(KieBaseTestConfiguration kieBaseTestCon
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void testAccessClassTypeField(KieBaseTestConfiguration kieBaseTestConfiguration) {
final String str = "package org.drools.mvel.compiler\n" +
"rule r1\n" +
Expand All @@ -90,7 +90,7 @@ public void testAccessClassTypeField(KieBaseTestConfiguration kieBaseTestConfigu
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void testGenericsOption(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception {
// JBRULES-3579
final String str = "import org.drools.mvel.compiler.*;\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static Stream<KieBaseTestConfiguration> parameters() {
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void testInsert(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception {
String drl = "";
drl += "package test\n";
Expand Down Expand Up @@ -81,7 +81,7 @@ public void testInsert(KieBaseTestConfiguration kieBaseTestConfiguration) throws
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void testInsertionOrder(KieBaseTestConfiguration kieBaseTestConfiguration) {
KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_InsertionOrder.drl");
KieSession ksession = kbase.newKieSession();
Expand Down Expand Up @@ -113,7 +113,7 @@ public void testInsertionOrder(KieBaseTestConfiguration kieBaseTestConfiguration
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void testInsertFinalClassInstance(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception {
KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_FinalClass.drl");
KieSession ksession = kbase.newKieSession();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static Stream<KieBaseTestConfiguration> parameters() {
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void testLatinLocale(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception {
final Locale defaultLoc = Locale.getDefault();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static Stream<KieBaseTestConfiguration> parameters() {
}

@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@MethodSource("parameters")
public void testEventModel(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception {
KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_EventModel.drl");
KieSession wm = kbase.newKieSession();
Expand Down
Loading

0 comments on commit 563ce66

Please sign in to comment.