Skip to content

Commit

Permalink
More unit tests migrated to JUnit5
Browse files Browse the repository at this point in the history
  • Loading branch information
pibizza committed Oct 29, 2024
1 parent 5995633 commit 0c757ff
Show file tree
Hide file tree
Showing 41 changed files with 1,453 additions and 1,249 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

public abstract class AbstractBackwardChainingTest {

@ParameterizedTest
@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@Timeout(10000)
public void testQueryPositional(KieBaseTestConfiguration kieBaseTestConfiguration) {
Expand Down Expand Up @@ -82,7 +82,7 @@ public void testQueryPositional(KieBaseTestConfiguration kieBaseTestConfiguratio
testQuery(kieBaseTestConfiguration, drl);
}

@ParameterizedTest
@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@Timeout(10000)
public void testQueryNamed(KieBaseTestConfiguration kieBaseTestConfiguration) {
Expand Down Expand Up @@ -130,7 +130,7 @@ public void testQueryNamed(KieBaseTestConfiguration kieBaseTestConfiguration) {
testQuery(kieBaseTestConfiguration, drl);
}

@ParameterizedTest
@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@Timeout(10000)
public void testQueryMixed(KieBaseTestConfiguration kieBaseTestConfiguration) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
import org.drools.testcoverage.common.util.KieBaseUtil;
import org.drools.testcoverage.common.util.KieSessionTestConfiguration;
import org.drools.testcoverage.common.util.SerializationHelper;
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.marshalling.ObjectMarshallingStrategy;
import org.kie.api.runtime.Environment;
Expand All @@ -39,14 +40,9 @@

public abstract class AbstractCellTest {

protected final KieBaseTestConfiguration kieBaseTestConfiguration;

public AbstractCellTest(final KieBaseTestConfiguration kieBaseTestConfiguration) {
this.kieBaseTestConfiguration = kieBaseTestConfiguration;
}

@Test
public void testCell() throws IOException, ClassNotFoundException {
@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
public void testCell(KieBaseTestConfiguration kieBaseTestConfiguration) throws IOException, ClassNotFoundException {

final String drl = "package evalmodify;\n" +
"\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
import org.drools.testcoverage.common.util.KieBaseTestConfiguration;
import org.drools.testcoverage.common.util.KieBaseUtil;
import org.drools.testcoverage.common.util.KieSessionTestConfiguration;
import org.junit.Test;
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;
Expand All @@ -43,14 +45,10 @@

public abstract class AbstractCepEspTest {

protected final KieBaseTestConfiguration kieBaseTestConfiguration;

public AbstractCepEspTest(final KieBaseTestConfiguration kieBaseTestConfiguration) {
this.kieBaseTestConfiguration = kieBaseTestConfiguration;
}

@Test(timeout = 10000)
public void testAssertBehaviorOnEntryPoints() {
@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@Timeout(10000)
public void testAssertBehaviorOnEntryPoints(KieBaseTestConfiguration kieBaseTestConfiguration) {
final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("cep-esp-test", kieBaseTestConfiguration,
"org/drools/compiler/integrationtests/test_CEP_AssertBehaviorOnEntryPoints.drl");
final KieSession ksession = kbase.newKieSession();
Expand Down Expand Up @@ -91,8 +89,10 @@ public void testAssertBehaviorOnEntryPoints() {
}
}

@Test(timeout = 10000L)
public void testDuplicateFiring2() {
@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@Timeout(10000)
public void testDuplicateFiring2(KieBaseTestConfiguration kieBaseTestConfiguration) {

final String drl = "package org.test;\n" +
"import " + StockTick.class.getCanonicalName() + ";\n " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static Stream<KieBaseTestConfiguration> parameters() {
return TestParametersUtil2.getKieBaseStreamConfigurations(true).stream();
}

@ParameterizedTest
@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
public void testAccumulatesExpireVsCancel(KieBaseTestConfiguration kieBaseTestConfiguration) throws Exception {
// JBRULES-3201
Expand Down Expand Up @@ -126,7 +126,7 @@ public void testAccumulatesExpireVsCancel(KieBaseTestConfiguration kieBaseTestCo
}
}

@ParameterizedTest
@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
public void testManySlidingWindows(KieBaseTestConfiguration kieBaseTestConfiguration) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
package org.drools.compiler.integrationtests;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;

import org.drools.core.reteoo.JoinNode;
import org.drools.core.reteoo.LeftTupleSink;
Expand All @@ -36,10 +36,10 @@
import org.drools.testcoverage.common.util.KieBaseUtil;
import org.drools.testcoverage.common.util.KieSessionTestConfiguration;
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.KieModule;
Expand All @@ -51,23 +51,17 @@
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;

@RunWith(Parameterized.class)
public class AccumulateMvelDialectTest {

private final KieBaseTestConfiguration kieBaseTestConfiguration;

public AccumulateMvelDialectTest( final KieBaseTestConfiguration kieBaseTestConfiguration) {
this.kieBaseTestConfiguration = kieBaseTestConfiguration;
}

@Parameterized.Parameters(name = "KieBase type={0}")
public static Collection<Object[]> getParameters() {
return TestParametersUtil.getKieBaseCloudConfigurations(true);
public static Stream<KieBaseTestConfiguration> parameters() {
return TestParametersUtil2.getKieBaseCloudConfigurations(true).stream();
}

// See https://issues.jboss.org/browse/DROOLS-2733
@Test(timeout = 10000)
public void testMVELAccumulate() {
@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@Timeout(10000)
public void testMVELAccumulate(KieBaseTestConfiguration kieBaseTestConfiguration) {
final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("accumulate-test", kieBaseTestConfiguration,
"org/drools/compiler/integrationtests/test_AccumulateMVEL.drl");
final KieSession wm = kbase.newKieSession();
Expand Down Expand Up @@ -101,8 +95,10 @@ public void testMVELAccumulate() {
}

// See https://issues.jboss.org/browse/DROOLS-2733
@Test(timeout = 10000)
public void testMVELAccumulate2WM() {
@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
@Timeout(10000)
public void testMVELAccumulate2WM(KieBaseTestConfiguration kieBaseTestConfiguration) {

final KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources("accumulate-test", kieBaseTestConfiguration,
"org/drools/compiler/integrationtests/test_AccumulateMVEL.drl");
Expand Down Expand Up @@ -167,20 +163,22 @@ public void testMVELAccumulate2WM() {
}


@Test
public void testAccFunctionOpaqueJoins() {
@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
public void testAccFunctionOpaqueJoins(KieBaseTestConfiguration kieBaseTestConfiguration) {
// DROOLS-661
testAccFunctionOpaqueJoins(PropertySpecificOption.ALLOWED);
testAccFunctionOpaqueJoins(kieBaseTestConfiguration, PropertySpecificOption.ALLOWED);
}

@Test
public void testAccFunctionOpaqueJoinsWithPropertyReactivity() {
@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
public void testAccFunctionOpaqueJoinsWithPropertyReactivity(KieBaseTestConfiguration kieBaseTestConfiguration) {
// DROOLS-1445
testAccFunctionOpaqueJoins(PropertySpecificOption.ALWAYS);
testAccFunctionOpaqueJoins(kieBaseTestConfiguration, PropertySpecificOption.ALWAYS);
}

// This is unsupported as the declared type Data is loosely typed
private void testAccFunctionOpaqueJoins(final PropertySpecificOption propertySpecificOption) {
private void testAccFunctionOpaqueJoins(KieBaseTestConfiguration kieBaseTestConfiguration, final PropertySpecificOption propertySpecificOption) {
final String drl = "package org.test; " +
"import java.util.*; " +
"global List list; " +
Expand Down Expand Up @@ -273,8 +271,9 @@ private void testAccFunctionOpaqueJoins(final PropertySpecificOption propertySpe
}
}

@Test
public void testAccumulateWithSameSubnetwork() {
@ParameterizedTest(name = "KieBase type={0}")
@MethodSource("parameters")
public void testAccumulateWithSameSubnetwork(KieBaseTestConfiguration kieBaseTestConfiguration) {
final String drl = "package org.drools.compiler.test;\n" +
"import " + Cheese.class.getCanonicalName() + ";\n" +
"import " + Person.class.getCanonicalName() + ";\n" +
Expand Down
Loading

0 comments on commit 0c757ff

Please sign in to comment.