use of com.tngtech.archunit.core.domain.JavaType in project ArchUnit by TNG.
the class ClassFileImporterGenericSuperclassTest method imports_generic_superclass_with_actual_type_arguments_parameterized_with_bounded_wildcards.
@Test
public void imports_generic_superclass_with_actual_type_arguments_parameterized_with_bounded_wildcards() {
@SuppressWarnings("unused")
class BaseClass<A, B> {
}
class Child extends BaseClass<ClassParameterWithSingleTypeParameter<? extends String>, ClassParameterWithSingleTypeParameter<? super File>> {
}
JavaType genericSuperclass = importClassWithOnlyGenericTypeResolution(Child.class).getSuperclass().get();
assertThatType(genericSuperclass).as("generic superclass").hasActualTypeArguments(parameterizedType(ClassParameterWithSingleTypeParameter.class).withWildcardTypeParameterWithUpperBound(String.class), parameterizedType(ClassParameterWithSingleTypeParameter.class).withWildcardTypeParameterWithLowerBound(File.class));
}
use of com.tngtech.archunit.core.domain.JavaType in project ArchUnit by TNG.
the class ClassFileImporterGenericSuperclassTest method imports_generic_superclass_with_primitive_array_type_argument.
@Test
public void imports_generic_superclass_with_primitive_array_type_argument() {
@SuppressWarnings("unused")
class BaseClass<T> {
}
class Child extends BaseClass<int[]> {
}
JavaType genericSuperClass = importClassWithOnlyGenericTypeResolution(Child.class).getSuperclass().get();
assertThatType(genericSuperClass).as("generic superclass").hasErasure(BaseClass.class).hasActualTypeArguments(int[].class);
}
use of com.tngtech.archunit.core.domain.JavaType in project ArchUnit by TNG.
the class ClassFileImporterGenericCodeUnitParameterTypesTest method test_imports_complex_generic_array_code_unit_parameter_type.
@Test
@UseDataProvider
public void test_imports_complex_generic_array_code_unit_parameter_type(JavaCodeUnit codeUnit) {
JavaType genericParameterType = codeUnit.getParameterTypes().get(0);
assertThatType(genericParameterType).matches(genericArray(List.class.getName() + "<" + Map.class.getName() + "<? super " + String.class.getName() + ", " + Map.class.getName() + "<" + Map.class.getName() + "<? super " + String.class.getName() + ", ?>, " + Serializable.class.getName() + ">>>[]").withComponentType(parameterizedType(List.class).withTypeArguments(parameterizedType(Map.class).withTypeArguments(wildcardType().withLowerBound(String.class), parameterizedType(Map.class).withTypeArguments(parameterizedType(Map.class).withTypeArguments(wildcardType().withLowerBound(String.class), wildcardType()), concreteClass(Serializable.class))))));
}
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_multiple_type_arguments.
@Test
@UseDataProvider
public void test_imports_generic_code_unit_parameter_type_with_multiple_type_arguments(JavaCodeUnit codeUnit) {
JavaType genericParameterType = codeUnit.getParameterTypes().get(0);
assertThatType(genericParameterType).as("generic parameter type").hasErasure(ClassParameterWithThreeTypeParameters.class).hasActualTypeArguments(String.class, Serializable.class, File.class);
}
use of com.tngtech.archunit.core.domain.JavaType in project ArchUnit by TNG.
the class ClassFileImporterGenericCodeUnitParameterTypesTest method test_references_type_variable_assigned_to_actual_type_argument_of_generic_code_unit_parameter_type.
@Test
@UseDataProvider
public void test_references_type_variable_assigned_to_actual_type_argument_of_generic_code_unit_parameter_type(JavaCodeUnit codeUnit) {
JavaType genericParameterType = codeUnit.getParameterTypes().get(0);
assertThatType(genericParameterType).as("generic parameter type").hasActualTypeArguments(parameterizedType(ClassParameterWithSingleTypeParameter.class).withTypeArguments(typeVariable("OF_CLASS").withUpperBounds(String.class)));
}
Aggregations