Search in sources :

Example 1 with ClassWithSynthetics

use of com.tngtech.archunit.core.importer.testexamples.syntheticimport.ClassWithSynthetics in project ArchUnit by TNG.

the class ClassFileImporterTest method handles_synthetic_modifiers.

@Test
public void handles_synthetic_modifiers() {
    JavaClasses classes = new ClassFileImporter().importUrl(getClass().getResource("testexamples/syntheticimport"));
    JavaField syntheticField = getOnlyElement(classes.get(ClassWithSynthetics.ClassWithSyntheticField.class).getFields());
    assertThat(syntheticField.getModifiers()).as("modifiers of field in ClassWithSynthetics.ClassWithSyntheticField").contains(SYNTHETIC);
    JavaMethod syntheticMethod = getMethodWithReturnType(classes.get(ClassWithSynthetics.ClassWithSyntheticMethod.class), Object.class);
    assertThat(syntheticMethod.getModifiers()).as("modifiers of method in ClassWithSynthetics.ClassWithSyntheticMethod").contains(SYNTHETIC);
    JavaMethod compareMethod = classes.get(ClassWithSynthetics.class).getMethod("compare", Object.class, Object.class);
    assertThat(compareMethod.getModifiers()).as("modifiers of bridge method in ClassWithSynthetics").contains(BRIDGE, SYNTHETIC);
}
Also used : JavaClasses(com.tngtech.archunit.core.domain.JavaClasses) JavaField(com.tngtech.archunit.core.domain.JavaField) JavaMethod(com.tngtech.archunit.core.domain.JavaMethod) ClassWithSynthetics(com.tngtech.archunit.core.importer.testexamples.syntheticimport.ClassWithSynthetics) Test(org.junit.Test)

Aggregations

JavaClasses (com.tngtech.archunit.core.domain.JavaClasses)1 JavaField (com.tngtech.archunit.core.domain.JavaField)1 JavaMethod (com.tngtech.archunit.core.domain.JavaMethod)1 ClassWithSynthetics (com.tngtech.archunit.core.importer.testexamples.syntheticimport.ClassWithSynthetics)1 Test (org.junit.Test)1