File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
main/java/com/tngtech/archunit/core/domain
test/java/com/tngtech/archunit/core/domain Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -99,6 +99,7 @@ public Set<JavaMember> get() {
99
99
}
100
100
});
101
101
private JavaClassDependencies javaClassDependencies = new JavaClassDependencies (this ); // just for stubs; will be overwritten for imported classes
102
+ private boolean imported = false ;
102
103
103
104
JavaClass (JavaClassBuilder builder ) {
104
105
source = checkNotNull (builder .getSource ());
@@ -1082,6 +1083,14 @@ public Set<JavaAnnotation<?>> getAnnotationsWithTypeOfSelf() {
1082
1083
return javaClassDependencies .getAnnotationsWithTypeOfClass ();
1083
1084
}
1084
1085
1086
+ /**
1087
+ * @return Whether this class has actually been imported (or is just a stub).
1088
+ */
1089
+ @ PublicAPI (usage = ACCESS )
1090
+ public boolean isImported () {
1091
+ return imported ;
1092
+ }
1093
+
1085
1094
/**
1086
1095
* @param clazz An arbitrary type
1087
1096
* @return true, if this {@link JavaClass} represents the same class as the supplied {@link Class}, otherwise false
@@ -1221,6 +1230,7 @@ CompletionProcess completeFrom(ImportContext context) {
1221
1230
completeComponentType (context );
1222
1231
enclosingClass = context .createEnclosingClass (this );
1223
1232
javaClassDependencies = new JavaClassDependencies (this , context );
1233
+ imported = true ;
1224
1234
return new CompletionProcess ();
1225
1235
}
1226
1236
Original file line number Diff line number Diff line change @@ -625,7 +625,7 @@ private Set<JavaClass> getOriginsOfDependenciesTo(JavaClass withType) {
625
625
}
626
626
627
627
@ Test
628
- public void stubs_have_empty_dependencies () {
628
+ public void stubs_have_empty_dependencies_and_are_not_imported () {
629
629
class Element {
630
630
}
631
631
class DependsOnArray {
@@ -644,6 +644,9 @@ class DependsOnArray {
644
644
assertThat (stub .getConstructorsWithParameterTypeOfSelf ()).isEmpty ();
645
645
assertThat (stub .getConstructorsWithThrowsDeclarationTypeOfSelf ()).isEmpty ();
646
646
assertThat (stub .getAnnotationsWithTypeOfSelf ()).isEmpty ();
647
+ assertThat (directlyImportedClass .isImported ()).isTrue ();
648
+ assertThat (additionallyImportedClass .isImported ()).isTrue ();
649
+ assertThat (stub .isImported ()).isFalse ();
647
650
}
648
651
649
652
@ Test
You can’t perform that action at this time.
0 commit comments