File tree 1 file changed +9
-3
lines changed
components/sbm-core/src/test/java/org/springframework/sbm/java/impl
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 20
20
import org .springframework .sbm .java .api .JavaSource ;
21
21
import org .springframework .sbm .java .api .Member ;
22
22
import org .springframework .sbm .engine .context .ProjectContext ;
23
+ import org .springframework .sbm .java .api .Type ;
23
24
import org .springframework .sbm .project .resource .TestProjectContext ;
24
25
import org .assertj .core .api .Assertions ;
25
26
import org .junit .jupiter .api .Test ;
@@ -113,13 +114,18 @@ public class Class1 {
113
114
assertThat (classpath ).contains (minAnnotation );
114
115
115
116
// add annotation
116
- javaSource .getTypes ().get (0 ).getMembers ().get (0 ).addAnnotation (minAnnotation );
117
+ Type type = javaSource .getTypes ().get (0 );
118
+ type .getMembers ().get (0 ).addAnnotation (minAnnotation );
119
+
120
+ boolean isTypeInUse = ((OpenRewriteJavaSource )javaSource ).getSourceFile ().getTypesInUse ().getTypesInUse ().stream ()
121
+ .anyMatch (t -> ((JavaType .FullyQualified )t ).getFullyQualifiedName ().equals (minAnnotation ));
122
+ assertThat (isTypeInUse ).isTrue ();
117
123
118
124
// correct import added
119
125
assertThat (javaSource .getImports ()).hasSize (1 );
120
126
assertThat (javaSource .hasImportStartingWith (minAnnotation )).isTrue ();
121
- assertThat (javaSource . getTypes (). get ( 0 ) .getMembers ().get (0 ).getAnnotation (minAnnotation )).isNotNull ();
122
- assertThat (javaSource . getTypes (). get ( 0 ) .getMembers ().get (1 ).getAnnotation (minAnnotation )).isNull ();
127
+ assertThat (type .getMembers ().get (0 ).getAnnotation (minAnnotation )).isNotNull ();
128
+ assertThat (type .getMembers ().get (1 ).getAnnotation (minAnnotation )).isNull ();
123
129
}
124
130
125
131
@ Test
You can’t perform that action at this time.
0 commit comments