use of com.tngtech.archunit.core.domain.JavaType in project ArchUnit by TNG.
the class ClassFileImporterGenericInterfacesTest method imports_generic_interface_with_multiple_actual_type_arguments_parameterized_with_concrete_classes.
@Test
public void imports_generic_interface_with_multiple_actual_type_arguments_parameterized_with_concrete_classes() {
class Child implements InterfaceWithThreeTypeParameters<ClassParameterWithSingleTypeParameter<File>, InterfaceWithOneTypeParameter<Serializable>, InterfaceWithOneTypeParameter<String>> {
}
JavaType genericInterface = getOnlyElement(importClassWithOnlyGenericTypeResolution(Child.class).getInterfaces());
assertThatType(genericInterface).as("generic interface").hasActualTypeArguments(parameterizedType(ClassParameterWithSingleTypeParameter.class).withTypeArguments(File.class), parameterizedType(InterfaceWithOneTypeParameter.class).withTypeArguments(Serializable.class), parameterizedType(InterfaceWithOneTypeParameter.class).withTypeArguments(String.class));
}
use of com.tngtech.archunit.core.domain.JavaType in project ArchUnit by TNG.
the class ClassFileImporterGenericMethodReturnTypesTest method imports_generic_method_return_type_with_single_unbound_wildcard.
@Test
public void imports_generic_method_return_type_with_single_unbound_wildcard() {
@SuppressWarnings("unused")
class GenericReturnType<T> {
}
@SuppressWarnings("unused")
class SomeClass {
GenericReturnType<?> method() {
return null;
}
}
JavaType genericReturnType = importClassWithOnlyGenericTypeResolution(SomeClass.class).getMethod("method").getReturnType();
assertThatType(genericReturnType).as("generic return type").hasActualTypeArguments(wildcardType());
}
use of com.tngtech.archunit.core.domain.JavaType in project ArchUnit by TNG.
the class ClassFileImporterGenericMethodReturnTypesTest method imports_complex_generic_array_method_return_type.
@Test
public void imports_complex_generic_array_method_return_type() {
@SuppressWarnings("unused")
class GenericReturnType<A> {
}
@SuppressWarnings("unused")
class SomeClass {
GenericReturnType<Map<? super String, Map<Map<? super String, ?>, Serializable>>>[] method() {
return null;
}
}
JavaType genericReturnType = importClassWithOnlyGenericTypeResolution(SomeClass.class).getMethod("method").getReturnType();
assertThatType(genericReturnType).matches(genericArray(GenericReturnType.class.getName() + "<" + Map.class.getName() + "<? super " + String.class.getName() + ", " + Map.class.getName() + "<" + Map.class.getName() + "<? super " + String.class.getName() + ", ?>, " + Serializable.class.getName() + ">>>[]").withComponentType(parameterizedType(GenericReturnType.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 ClassFileImporterGenericMethodReturnTypesTest method imports_generic_method_return_type_with_actual_type_arguments_parameterized_with_bounded_wildcards.
@Test
public void imports_generic_method_return_type_with_actual_type_arguments_parameterized_with_bounded_wildcards() {
@SuppressWarnings("unused")
class GenericReturnType<A, B> {
}
@SuppressWarnings("unused")
class SomeClass {
GenericReturnType<ClassParameterWithSingleTypeParameter<? extends String>, ClassParameterWithSingleTypeParameter<? super File>> method() {
return null;
}
}
JavaType genericReturnType = importClassWithOnlyGenericTypeResolution(SomeClass.class).getMethod("method").getReturnType();
assertThatType(genericReturnType).as("generic return type").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 ClassFileImporterGenericMethodReturnTypesTest method imports_generic_method_return_type_with_primitive_array_type_argument.
@Test
public void imports_generic_method_return_type_with_primitive_array_type_argument() {
@SuppressWarnings("unused")
class GenericReturnType<T> {
}
@SuppressWarnings("unused")
class SomeClass {
GenericReturnType<int[]> method() {
return null;
}
}
JavaType genericMethodReturnType = importClassWithOnlyGenericTypeResolution(SomeClass.class).getMethod("method").getReturnType();
assertThatType(genericMethodReturnType).as("generic method return type").hasErasure(GenericReturnType.class).hasActualTypeArguments(int[].class);
}
Aggregations