Search in sources :

Example 76 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_one_type_argument.

@Test
@UseDataProvider
public void test_imports_generic_code_unit_parameter_type_with_one_type_argument(JavaCodeUnit codeUnit) {
    JavaType genericParameterType = codeUnit.getParameterTypes().get(0);
    assertThatType(genericParameterType).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)

Example 77 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_primitive_array_type_argument.

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

Example 78 with JavaType

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

the class ClassFileImporterGenericCodeUnitParameterTypesTest method test_references_outer_type_variable_assigned_to_actual_type_argument_of_generic_code_unit_parameter_type_of_inner_class.

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

Example 79 with JavaType

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

the class ClassFileImporterGenericCodeUnitParameterTypesTest method test_imports_wildcards_of_generic_code_unit_parameter_type_bound_by_type_variables_of_enclosing_classes.

@Test
@UseDataProvider
public void test_imports_wildcards_of_generic_code_unit_parameter_type_bound_by_type_variables_of_enclosing_classes(JavaCodeUnit codeUnit) {
    JavaType genericParameterType = codeUnit.getParameterTypes().get(0);
    assertThatType(genericParameterType).as("generic parameter type").hasActualTypeArguments(parameterizedType(ClassParameterWithSingleTypeParameter.class).withWildcardTypeParameterWithUpperBound(typeVariable("OUTER_ONE").withUpperBounds(String.class)), parameterizedType(ClassParameterWithSingleTypeParameter.class).withWildcardTypeParameterWithLowerBound(typeVariable("OUTER_TWO").withUpperBounds(Serializable.class)));
}
Also used : JavaType(com.tngtech.archunit.core.domain.JavaType) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 80 with JavaType

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

the class ClassFileImporterGenericCodeUnitParameterTypesTest method test_imports_non_generic_code_unit_parameter_type.

@Test
@UseDataProvider
public void test_imports_non_generic_code_unit_parameter_type(JavaCodeUnit codeUnit, Class<?> expectedParameterType) {
    JavaType parameterType = codeUnit.getParameterTypes().get(0);
    assertThatType(parameterType).as("parameter type").matches(expectedParameterType);
}
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