Java Code Examples for com.tngtech.archunit.core.domain.JavaClass#getConstructorCallsFromSelf()

The following examples show how to use com.tngtech.archunit.core.domain.JavaClass#getConstructorCallsFromSelf() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClassFileImporterTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@Test
public void imports_constructor_calls_on_self() throws Exception {
    JavaClass classThatCallsOwnConstructor = classesIn("testexamples/callimport").get(CallsOwnConstructor.class);
    JavaCodeUnit caller = classThatCallsOwnConstructor.getCodeUnitWithParameterTypes("copy");

    Set<JavaConstructorCall> calls = classThatCallsOwnConstructor.getConstructorCallsFromSelf();

    assertThatCall(getOnlyByCaller(calls, caller))
            .isFrom(caller)
            .isTo(classThatCallsOwnConstructor.getConstructor(String.class))
            .inLineNumber(8);
}
 
Example 2
Source File: ClassFileImporterTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@Test
public void imports_constructor_calls_on_other() throws Exception {
    ImportedClasses classes = classesIn("testexamples/callimport");
    JavaClass classThatCallsOtherConstructor = classes.get(CallsOtherConstructor.class);
    JavaClass otherClass = classes.get(CallsOwnConstructor.class);
    JavaCodeUnit caller = classThatCallsOtherConstructor.getCodeUnitWithParameterTypes("createOther");

    Set<JavaConstructorCall> calls = classThatCallsOtherConstructor.getConstructorCallsFromSelf();

    assertThatCall(getOnlyByCaller(calls, caller))
            .isFrom(caller)
            .isTo(otherClass.getConstructor(String.class))
            .inLineNumber(5);
}