use of com.tngtech.archunit.core.domain.JavaType in project ArchUnit by TNG.
the class ClassFileImporterGenericMethodReturnTypesTest method imports_non_generic_method_return_type.
@Test
public void imports_non_generic_method_return_type() {
class NonGenericReturnType {
}
@SuppressWarnings("unused")
class SomeClass {
NonGenericReturnType method() {
return null;
}
}
JavaType returnType = importClassWithOnlyGenericTypeResolution(SomeClass.class).getMethod("method").getReturnType();
assertThatType(returnType).as("return type").matches(NonGenericReturnType.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_with_multiple_wildcards_with_various_bounds.
@Test
public void imports_generic_method_return_type_with_actual_type_arguments_with_multiple_wildcards_with_various_bounds() {
@SuppressWarnings("unused")
class GenericReturnType<A, B> {
}
@SuppressWarnings("unused")
class SomeClass {
GenericReturnType<ClassParameterWithSingleTypeParameter<Map<? extends Serializable, ? super File>>, ClassParameterWithSingleTypeParameter<Reference<? super String>>> method() {
return null;
}
}
JavaType genericReturnType = importClassWithOnlyGenericTypeResolution(SomeClass.class).getMethod("method").getReturnType();
assertThatType(genericReturnType).as("generic return type").hasActualTypeArguments(parameterizedType(ClassParameterWithSingleTypeParameter.class).withTypeArguments(parameterizedType(Map.class).withWildcardTypeParameters(wildcardType().withUpperBound(Serializable.class), wildcardType().withLowerBound(File.class))), parameterizedType(ClassParameterWithSingleTypeParameter.class).withTypeArguments(parameterizedType(Reference.class).withWildcardTypeParameterWithLowerBound(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_multiple_type_arguments.
@Test
public void imports_generic_method_return_type_with_multiple_type_arguments() {
@SuppressWarnings("unused")
class GenericReturnType<A, B, C> {
}
@SuppressWarnings("unused")
class SomeClass {
GenericReturnType<String, Serializable, File> method() {
return null;
}
}
JavaType genericReturnType = importClassWithOnlyGenericTypeResolution(SomeClass.class).getMethod("method").getReturnType();
assertThatType(genericReturnType).as("generic return type").hasErasure(GenericReturnType.class).hasActualTypeArguments(String.class, Serializable.class, File.class);
}
use of com.tngtech.archunit.core.domain.JavaType in project ArchUnit by TNG.
the class HasReturnTypeTest method function_get_raw_return_type.
@Test
public void function_get_raw_return_type() {
abstract class TestClass implements Iterable<String> {
}
JavaType genericType = importClassWithContext(TestClass.class).getSuperclass().get();
JavaClass expectedType = genericType.toErasure();
assertThatType(GET_RAW_RETURN_TYPE.apply(newHasReturnType(genericType, expectedType))).as("result of GET_RAW_RETURN_TYPE").isEqualTo(expectedType);
}
use of com.tngtech.archunit.core.domain.JavaType in project ArchUnit by TNG.
the class HasReturnTypeTest method function_get_return_type.
@Test
public void function_get_return_type() {
abstract class TestClass implements Iterable<String> {
}
JavaType expectedType = importClassWithContext(TestClass.class).getSuperclass().get();
JavaClass rawType = expectedType.toErasure();
assertThatType(GET_RETURN_TYPE.apply(newHasReturnType(expectedType, rawType))).as("result of GET_RETURN_TYPE").isEqualTo(expectedType);
}
Aggregations