Search in sources :

Example 71 with JavaType

use of com.tngtech.archunit.core.domain.JavaType in project ArchUnit by TNG.

the class ClassFileImporterGenericSuperclassTest method imports_non_generic_superclass.

@Test
public void imports_non_generic_superclass() {
    class BaseClass {
    }
    class Child extends BaseClass {
    }
    JavaType genericSuperclass = importClassWithOnlyGenericTypeResolution(Child.class).getSuperclass().get();
    assertThatType(genericSuperclass).as("generic superclass").matches(BaseClass.class);
}
Also used : JavaType(com.tngtech.archunit.core.domain.JavaType) Test(org.junit.Test)

Example 72 with JavaType

use of com.tngtech.archunit.core.domain.JavaType in project ArchUnit by TNG.

the class ClassFileImporterGenericSuperclassTest method imports_generic_superclass_parameterized_with_type_variable.

@Test
public void imports_generic_superclass_parameterized_with_type_variable() {
    @SuppressWarnings("unused")
    class BaseClass<SUPER> {
    }
    class Child<SUB> extends BaseClass<SUB> {
    }
    JavaType genericSuperclass = importClassWithOnlyGenericTypeResolution(Child.class).getSuperclass().get();
    assertThatType(genericSuperclass).as("generic superclass").hasActualTypeArguments(typeVariable("SUB"));
}
Also used : JavaType(com.tngtech.archunit.core.domain.JavaType) Test(org.junit.Test)

Example 73 with JavaType

use of com.tngtech.archunit.core.domain.JavaType in project ArchUnit by TNG.

the class ClassFileImporterGenericSuperclassTest method imports_generic_superclass_with_single_actual_type_argument_parameterized_with_unbound_wildcard.

@Test
public void imports_generic_superclass_with_single_actual_type_argument_parameterized_with_unbound_wildcard() {
    @SuppressWarnings("unused")
    class BaseClass<T> {
    }
    class Child extends BaseClass<ClassParameterWithSingleTypeParameter<?>> {
    }
    JavaType genericSuperclass = importClassWithOnlyGenericTypeResolution(Child.class).getSuperclass().get();
    assertThatType(genericSuperclass).as("generic superclass").hasActualTypeArguments(parameterizedType(ClassParameterWithSingleTypeParameter.class).withWildcardTypeParameter());
}
Also used : JavaType(com.tngtech.archunit.core.domain.JavaType) Test(org.junit.Test)

Example 74 with JavaType

use of com.tngtech.archunit.core.domain.JavaType in project ArchUnit by TNG.

the class ClassFileImporterGenericCodeUnitParameterTypesTest method test_imports_generic_code_unit_parameter_type_with_single_unbound_wildcard.

@Test
@UseDataProvider
public void test_imports_generic_code_unit_parameter_type_with_single_unbound_wildcard(JavaCodeUnit codeUnit) {
    JavaType genericParameterType = codeUnit.getParameterTypes().get(0);
    assertThatType(genericParameterType).as("generic parameter type").hasActualTypeArguments(wildcardType());
}
Also used : JavaType(com.tngtech.archunit.core.domain.JavaType) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 75 with JavaType

use of com.tngtech.archunit.core.domain.JavaType in project ArchUnit by TNG.

the class ClassFileImporterGenericCodeUnitParameterTypesTest method test_imports_generic_code_unit_parameter_type_with_array_type_argument.

@Test
@UseDataProvider
public void test_imports_generic_code_unit_parameter_type_with_array_type_argument(JavaCodeUnit codeUnit) {
    JavaType genericMethodParameterType = codeUnit.getParameterTypes().get(0);
    assertThatType(genericMethodParameterType).as("generic parameter type").hasErasure(ClassParameterWithSingleTypeParameter.class).hasActualTypeArguments(String[].class);
}
Also used : JavaType(com.tngtech.archunit.core.domain.JavaType) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Aggregations

JavaType (com.tngtech.archunit.core.domain.JavaType)133 Test (org.junit.Test)132 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)31 Serializable (java.io.Serializable)29 Map (java.util.Map)23 File (java.io.File)17 List (java.util.List)13 Reference (java.lang.ref.Reference)5 JavaClass (com.tngtech.archunit.core.domain.JavaClass)3 JavaTypeVariable (com.tngtech.archunit.core.domain.JavaTypeVariable)3 JavaParameterizedType (com.tngtech.archunit.core.domain.JavaParameterizedType)1 SomeDeeplyNestedInterface (com.tngtech.archunit.core.importer.ClassFileImporterGenericInterfacesTest.Outer.SomeNestedInterface.SomeDeeplyNestedInterface)1 Path (java.nio.file.Path)1 Set (java.util.Set)1