Skip to content

Commit 2761546

Browse files
committed
fix issues
1 parent 5455ea7 commit 2761546

2 files changed

Lines changed: 20 additions & 27 deletions

File tree

src/main/java/it/aboutbits/archunit/toolbox/ArchitectureTestBase.java

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,13 @@
44
import com.tngtech.archunit.core.domain.JavaClass;
55
import com.tngtech.archunit.core.domain.JavaClasses;
66
import com.tngtech.archunit.core.domain.JavaMethod;
7-
import com.tngtech.archunit.junit.ArchIgnore;
87
import com.tngtech.archunit.junit.ArchTest;
98
import com.tngtech.archunit.lang.ArchCondition;
109
import com.tngtech.archunit.lang.ArchRule;
1110
import com.tngtech.archunit.lang.ConditionEvents;
1211
import com.tngtech.archunit.lang.SimpleConditionEvent;
13-
import it.aboutbits.archunit.toolbox.support.ArchIgnoreGroupName;
14-
import it.aboutbits.archunit.toolbox.support.ArchIgnoreNoProductionCounterpart;
1512
import lombok.extern.slf4j.Slf4j;
1613
import org.jspecify.annotations.NullMarked;
17-
import org.jspecify.annotations.NullUnmarked;
18-
import org.junit.jupiter.api.Disabled;
19-
import org.junit.jupiter.api.Nested;
20-
import org.junit.jupiter.api.RepeatedTest;
21-
import org.junit.jupiter.api.Test;
22-
import org.junit.jupiter.params.ParameterizedTest;
2314

2415
import java.util.HashSet;
2516
import java.util.Set;
@@ -80,7 +71,7 @@ public abstract class ArchitectureTestBase {
8071
"org.junit.Ignore",
8172
"org.junit.Rule",
8273
"org.junit.Test",
83-
// (allowed is only org.jspecify.annotations.NonNull)
74+
// @NonNull (allowed is only org.jspecify.annotations.NonNull)
8475
"lombok.NonNull",
8576
"edu.umd.cs.findbugs.annotations.NonNull",
8677
"io.micrometer.common.lang.NonNull",
@@ -138,7 +129,7 @@ public abstract class ArchitectureTestBase {
138129
@ArchTest
139130
static final ArchRule nested_test_classes_must_be_package_private = classes()
140131
.that()
141-
.areAnnotatedWith(Nested.class)
132+
.areAnnotatedWith(org.junit.jupiter.api.Nested.class)
142133
.should()
143134
.bePackagePrivate()
144135
.allowEmptyShould(true);
@@ -147,13 +138,13 @@ public abstract class ArchitectureTestBase {
147138
@ArchTest
148139
static final ArchRule test_methods_must_be_package_private = methods()
149140
.that()
150-
.areAnnotatedWith(Test.class)
141+
.areAnnotatedWith(org.junit.jupiter.api.Test.class)
151142
.or()
152-
.areAnnotatedWith(RepeatedTest.class)
143+
.areAnnotatedWith(org.junit.jupiter.api.RepeatedTest.class)
153144
.or()
154-
.areAnnotatedWith(ParameterizedTest.class)
145+
.areAnnotatedWith(org.junit.jupiter.params.ParameterizedTest.class)
155146
.or()
156-
.areAnnotatedWith(ArchTest.class)
147+
.areAnnotatedWith(com.tngtech.archunit.junit.ArchTest.class)
157148
.should()
158149
.bePackagePrivate();
159150

@@ -164,11 +155,11 @@ void test_classes_should_be_in_the_same_package_as_their_production_code(JavaCla
164155
.and()
165156
.doNotHaveSimpleName("ArchitectureTest")
166157
.and()
167-
.areNotAnnotatedWith(Disabled.class)
158+
.areNotAnnotatedWith(org.junit.jupiter.api.Disabled.class)
168159
.and()
169-
.areNotAnnotatedWith(ArchIgnore.class)
160+
.areNotAnnotatedWith(com.tngtech.archunit.junit.ArchIgnore.class)
170161
.and()
171-
.areNotAnnotatedWith(ArchIgnoreNoProductionCounterpart.class)
162+
.areNotAnnotatedWith(it.aboutbits.archunit.toolbox.support.ArchIgnoreNoProductionCounterpart.class)
172163
.and()
173164
.resideOutsideOfPackages(".._support..", ".._config..")
174165
.should(beInTheSamePackageAsProductionClass(classes))
@@ -181,9 +172,9 @@ void nested_test_classes_have_matching_production_method_name(JavaClasses classe
181172
classes().that()
182173
.haveNameMatching(getTestClassRegex())
183174
.and()
184-
.areNotAnnotatedWith(Disabled.class)
175+
.areNotAnnotatedWith(org.junit.jupiter.api.Disabled.class)
185176
.and()
186-
.areNotAnnotatedWith(ArchIgnore.class)
177+
.areNotAnnotatedWith(com.tngtech.archunit.junit.ArchIgnore.class)
187178
.should(nestedClassesMatchProdMethodName(classes))
188179
.allowEmptyShould(true)
189180
.check(classes);
@@ -334,9 +325,9 @@ public boolean test(JavaClass javaClass) {
334325
.and()
335326
.areNotAnnotations()
336327
.should()
337-
.beAnnotatedWith(NullMarked.class)
328+
.beAnnotatedWith(org.jspecify.annotations.NullMarked.class)
338329
.orShould()
339-
.beAnnotatedWith(NullUnmarked.class);
330+
.beAnnotatedWith(org.jspecify.annotations.NullUnmarked.class);
340331

341332
/* ****************************************************************** */
342333

@@ -380,8 +371,8 @@ public void check(JavaClass testClass, ConditionEvents events) {
380371
.getClasses()
381372
.stream()
382373
.filter(clazz -> clazz.getName().startsWith(testClass.getName() + "$")
383-
&& clazz.isAnnotatedWith(Nested.class)
384-
&& !clazz.isAnnotatedWith(ArchIgnoreGroupName.class)
374+
&& clazz.isAnnotatedWith(org.junit.jupiter.api.Nested.class)
375+
&& !clazz.isAnnotatedWith(it.aboutbits.archunit.toolbox.support.ArchIgnoreGroupName.class)
385376
&& !clazz.getName().endsWith("$Validation")
386377
)
387378
.collect(Collectors.toSet());
@@ -410,8 +401,8 @@ public void check(JavaClass testClass, ConditionEvents events) {
410401
.getClasses()
411402
.stream()
412403
.anyMatch(clazz -> clazz.getName().startsWith(nestedClass.getName() + "$")
413-
&& clazz.isAnnotatedWith(Nested.class)
414-
&& !clazz.isAnnotatedWith(ArchIgnoreGroupName.class)
404+
&& clazz.isAnnotatedWith(org.junit.jupiter.api.Nested.class)
405+
&& !clazz.isAnnotatedWith(it.aboutbits.archunit.toolbox.support.ArchIgnoreGroupName.class)
415406
&& !clazz.getName().endsWith("$Validation")
416407
)
417408
) {

src/test/java/it/aboutbits/archunit/toolbox/ArchitectureTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package it.aboutbits.archunit.toolbox;
22

33
import com.tngtech.archunit.junit.AnalyzeClasses;
4+
import com.tngtech.archunit.junit.CacheMode;
45
import org.jspecify.annotations.NullMarked;
56

67
@AnalyzeClasses(
7-
packages = ArchitectureTest.PACKAGE
8+
packages = ArchitectureTest.PACKAGE,
9+
cacheMode = CacheMode.PER_CLASS
810
)
911
@NullMarked
1012
class ArchitectureTest extends ArchitectureTestBase {

0 commit comments

Comments
 (0)