@@ -57,23 +57,23 @@ public ClassDeclaration visitClassDeclaration(ClassDeclaration classDecl, Execut
5757 ClassDeclaration c = super .visitClassDeclaration (classDecl , executionContext );
5858
5959 if (c .getModifiers ().stream ().anyMatch (mod -> mod .getType () == J .Modifier .Type .Public )
60- && c .getModifiers ().stream ().noneMatch (mod -> mod .getType () == Type .Abstract )) {
60+ && c .getModifiers ().stream ().noneMatch (mod -> mod .getType () == Type .Abstract )) {
6161
6262 boolean hasTestMethods = c .getBody ().getStatements ().stream ()
63- .filter (statement -> statement instanceof J .MethodDeclaration )
64- .map (J .MethodDeclaration .class ::cast )
65- .anyMatch (this ::hasJUnit5MethodAnnotation );
63+ .filter (statement -> statement instanceof J .MethodDeclaration )
64+ .map (J .MethodDeclaration .class ::cast )
65+ .anyMatch (this ::hasJUnit5MethodAnnotation );
6666
6767 boolean hasPublicNonTestMethods = c .getBody ().getStatements ().stream ()
68- .filter (statement -> statement instanceof J .MethodDeclaration )
69- .map (J .MethodDeclaration .class ::cast )
70- .filter (m -> m .getModifiers ().stream ().anyMatch (mod -> mod .getType () == J .Modifier .Type .Public ))
71- .anyMatch (method -> !hasJUnit5MethodAnnotation (method ));
68+ .filter (statement -> statement instanceof J .MethodDeclaration )
69+ .map (J .MethodDeclaration .class ::cast )
70+ .filter (m -> m .getModifiers ().stream ().anyMatch (mod -> mod .getType () == J .Modifier .Type .Public ))
71+ .anyMatch (method -> !hasJUnit5MethodAnnotation (method ));
7272
7373 boolean hasPublicVariableDeclarations = c .getBody ().getStatements ().stream ()
74- .filter (statement -> statement instanceof J .VariableDeclarations )
75- .map (J .VariableDeclarations .class ::cast )
76- .anyMatch (m -> m .getModifiers ().stream ().anyMatch (mod -> mod .getType () == J .Modifier .Type .Public ));
74+ .filter (statement -> statement instanceof J .VariableDeclarations )
75+ .map (J .VariableDeclarations .class ::cast )
76+ .anyMatch (m -> m .getModifiers ().stream ().anyMatch (mod -> mod .getType () == J .Modifier .Type .Public ));
7777
7878 if (hasTestMethods && !hasPublicNonTestMethods && !hasPublicVariableDeclarations ) {
7979 // Remove public modifier and move associated comment
@@ -107,7 +107,7 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, Ex
107107 J .MethodDeclaration m = super .visitMethodDeclaration (method , executionContext );
108108
109109 if (m .getModifiers ().stream ().anyMatch (mod -> mod .getType () == J .Modifier .Type .Public )
110- && hasJUnit5MethodAnnotation (m )) {
110+ && hasJUnit5MethodAnnotation (m )) {
111111 // remove public modifier
112112 doAfterVisit (new ChangeMethodAccessLevelVisitor <>(new MethodMatcher (method ), null ));
113113 }
@@ -118,11 +118,11 @@ && hasJUnit5MethodAnnotation(m)) {
118118 private boolean hasJUnit5MethodAnnotation (MethodDeclaration method ) {
119119 for (J .Annotation a : method .getLeadingAnnotations ()) {
120120 if (TypeUtils .isOfClassType (a .getType (), "org.junit.jupiter.api.Test" )
121- || TypeUtils .isOfClassType (a .getType (), "org.junit.jupiter.api.RepeatedTest" )
122- || TypeUtils .isOfClassType (a .getType (), "org.junit.jupiter.params.ParameterizedTest" )
123- || TypeUtils .isOfClassType (a .getType (), "org.junit.jupiter.api.TestFactory" )
124- || TypeUtils .isOfClassType (a .getType (), "org.junit.jupiter.api.AfterEach" )
125- || TypeUtils .isOfClassType (a .getType (), "org.junit.jupiter.api.BeforeEach" )) {
121+ || TypeUtils .isOfClassType (a .getType (), "org.junit.jupiter.api.RepeatedTest" )
122+ || TypeUtils .isOfClassType (a .getType (), "org.junit.jupiter.params.ParameterizedTest" )
123+ || TypeUtils .isOfClassType (a .getType (), "org.junit.jupiter.api.TestFactory" )
124+ || TypeUtils .isOfClassType (a .getType (), "org.junit.jupiter.api.AfterEach" )
125+ || TypeUtils .isOfClassType (a .getType (), "org.junit.jupiter.api.BeforeEach" )) {
126126 return true ;
127127 }
128128 }
0 commit comments