Skip to content

Commit

Permalink
[incubator-kie-drools apache#6136] Migrate tests to Junit5 (apache#6138)
Browse files Browse the repository at this point in the history
* Migrated drools-examples-api

* Migrated drools-fastutil

* Migrated drools-kiesession

* Migrated drools-compiler

* Migrated drools-legacy-test-util

* Migrated drools-metric

* Migrated drools-mvel

* Migrated drools-templates

* Migrated drools-tms

* Migrated drools-wiring

* Fixed issue with tests

* Better solution to migrate test
  • Loading branch information
pibizza authored and rgdoliveira committed Nov 7, 2024
1 parent d3d9e50 commit 241966d
Show file tree
Hide file tree
Showing 102 changed files with 589 additions and 294 deletions.
5 changes: 5 additions & 0 deletions drools-compiler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@
<artifactId>drools-wiring-dynamic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.kie</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.drools.compiler;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.kie.api.io.ResourceType;
import org.kie.internal.utils.KieHelper;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@

import org.drools.drl.ast.descr.PackageDescr;
import org.drools.io.ByteArrayResource;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.drools.util.StringUtils.generateUUID;

public class CompositePackageDescrTest {

private static final String NAMESPACE = "namespace";
private CompositePackageDescr compositePackageDescr;

@Before
@BeforeEach
public void setup() {
compositePackageDescr = new CompositePackageDescr(new ByteArrayResource(), new PackageDescr(NAMESPACE));
}
Expand All @@ -50,7 +51,7 @@ public void addPackageDescrSamePkgUUID() {
assertThat(compositePackageDescr.getPreferredPkgUUID().get()).isEqualTo(pkgUUID);
}

@Test(expected = RuntimeException.class)
@Test
public void addPackageDescrDifferentPkgUUID() {
String pkgUUID = generateUUID();
PackageDescr first = new PackageDescr(NAMESPACE);
Expand All @@ -64,6 +65,8 @@ public void addPackageDescrDifferentPkgUUID() {
second.setPreferredPkgUUID(pkgUUID);
assertThat(second.getPreferredPkgUUID().isPresent()).isTrue();
assertThat(second.getPreferredPkgUUID().get()).isNotEqualTo(first.getPreferredPkgUUID().get());
compositePackageDescr.addPackageDescr(new ByteArrayResource(), second);
assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> {
compositePackageDescr.addPackageDescr(new ByteArrayResource(), second);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.drools.drl.ast.descr.PackageDescr;
import org.drools.drl.ast.dsl.PackageDescrBuilder;
import org.drools.drl.ast.dsl.impl.PackageDescrBuilderImpl;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down
11 changes: 5 additions & 6 deletions drools-examples-api/default-kiesession-from-file/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@
<groupId>org.drools</groupId>
<artifactId>drools-engine-classic</artifactId>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
import java.io.PrintStream;
import java.util.Arrays;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.kie.api.KieServices;
import org.kie.api.builder.KieModule;
import org.kie.api.builder.KieRepository;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class DefaultKieSessionFromByteArrayExampleTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
*/
package org.drools.example.api.defaultkiesessionfromfile;

import org.junit.Test;

import java.io.ByteArrayOutputStream;

import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.PrintStream;

import static org.junit.Assert.assertEquals;
import org.junit.jupiter.api.Test;

public class DefaultKieSessionFromFileExampleTest {

Expand Down
11 changes: 5 additions & 6 deletions drools-examples-api/default-kiesession/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@
<groupId>org.drools</groupId>
<artifactId>drools-engine-classic</artifactId>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
*/
package org.drools.example.api.defaultkiesession;

import org.junit.Test;

import java.io.ByteArrayOutputStream;

import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.PrintStream;

import static org.junit.Assert.assertEquals;
import org.junit.jupiter.api.Test;

public class DefaultKieSessionExampleTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
*/
package org.drools.example.api.defaultkiesession;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.kie.api.KieServices;
import org.kie.api.builder.KieBuilder;
import org.kie.api.runtime.KieSession;

import java.io.ByteArrayOutputStream;

import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;

import static org.junit.Assert.assertEquals;

public class DefaultKieSessionFromFSExampleTest {

private static final String NL = System.getProperty("line.separator");
Expand Down
11 changes: 5 additions & 6 deletions drools-examples-api/kie-module-from-multiple-files/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,17 @@
<artifactId>drools-engine-classic</artifactId>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<!-- Needed by the example as it uses this kjar -->
<dependency>
<groupId>org.drools</groupId>
<artifactId>kiebase-inclusion</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
*/
package org.drools.example.api.kiemodulefrommultiplefiles;

import org.junit.Test;

import java.io.ByteArrayOutputStream;

import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.PrintStream;

import static org.junit.Assert.assertEquals;
import org.junit.jupiter.api.Test;

public class KieModuleFromMultipleFilesExampleTest {

Expand Down
10 changes: 5 additions & 5 deletions drools-examples-api/kiebase-inclusion/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@
<groupId>org.drools</groupId>
<artifactId>named-kiesession</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
*/
package org.drools.example.api.kiebaseinclusion;

import org.junit.Test;

import java.io.ByteArrayOutputStream;

import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.PrintStream;

import static org.junit.Assert.assertEquals;
import org.junit.jupiter.api.Test;

public class KieBaseInclusionExampleTest {

Expand Down
11 changes: 5 additions & 6 deletions drools-examples-api/kiecontainer-from-kierepo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
<groupId>org.kie</groupId>
<artifactId>kie-ci</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-engine-classic</artifactId>
Expand All @@ -49,12 +54,6 @@
<groupId>org.drools</groupId>
<artifactId>named-kiesession</artifactId>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
*/
package org.drools.example.api.kiecontainerfromkierepo;

import org.junit.Test;

import java.io.ByteArrayOutputStream;

import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.PrintStream;

import static org.junit.Assert.assertEquals;
import org.junit.jupiter.api.Test;

public class KieContainerFromKieRepoExampleTest {

Expand Down
10 changes: 5 additions & 5 deletions drools-examples-api/kiefilesystem-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
*/
package org.drools.example.api.kiefilesystem;

import org.junit.Test;

import java.io.ByteArrayOutputStream;

import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.PrintStream;

import static org.junit.Assert.assertEquals;
import org.junit.jupiter.api.Test;

public class KieFileSystemExampleTest {

Expand Down
11 changes: 5 additions & 6 deletions drools-examples-api/kiemodulemodel-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,17 @@
<artifactId>kie-api</artifactId>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<!-- Needed by the example as it uses these kjars -->
<dependency>
<groupId>org.drools</groupId>
<artifactId>named-kiesession</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>kiebase-inclusion</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
*/
package org.drools.example.api.kiemodulemodel;

import org.junit.Test;

import java.io.ByteArrayOutputStream;

import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.PrintStream;

import static org.junit.Assert.assertEquals;
import org.junit.jupiter.api.Test;

public class KieModuleModelExampleTest {

Expand Down
10 changes: 5 additions & 5 deletions drools-examples-api/multiple-kbases/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
<groupId>org.drools</groupId>
<artifactId>drools-engine-classic</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Loading

0 comments on commit 241966d

Please sign in to comment.