File tree 1 file changed +11
-2
lines changed
components/sbm-core/src/test/java/org/springframework/sbm/java/migration/conditions
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 16
16
package org .springframework .sbm .java .migration .conditions ;
17
17
18
18
import org .openrewrite .java .marker .JavaSourceSet ;
19
+ import org .openrewrite .java .tree .J ;
20
+ import org .openrewrite .java .tree .JavaType ;
19
21
import org .springframework .sbm .engine .context .ProjectContext ;
20
22
import org .springframework .sbm .project .resource .TestProjectContext ;
21
23
import org .junit .jupiter .api .Test ;
@@ -42,11 +44,18 @@ class AnnotatedClass {
42
44
.withBuildFileHavingDependencies ("javax.validation:validation-api:2.0.1.Final" )
43
45
.build ();
44
46
45
- boolean isTypeResolved = context .getProjectJavaSources ().list ().get (0 ).getResource ().getSourceFile ().getMarkers ().findFirst (JavaSourceSet .class ).get ().getClasspath ().stream ().map (fq -> fq .getFullyQualifiedName ()).anyMatch (fq -> fq .startsWith ("javax.validation" ));
47
+ J .CompilationUnit sourceFile = context .getProjectJavaSources ().list ().get (0 ).getResource ().getSourceFile ();
48
+ boolean isTypeResolved = sourceFile .getMarkers ().findFirst (JavaSourceSet .class ).get ().getClasspath ().stream ().map (fq -> fq .getFullyQualifiedName ()).anyMatch (fq -> fq .startsWith ("javax.validation" ));
46
49
assertThat (isTypeResolved ).isTrue ();
47
50
51
+
52
+ String annotation = "javax.validation.constraints.Min" ;
48
53
HasMemberAnnotation sut = new HasMemberAnnotation ();
49
- sut .setAnnotation ("javax.validation.constraints.Min" );
54
+ sut .setAnnotation (annotation );
55
+
56
+ boolean isTypeInUse = sourceFile .getTypesInUse ().getTypesInUse ().stream ()
57
+ .anyMatch (t -> ((JavaType .FullyQualified )t ).getFullyQualifiedName ().equals (annotation ));
58
+ assertThat (isTypeInUse ).isTrue ();
50
59
51
60
assertThat (sut .evaluate (context )).isTrue ();
52
61
}
You can’t perform that action at this time.
0 commit comments