Search in sources :

Example 61 with JavaClasses

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();
}
Also used : JavaClasses(com.tngtech.archunit.core.domain.JavaClasses) Test(org.junit.Test)

Example 62 with JavaClasses

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");
    }
}
Also used : JavaClasses(com.tngtech.archunit.core.domain.JavaClasses) JavaClass(com.tngtech.archunit.core.domain.JavaClass) ArchConfigurationRule(com.tngtech.archunit.testutil.ArchConfigurationRule) Rule(org.junit.Rule) MockitoRule(org.mockito.junit.MockitoRule) Test(org.junit.Test)

Example 63 with JavaClasses

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);
}
Also used : JavaClasses(com.tngtech.archunit.core.domain.JavaClasses) ArchConfigurationRule(com.tngtech.archunit.testutil.ArchConfigurationRule) Rule(org.junit.Rule) MockitoRule(org.mockito.junit.MockitoRule) Test(org.junit.Test)

Example 64 with JavaClasses

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();
}
Also used : JavaClasses(com.tngtech.archunit.core.domain.JavaClasses) Test(org.junit.Test)

Example 65 with JavaClasses

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);
}
Also used : JavaClasses(com.tngtech.archunit.core.domain.JavaClasses) Test(org.junit.Test)

Aggregations

JavaClasses (com.tngtech.archunit.core.domain.JavaClasses)248 Test (org.junit.Test)184 ClassFileImporter (com.tngtech.archunit.core.importer.ClassFileImporter)98 JavaClass (com.tngtech.archunit.core.domain.JavaClass)72 Test (org.junit.jupiter.api.Test)54 JavaMethodCall (com.tngtech.archunit.core.domain.JavaMethodCall)19 ArchRule (com.tngtech.archunit.lang.ArchRule)19 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)19 JavaFieldAccess (com.tngtech.archunit.core.domain.JavaFieldAccess)16 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)15 JavaMethod (com.tngtech.archunit.core.domain.JavaMethod)15 MethodCallTarget (com.tngtech.archunit.core.domain.AccessTarget.MethodCallTarget)14 EvaluationResult (com.tngtech.archunit.lang.EvaluationResult)13 Workspace (com.structurizr.Workspace)12 JavaConstructorCall (com.tngtech.archunit.core.domain.JavaConstructorCall)12 Set (java.util.Set)12 Application (org.archifacts.core.model.Application)12 Component (com.structurizr.model.Component)10 Container (com.structurizr.model.Container)10 ArtifactContainer (org.archifacts.core.model.ArtifactContainer)10