Skip to content

Commit bd5fafa

Browse files
committed
Cleanup
1 parent b59b6ea commit bd5fafa

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

components/sbm-core/src/test/java/org/springframework/sbm/java/impl/OpenRewriteMemberTest.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.springframework.sbm.java.api.JavaSource;
2121
import org.springframework.sbm.java.api.Member;
2222
import org.springframework.sbm.engine.context.ProjectContext;
23+
import org.springframework.sbm.java.api.Type;
2324
import org.springframework.sbm.project.resource.TestProjectContext;
2425
import org.assertj.core.api.Assertions;
2526
import org.junit.jupiter.api.Test;
@@ -113,13 +114,18 @@ public class Class1 {
113114
assertThat(classpath).contains(minAnnotation);
114115

115116
// 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();
117123

118124
// correct import added
119125
assertThat(javaSource.getImports()).hasSize(1);
120126
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();
123129
}
124130

125131
@Test

0 commit comments

Comments
 (0)