Skip to content

Commit 222c194

Browse files
authored
change: migrate to junit5 (#576)
* change: migrate to junit6
1 parent a71da84 commit 222c194

154 files changed

Lines changed: 1266 additions & 976 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

adapters/api/pom.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,13 @@
3939
<version>${project.version}</version>
4040
</dependency>
4141
<dependency>
42-
<groupId>junit</groupId>
43-
<artifactId>junit</artifactId>
42+
<groupId>org.junit.jupiter</groupId>
43+
<artifactId>junit-jupiter-api</artifactId>
44+
<scope>test</scope>
45+
</dependency>
46+
<dependency>
47+
<groupId>org.junit.jupiter</groupId>
48+
<artifactId>junit-jupiter-engine</artifactId>
4449
<scope>test</scope>
4550
</dependency>
4651
</dependencies>

adapters/apt/pom.xml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,13 @@
4949
</dependency>
5050

5151
<dependency>
52-
<groupId>junit</groupId>
53-
<artifactId>junit</artifactId>
52+
<groupId>org.junit.jupiter</groupId>
53+
<artifactId>junit-jupiter-api</artifactId>
54+
<scope>test</scope>
55+
</dependency>
56+
<dependency>
57+
<groupId>org.junit.jupiter</groupId>
58+
<artifactId>junit-jupiter-engine</artifactId>
5459
<scope>test</scope>
5560
</dependency>
5661

@@ -59,6 +64,11 @@
5964
<artifactId>compile-testing</artifactId>
6065
<scope>test</scope>
6166
</dependency>
67+
<dependency>
68+
<groupId>io.github.kiskae</groupId>
69+
<artifactId>compile-testing-extension</artifactId>
70+
<scope>test</scope>
71+
</dependency>
6272

6373
</dependencies>
6474

adapters/apt/src/test/java/io/sundr/adapter/apt/AptAdapterFactoryTest.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
package io.sundr.adapter.apt;
1919

20-
import static org.junit.Assert.assertEquals;
21-
import static org.junit.Assert.assertTrue;
20+
import static org.junit.jupiter.api.Assertions.assertEquals;
21+
import static org.junit.jupiter.api.Assertions.assertTrue;
2222

2323
import java.util.Optional;
2424

@@ -29,29 +29,27 @@
2929
import javax.lang.model.util.Elements;
3030
import javax.lang.model.util.Types;
3131

32-
import org.junit.Before;
33-
import org.junit.Rule;
34-
import org.junit.Test;
35-
36-
import com.google.testing.compile.CompilationRule;
32+
import org.junit.jupiter.api.BeforeEach;
33+
import org.junit.jupiter.api.Test;
34+
import org.junit.jupiter.api.extension.ExtendWith;
3735

3836
import io.sundr.adapter.api.Adapter;
3937
import io.sundr.adapter.api.AdapterContext;
4038
import io.sundr.adapter.api.Adapters;
4139
import io.sundr.model.TypeDef;
4240
import io.sundr.model.repo.DefinitionRepository;
41+
import net.serverpeon.testing.compile.CompilationExtension;
4342

43+
@ExtendWith(CompilationExtension.class)
4444
public class AptAdapterFactoryTest {
4545

46-
public @Rule CompilationRule rule = new CompilationRule();
47-
4846
private Elements elements;
4947
private Types types;
5048

51-
@Before
52-
public void setup() {
53-
elements = rule.getElements();
54-
types = rule.getTypes();
49+
@BeforeEach
50+
public void setup(Elements elements, Types types) {
51+
this.elements = elements;
52+
this.types = types;
5553
}
5654

5755
private Optional<Adapter<TypeElement, TypeMirror, VariableElement, ExecutableElement>> createAdapter() {

adapters/apt/src/test/java/io/sundr/adapter/apt/AptAdapterTest.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,25 @@
2121
import javax.lang.model.util.Elements;
2222
import javax.lang.model.util.Types;
2323

24-
import org.junit.Before;
25-
import org.junit.Rule;
26-
27-
import com.google.testing.compile.CompilationRule;
24+
import org.junit.jupiter.api.BeforeEach;
25+
import org.junit.jupiter.api.extension.ExtendWith;
2826

2927
import io.sundr.adapter.api.AdapterContext;
3028
import io.sundr.adapter.testing.AbstractAdapterTest;
3129
import io.sundr.model.repo.DefinitionRepository;
30+
import net.serverpeon.testing.compile.CompilationExtension;
3231

32+
@ExtendWith(CompilationExtension.class)
3333
public class AptAdapterTest extends AbstractAdapterTest<TypeElement> {
3434

35-
public @Rule CompilationRule rule = new CompilationRule();
36-
3735
private Elements elements;
3836
private Types types;
3937
private AptContext context;
4038

41-
@Before
42-
public void setup() {
43-
elements = rule.getElements();
44-
types = rule.getTypes();
39+
@BeforeEach
40+
public void setup(Elements elements, Types types) {
41+
this.elements = elements;
42+
this.types = types;
4543
context = AptContext.create(elements, types, DefinitionRepository.getRepository());
4644
}
4745

adapters/reflect/pom.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,13 @@
4949
</dependency>
5050

5151
<dependency>
52-
<groupId>junit</groupId>
53-
<artifactId>junit</artifactId>
52+
<groupId>org.junit.jupiter</groupId>
53+
<artifactId>junit-jupiter-api</artifactId>
54+
<scope>test</scope>
55+
</dependency>
56+
<dependency>
57+
<groupId>org.junit.jupiter</groupId>
58+
<artifactId>junit-jupiter-engine</artifactId>
5459
<scope>test</scope>
5560
</dependency>
5661
</dependencies>

adapters/reflect/src/test/java/io/sundr/adapter/reflect/ReflectionAdapterFactoryTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717

1818
package io.sundr.adapter.reflect;
1919

20-
import static org.junit.Assert.assertTrue;
20+
import static org.junit.jupiter.api.Assertions.assertTrue;
2121

2222
import java.lang.reflect.Field;
2323
import java.lang.reflect.Method;
2424
import java.lang.reflect.Type;
2525
import java.util.Optional;
2626

27-
import org.junit.Test;
27+
import org.junit.jupiter.api.Test;
2828

2929
import io.sundr.adapter.api.Adapter;
3030
import io.sundr.adapter.api.AdapterContext;

adapters/source/pom.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,13 @@
4444
<artifactId>javaparser-core</artifactId>
4545
</dependency>
4646
<dependency>
47-
<groupId>junit</groupId>
48-
<artifactId>junit</artifactId>
47+
<groupId>org.junit.jupiter</groupId>
48+
<artifactId>junit-jupiter-api</artifactId>
49+
<scope>test</scope>
50+
</dependency>
51+
<dependency>
52+
<groupId>org.junit.jupiter</groupId>
53+
<artifactId>junit-jupiter-engine</artifactId>
4954
<scope>test</scope>
5055
</dependency>
5156
</dependencies>

adapters/source/src/test/java/io/sundr/adapter/source/ContextRefResolutionTest.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package io.sundr.adapter.source;
22

3-
import static org.junit.Assert.*;
3+
import static org.junit.jupiter.api.Assertions.*;
44

55
import java.util.Optional;
66

7-
import org.junit.Test;
7+
import org.junit.jupiter.api.Test;
88

99
import io.sundr.adapter.api.AdapterContext;
1010
import io.sundr.adapter.source.utils.Sources;
@@ -27,11 +27,11 @@ public void testPropertyResolution() {
2727
.filter(m -> "testMethod".equals(m.getName()))
2828
.findFirst();
2929

30-
assertTrue("testMethod should exist", testMethod.isPresent());
30+
assertTrue(testMethod.isPresent(), "testMethod should exist");
3131

3232
UnresolvedContextRefLocator locator = UnresolvedContextRefLocator.forType(typeDef);
33-
assertFalse("All ContextRef objects should be resolved, but found: " + locator.getUnresolvedContextRefs(),
34-
locator.hasUnresolvedContextRefs());
33+
assertFalse(locator.hasUnresolvedContextRefs(),
34+
"All ContextRef objects should be resolved, but found: " + locator.getUnresolvedContextRefs());
3535
}
3636

3737
@Test
@@ -42,11 +42,11 @@ public void testMethodArgumentResolution() {
4242
.filter(m -> "testMethod".equals(m.getName()))
4343
.findFirst();
4444

45-
assertTrue("testMethod should exist", testMethod.isPresent());
45+
assertTrue(testMethod.isPresent(), "testMethod should exist");
4646

4747
UnresolvedContextRefLocator locator = UnresolvedContextRefLocator.forType(typeDef);
48-
assertFalse("All ContextRef objects should be resolved, but found: " + locator.getUnresolvedContextRefs(),
49-
locator.hasUnresolvedContextRefs());
48+
assertFalse(locator.hasUnresolvedContextRefs(),
49+
"All ContextRef objects should be resolved, but found: " + locator.getUnresolvedContextRefs());
5050

5151
}
5252

@@ -58,10 +58,10 @@ public void testLocalVariableResolution() {
5858
.filter(m -> "testMethod".equals(m.getName()))
5959
.findFirst();
6060

61-
assertTrue("testMethod should exist", testMethod.isPresent());
61+
assertTrue(testMethod.isPresent(), "testMethod should exist");
6262
UnresolvedContextRefLocator locator = UnresolvedContextRefLocator.forType(typeDef);
63-
assertFalse("All ContextRef objects should be resolved, but found: " + locator.getUnresolvedContextRefs(),
64-
locator.hasUnresolvedContextRefs());
63+
assertFalse(locator.hasUnresolvedContextRefs(),
64+
"All ContextRef objects should be resolved, but found: " + locator.getUnresolvedContextRefs());
6565

6666
}
6767

@@ -73,10 +73,10 @@ public void testStaticMethodResolution() {
7373
.filter(m -> "testMethod".equals(m.getName()))
7474
.findFirst();
7575

76-
assertTrue("testMethod should exist", testMethod.isPresent());
76+
assertTrue(testMethod.isPresent(), "testMethod should exist");
7777
UnresolvedContextRefLocator locator = UnresolvedContextRefLocator.forType(typeDef);
78-
assertFalse("All ContextRef objects should be resolved, but found: " + locator.getUnresolvedContextRefs(),
79-
locator.hasUnresolvedContextRefs());
78+
assertFalse(locator.hasUnresolvedContextRefs(),
79+
"All ContextRef objects should be resolved, but found: " + locator.getUnresolvedContextRefs());
8080
}
8181

8282
@Test
@@ -87,11 +87,11 @@ public void testStaticMethodFromSamePackage() {
8787
.filter(m -> "testMethod".equals(m.getName()))
8888
.findFirst();
8989

90-
assertTrue("testMethod should exist", testMethod.isPresent());
90+
assertTrue(testMethod.isPresent(), "testMethod should exist");
9191

9292
UnresolvedContextRefLocator locator = UnresolvedContextRefLocator.forType(typeDef);
93-
assertFalse("All ContextRef objects should be resolved, but found: " + locator.getUnresolvedContextRefs(),
94-
locator.hasUnresolvedContextRefs());
93+
assertFalse(locator.hasUnresolvedContextRefs(),
94+
"All ContextRef objects should be resolved, but found: " + locator.getUnresolvedContextRefs());
9595
}
9696

9797
@Test
@@ -102,10 +102,10 @@ public void testContextRefToPropertyRefResolution() {
102102
.filter(m -> "testMethod".equals(m.getName()))
103103
.findFirst();
104104

105-
assertTrue("testMethod should exist", testMethod.isPresent());
105+
assertTrue(testMethod.isPresent(), "testMethod should exist");
106106
UnresolvedContextRefLocator locator = UnresolvedContextRefLocator.forType(typeDef);
107-
assertFalse("All ContextRef objects should be resolved, but found: " + locator.getUnresolvedContextRefs(),
108-
locator.hasUnresolvedContextRefs());
107+
assertFalse(locator.hasUnresolvedContextRefs(),
108+
"All ContextRef objects should be resolved, but found: " + locator.getUnresolvedContextRefs());
109109
}
110110

111111
private TypeDef parseTypeDefFromResource(String resourceName) {

adapters/source/src/test/java/io/sundr/adapter/source/EnumSourceAdapterTest.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717

1818
package io.sundr.adapter.source;
1919

20-
import static org.junit.Assert.assertEquals;
21-
import static org.junit.Assert.assertNotNull;
22-
import static org.junit.Assert.assertTrue;
20+
import static org.junit.jupiter.api.Assertions.assertEquals;
21+
import static org.junit.jupiter.api.Assertions.assertNotNull;
22+
import static org.junit.jupiter.api.Assertions.assertTrue;
2323

2424
import java.nio.file.Path;
2525
import java.util.Optional;
2626

27-
import org.junit.Test;
27+
import org.junit.jupiter.api.Test;
2828

2929
import io.sundr.model.Kind;
3030
import io.sundr.model.TypeDef;
@@ -39,7 +39,7 @@ public void shouldAdaptSingularizeEnum() throws Exception {
3939
// Find the Singularize enum in the core module
4040
Optional<Path> singularizePath = coreProject.allSources().find("io.sundr.functions.Singularize");
4141

42-
assertTrue("Should find Singularize.java", singularizePath.isPresent());
42+
assertTrue(singularizePath.isPresent(), "Should find Singularize.java");
4343

4444
// Parse the TypeDef from the file - should now work with enum support
4545
TypeDef typeDef = coreProject.parse(singularizePath.get());
@@ -49,13 +49,13 @@ public void shouldAdaptSingularizeEnum() throws Exception {
4949
assertEquals("io.sundr.functions", typeDef.getPackageName());
5050

5151
// Verify the enum has the expected structure
52-
assertTrue("Should have FUNCTION constant",
53-
typeDef.getFields().stream()
54-
.anyMatch(f -> "FUNCTION".equals(f.getName())));
52+
assertTrue(typeDef.getFields().stream()
53+
.anyMatch(f -> "FUNCTION".equals(f.getName())),
54+
"Should have FUNCTION constant");
5555

56-
assertTrue("Should have apply method",
57-
typeDef.getMethods().stream()
58-
.anyMatch(m -> "apply".equals(m.getName())));
56+
assertTrue(typeDef.getMethods().stream()
57+
.anyMatch(m -> "apply".equals(m.getName())),
58+
"Should have apply method");
5959
}
6060

6161
@Test
@@ -66,7 +66,7 @@ public void shouldAdaptPluralizeEnum() throws Exception {
6666
// Find the Pluralize enum in the core module
6767
Optional<Path> pluralizePath = coreProject.allSources().find("io.sundr.functions.Pluralize");
6868

69-
assertTrue("Should find Pluralize.java", pluralizePath.isPresent());
69+
assertTrue(pluralizePath.isPresent(), "Should find Pluralize.java");
7070

7171
// Parse the TypeDef from the file - should now work with enum support
7272
TypeDef typeDef = coreProject.parse(pluralizePath.get());
@@ -76,16 +76,16 @@ public void shouldAdaptPluralizeEnum() throws Exception {
7676
assertEquals("io.sundr.functions", typeDef.getPackageName());
7777

7878
// Verify the enum has the expected structure
79-
assertTrue("Should have FUNCTION constant",
80-
typeDef.getFields().stream()
81-
.anyMatch(f -> "FUNCTION".equals(f.getName())));
79+
assertTrue(typeDef.getFields().stream()
80+
.anyMatch(f -> "FUNCTION".equals(f.getName())),
81+
"Should have FUNCTION constant");
8282

83-
assertTrue("Should have apply method",
84-
typeDef.getMethods().stream()
85-
.anyMatch(m -> "apply".equals(m.getName())));
83+
assertTrue(typeDef.getMethods().stream()
84+
.anyMatch(m -> "apply".equals(m.getName())),
85+
"Should have apply method");
8686

87-
assertTrue("Should have isAlreadyPlural method",
88-
typeDef.getMethods().stream()
89-
.anyMatch(m -> "isAlreadyPlural".equals(m.getName())));
87+
assertTrue(typeDef.getMethods().stream()
88+
.anyMatch(m -> "isAlreadyPlural".equals(m.getName())),
89+
"Should have isAlreadyPlural method");
9090
}
9191
}

adapters/source/src/test/java/io/sundr/adapter/source/NodeToPackageTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
package io.sundr.adapter.source;
1919

20-
import static org.junit.Assert.assertEquals;
20+
import static org.junit.jupiter.api.Assertions.assertEquals;
2121

22-
import org.junit.Test;
22+
import org.junit.jupiter.api.Test;
2323

2424
import com.github.javaparser.ast.body.FieldDeclaration;
2525
import com.github.javaparser.ast.body.TypeDeclaration;

0 commit comments

Comments
 (0)