use of com.tngtech.archunit.core.domain.JavaClasses in project ArchUnit by TNG.
the class ClassCacheTest method loads_classes.
@Test
public void loads_classes() {
JavaClasses classes = cache.getClassesToAnalyzeFor(TestClass.class, analyzePackages("com.tngtech.archunit.junit"));
assertThat(classes).as("Classes were found").isNotEmpty();
}
use of com.tngtech.archunit.core.domain.JavaClasses in project ArchUnit by TNG.
the class ClassCacheTest method filters_jars_relative_to_class.
@Test
public void filters_jars_relative_to_class() {
JavaClasses classes = cache.getClassesToAnalyzeFor(TestClass.class, analyzePackagesOf(Rule.class));
assertThat(classes).isNotEmpty();
for (JavaClass clazz : classes) {
assertThat(clazz.getPackageName()).doesNotContain("tngtech");
}
}
use of com.tngtech.archunit.core.domain.JavaClasses in project ArchUnit by TNG.
the class ClassCacheTest method non_existing_packages_are_ignored.
@Test
public void non_existing_packages_are_ignored() {
JavaClasses first = cache.getClassesToAnalyzeFor(TestClass.class, new TestAnalysisRequest().withPackages("something.that.doesnt.exist").withPackagesRoots(Rule.class));
JavaClasses second = cache.getClassesToAnalyzeFor(TestClass.class, analyzePackagesOf(Rule.class));
assertThat(first).isEqualTo(second);
verifyNumberOfImports(1);
}
use of com.tngtech.archunit.core.domain.JavaClasses in project ArchUnit by TNG.
the class ClassCacheTest method gets_all_classes_relative_to_class.
@Test
public void gets_all_classes_relative_to_class() {
JavaClasses classes = cache.getClassesToAnalyzeFor(TestClass.class, analyzePackagesOf(getClass()));
assertThat(classes).isNotEmpty();
assertThat(classes.contain(getClass())).as("root class is contained itself").isTrue();
}
use of com.tngtech.archunit.core.domain.JavaClasses in project ArchUnit by TNG.
the class ClassCacheTest method if_no_import_locations_are_specified_and_whole_classpath_is_set_false_then_the_default_is_the_package_of_the_test_class.
@Test
public void if_no_import_locations_are_specified_and_whole_classpath_is_set_false_then_the_default_is_the_package_of_the_test_class() {
TestAnalysisRequest defaultOptions = new TestAnalysisRequest().withWholeClasspath(false);
JavaClasses classes = cache.getClassesToAnalyzeFor(TestClass.class, defaultOptions);
assertThatTypes(classes).contain(getClass(), TestAnalysisRequest.class);
assertThatTypes(classes).doNotContain(ClassFileImporter.class);
}
Aggregations