Search in sources :

Example 1 with CalledClass

use of com.tngtech.archunit.core.importer.testexamples.innerclassimport.CalledClass in project ArchUnit by TNG.

the class ClassFileImporterTest method reflect_works.

@Test
public void reflect_works() {
    JavaClasses classes = new ClassFileImporter().importUrl(getClass().getResource("testexamples/innerclassimport"));
    JavaClass calledClass = classes.get(CalledClass.class);
    assertThat(calledClass.reflect()).isEqualTo(CalledClass.class);
    assertThat(calledClass.getField("someString").reflect()).isEqualTo(field(CalledClass.class, "someString"));
    assertThat(calledClass.getConstructor().reflect()).isEqualTo(constructor(CalledClass.class));
    assertThat(calledClass.getConstructor(String.class).reflect()).isEqualTo(constructor(CalledClass.class, String.class));
    assertThat(calledClass.getCodeUnitWithParameterTypes(CONSTRUCTOR_NAME, String.class).reflect()).isEqualTo(constructor(CalledClass.class, String.class));
    JavaClass innerClass = classes.get(ClassWithInnerClass.Inner.class);
    assertThat(innerClass.reflect()).isEqualTo(ClassWithInnerClass.Inner.class);
    assertThat(innerClass.getMethod("call").reflect()).isEqualTo(method(ClassWithInnerClass.Inner.class, "call"));
}
Also used : JavaClasses(com.tngtech.archunit.core.domain.JavaClasses) CalledClass(com.tngtech.archunit.core.importer.testexamples.innerclassimport.CalledClass) JavaClass(com.tngtech.archunit.core.domain.JavaClass) ClassWithInnerClass(com.tngtech.archunit.core.importer.testexamples.innerclassimport.ClassWithInnerClass) Test(org.junit.Test)

Aggregations

JavaClass (com.tngtech.archunit.core.domain.JavaClass)1 JavaClasses (com.tngtech.archunit.core.domain.JavaClasses)1 CalledClass (com.tngtech.archunit.core.importer.testexamples.innerclassimport.CalledClass)1 ClassWithInnerClass (com.tngtech.archunit.core.importer.testexamples.innerclassimport.ClassWithInnerClass)1 Test (org.junit.Test)1