use of com.tngtech.archunit.core.domain.JavaType in project ArchUnit by TNG.
the class ClassFileImporterGenericInterfacesTest method test_imports_complex_type_with_multiple_nested_actual_type_arguments_of_generic_interface_with_self_referencing_type_definitions.
@Test
@UseDataProvider
public void test_imports_complex_type_with_multiple_nested_actual_type_arguments_of_generic_interface_with_self_referencing_type_definitions(Class<?> testInput) {
JavaType genericInterface = getOnlyElement(importClassWithOnlyGenericTypeResolution(testInput).getInterfaces());
// @formatter:off
assertThatType(genericInterface).as("generic interface").hasActualTypeArguments(// assigned to InterfaceWithThreeTypeParameters<A,_,_>
parameterizedType(List.class).withWildcardTypeParameterWithUpperBound(typeVariable("FIRST").withUpperBounds(String.class, Serializable.class)), // assigned to InterfaceWithThreeTypeParameters<_,B,_>
parameterizedType(Map.class).withTypeArguments(parameterizedType(Map.Entry.class).withTypeArguments(typeVariable("FIRST").withUpperBounds(String.class, Serializable.class), parameterizedType(Map.Entry.class).withTypeArguments(concreteClass(String.class), typeVariable("SECOND").withUpperBounds(Serializable.class, Cloneable.class))), parameterizedType(Map.class).withTypeArguments(wildcardType().withUpperBound(String.class), parameterizedType(Map.class).withTypeArguments(wildcardType().withUpperBound(Serializable.class), parameterizedType(List.class).withTypeArguments(parameterizedType(List.class).withTypeArguments(wildcardType().withUpperBound(parameterizedType(Set.class).withTypeArguments(wildcardType().withLowerBound(parameterizedType(Iterable.class).withTypeArguments(wildcardType().withLowerBound(parameterizedType(Map.class).withTypeArguments(typeVariable("SECOND").withUpperBounds(Serializable.class, Cloneable.class), wildcardType()))))))))))), // assigned to InterfaceWithThreeTypeParameters<_,_,C>
parameterizedType(Comparable.class).withTypeArguments(parameterizedType(testInput).withTypeArguments(typeVariable("FIRST").withUpperBounds(String.class, Serializable.class), typeVariable("SECOND").withUpperBounds(Serializable.class, Cloneable.class))));
// @formatter:on
}
use of com.tngtech.archunit.core.domain.JavaType in project ArchUnit by TNG.
the class ClassFileImporterGenericInterfacesTest method imports_nested_generic_interfaces.
@Test
public void imports_nested_generic_interfaces() {
@SuppressWarnings("unused")
class Child<T> implements SomeDeeplyNestedInterface<File, SomeNestedInterface<Path, Path>> {
}
JavaType genericInterface = getOnlyElement(importClassWithOnlyGenericTypeResolution(Child.class).getInterfaces());
assertThatType(genericInterface).as("generic interface").hasErasure(SomeDeeplyNestedInterface.class).hasActualTypeArguments(concreteClass(File.class), parameterizedType(SomeNestedInterface.class).withTypeArguments(Path.class, Path.class));
}
use of com.tngtech.archunit.core.domain.JavaType in project ArchUnit by TNG.
the class ClassFileImporterGenericInterfacesTest method test_imports_complex_type_with_multiple_nested_actual_type_arguments_of_generic_interface_with_generic_array_bounds.
@Test
@UseDataProvider
public void test_imports_complex_type_with_multiple_nested_actual_type_arguments_of_generic_interface_with_generic_array_bounds(Class<?> testInput) {
JavaType genericInterface = getOnlyElement(importClassWithOnlyGenericTypeResolution(testInput).getInterfaces());
assertThatType(genericInterface).hasActualTypeArguments(parameterizedType(List.class).withTypeArguments(genericArray(typeVariableArrayName("X", 1)).withComponentType(typeVariable("X").withUpperBounds(Serializable.class))), parameterizedType(List.class).withWildcardTypeParameterWithUpperBound(genericArray(typeVariableArrayName("X", 2)).withComponentType(genericArray(typeVariableArrayName("X", 1)).withComponentType(typeVariable("X").withUpperBounds(Serializable.class)))), parameterizedType(Map.class).withTypeArguments(wildcardType().withLowerBound(genericArray(typeVariableArrayName("Y", 1)).withComponentType(typeVariable("Y").withUpperBounds(String.class))), parameterizedType(Map.class).withTypeArguments(parameterizedType(Map.class).withTypeArguments(wildcardType().withLowerBound(genericArray(typeVariableArrayName("Y", 3)).withComponentType(genericArray(typeVariableArrayName("Y", 2)).withComponentType(genericArray(typeVariableArrayName("Y", 1)).withComponentType(typeVariable("Y").withUpperBounds(String.class))))), wildcardType()), genericArray(typeVariableArrayName("X", 2)).withComponentType(genericArray(typeVariableArrayName("X", 1)).withComponentType(typeVariable("X").withUpperBounds(Serializable.class))))));
}
use of com.tngtech.archunit.core.domain.JavaType in project ArchUnit by TNG.
the class ClassFileImporterGenericInterfacesTest method test_imports_type_of_generic_interface_with_parameterized_array_bounds.
@Test
@UseDataProvider
public void test_imports_type_of_generic_interface_with_parameterized_array_bounds(Class<?> testInput) {
JavaType genericInterface = getOnlyElement(importClassWithOnlyGenericTypeResolution(testInput).getInterfaces());
assertThatType(genericInterface).hasActualTypeArguments(genericArray(parameterizedTypeArrayName(List.class, String.class, 1)).withComponentType(parameterizedType(List.class).withTypeArguments(String.class)), genericArray(parameterizedTypeArrayName(List.class, String[].class, 2)).withComponentType(genericArray(parameterizedTypeArrayName(List.class, String[].class, 1)).withComponentType(parameterizedType(List.class).withTypeArguments(String[].class))), genericArray(parameterizedTypeArrayName(List.class, String[][].class, 3)).withComponentType(genericArray(parameterizedTypeArrayName(List.class, String[][].class, 2)).withComponentType(genericArray(parameterizedTypeArrayName(List.class, String[][].class, 1)).withComponentType(parameterizedType(List.class).withTypeArguments(String[][].class)))));
}
use of com.tngtech.archunit.core.domain.JavaType in project ArchUnit by TNG.
the class ClassFileImporterGenericInterfacesTest method imports_wildcards_of_generic_interface_bound_by_type_variables_of_enclosing_classes.
@Test
public void imports_wildcards_of_generic_interface_bound_by_type_variables_of_enclosing_classes() {
@SuppressWarnings("unused")
class OuterWithTypeParameter<OUTER_ONE extends String, OUTER_TWO extends Serializable> {
class SomeInner {
class Child implements InterfaceWithTwoTypeParameters<ClassParameterWithSingleTypeParameter<? extends OUTER_ONE>, ClassParameterWithSingleTypeParameter<? super OUTER_TWO>> {
}
}
}
JavaType genericInterface = getOnlyElement(importClassesWithOnlyGenericTypeResolution(OuterWithTypeParameter.SomeInner.Child.class, OuterWithTypeParameter.SomeInner.class, OuterWithTypeParameter.class).get(OuterWithTypeParameter.SomeInner.Child.class).getInterfaces());
assertThatType(genericInterface).as("generic interface").hasActualTypeArguments(parameterizedType(ClassParameterWithSingleTypeParameter.class).withWildcardTypeParameterWithUpperBound(typeVariable("OUTER_ONE").withUpperBounds(String.class)), parameterizedType(ClassParameterWithSingleTypeParameter.class).withWildcardTypeParameterWithLowerBound(typeVariable("OUTER_TWO").withUpperBounds(Serializable.class)));
}
Aggregations