Search in sources :

Example 1 with SomeTestClass1

use of com.tngtech.archunit.library.metrics.testobjects.lakos.pkg1.SomeTestClass1 in project ArchUnit by TNG.

the class MetricsComponentsTest method creates_components_from_Java_packages.

@Test
public void creates_components_from_Java_packages() {
    JavaClasses classes = new ClassFileImporter().importPackagesOf(SomeTestClass1.class, SomeTestClass2.class);
    Set<JavaPackage> packages = ImmutableSet.of(classes.get(SomeTestClass1.class).getPackage(), classes.get(SomeTestClass2.class).getPackage());
    MetricsComponents<JavaClass> components = MetricsComponents.fromPackages(packages);
    assertThat(components).as("components").hasSize(2);
    MetricsComponent<JavaClass> component = components.tryGetComponent(SomeTestClass1.class.getPackage().getName()).get();
    assertThatTypes(component).as("elements of component " + component.getIdentifier()).matchInAnyOrder(SomeTestClass1.class, SomeSubTestClass.class);
    component = components.tryGetComponent(SomeTestClass2.class.getPackage().getName()).get();
    assertThatTypes(component).as("elements of component " + component.getIdentifier()).matchInAnyOrder(SomeTestClass2.class);
}
Also used : JavaClasses(com.tngtech.archunit.core.domain.JavaClasses) SomeTestClass1(com.tngtech.archunit.library.metrics.testobjects.lakos.pkg1.SomeTestClass1) JavaClass(com.tngtech.archunit.core.domain.JavaClass) JavaPackage(com.tngtech.archunit.core.domain.JavaPackage) ClassFileImporter(com.tngtech.archunit.core.importer.ClassFileImporter) Test(org.junit.Test)

Example 2 with SomeTestClass1

use of com.tngtech.archunit.library.metrics.testobjects.lakos.pkg1.SomeTestClass1 in project ArchUnit by TNG.

the class MetricsComponentsTest method creates_components_from_Java_classes.

@Test
public void creates_components_from_Java_classes() {
    JavaClasses classes = new ClassFileImporter().importPackagesOf(SomeTestClass1.class, SomeTestClass2.class);
    MetricsComponents<JavaClass> components = MetricsComponents.fromClasses(classes);
    assertThat(components).as("components").hasSize(3);
    MetricsComponent<JavaClass> component = components.tryGetComponent(SomeTestClass1.class.getName()).get();
    assertThatTypes(component).as("elements of component " + component.getIdentifier()).matchInAnyOrder(SomeTestClass1.class);
    component = components.tryGetComponent(SomeSubTestClass.class.getName()).get();
    assertThatTypes(component).as("elements of component " + component.getIdentifier()).matchInAnyOrder(SomeSubTestClass.class);
    component = components.tryGetComponent(SomeTestClass2.class.getName()).get();
    assertThatTypes(component).as("elements of component " + component.getIdentifier()).matchInAnyOrder(SomeTestClass2.class);
}
Also used : JavaClasses(com.tngtech.archunit.core.domain.JavaClasses) JavaClass(com.tngtech.archunit.core.domain.JavaClass) SomeSubTestClass(com.tngtech.archunit.library.metrics.testobjects.lakos.pkg1.sub.SomeSubTestClass) SomeTestClass2(com.tngtech.archunit.library.metrics.testobjects.lakos.pkg2.SomeTestClass2) ClassFileImporter(com.tngtech.archunit.core.importer.ClassFileImporter) Test(org.junit.Test)

Aggregations

JavaClass (com.tngtech.archunit.core.domain.JavaClass)2 JavaClasses (com.tngtech.archunit.core.domain.JavaClasses)2 ClassFileImporter (com.tngtech.archunit.core.importer.ClassFileImporter)2 Test (org.junit.Test)2 JavaPackage (com.tngtech.archunit.core.domain.JavaPackage)1 SomeTestClass1 (com.tngtech.archunit.library.metrics.testobjects.lakos.pkg1.SomeTestClass1)1 SomeSubTestClass (com.tngtech.archunit.library.metrics.testobjects.lakos.pkg1.sub.SomeSubTestClass)1 SomeTestClass2 (com.tngtech.archunit.library.metrics.testobjects.lakos.pkg2.SomeTestClass2)1