use of com.tngtech.archunit.core.domain.JavaType in project ArchUnit by TNG.
the class ClassFileImporterGenericFieldTypesTest method imports_complex_generic_field_type_with_multiple_nested_actual_type_arguments_with_concrete_array_bounds.
@Test
public void imports_complex_generic_field_type_with_multiple_nested_actual_type_arguments_with_concrete_array_bounds() {
@SuppressWarnings("unused")
class GenericFieldType<A, B, C> {
}
@SuppressWarnings("unused")
class SomeClass {
GenericFieldType<List<Serializable[]>, List<? extends Serializable[][]>, Map<? super String[], Map<Map<? super String[][][], ?>, Serializable[][]>>> field;
}
JavaType genericFieldType = importClassWithOnlyGenericTypeResolution(SomeClass.class).getField("field").getType();
assertThatType(genericFieldType).hasActualTypeArguments(parameterizedType(List.class).withTypeArguments(Serializable[].class), parameterizedType(List.class).withWildcardTypeParameterWithUpperBound(Serializable[][].class), 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 ClassFileImporterGenericFieldTypesTest method imports_generic_field_type_with_primitive_array_type_argument.
@Test
public void imports_generic_field_type_with_primitive_array_type_argument() {
@SuppressWarnings("unused")
class GenericFieldType<T> {
}
@SuppressWarnings("unused")
class SomeClass {
GenericFieldType<int[]> field;
}
JavaType genericFieldType = importClassWithOnlyGenericTypeResolution(SomeClass.class).getField("field").getType();
assertThatType(genericFieldType).as("generic field type").hasErasure(GenericFieldType.class).hasActualTypeArguments(int[].class);
}
use of com.tngtech.archunit.core.domain.JavaType in project ArchUnit by TNG.
the class ClassFileImporterGenericFieldTypesTest method imports_generic_field_type_with_actual_type_arguments_parameterized_with_bounded_wildcards.
@Test
public void imports_generic_field_type_with_actual_type_arguments_parameterized_with_bounded_wildcards() {
@SuppressWarnings("unused")
class GenericFieldType<A, B> {
}
@SuppressWarnings("unused")
class SomeClass {
GenericFieldType<ClassParameterWithSingleTypeParameter<? extends String>, ClassParameterWithSingleTypeParameter<? super File>> field;
}
JavaType genericFieldType = importClassWithOnlyGenericTypeResolution(SomeClass.class).getField("field").getType();
assertThatType(genericFieldType).as("generic field 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 ClassFileImporterGenericFieldTypesTest method imports_type_variable_as_generic_field_type.
@Test
public void imports_type_variable_as_generic_field_type() {
@SuppressWarnings("unused")
class SomeClass<T extends String> {
T field;
}
JavaType genericFieldType = importClassWithOnlyGenericTypeResolution(SomeClass.class).getField("field").getType();
assertThatType(genericFieldType).as("generic field type").isInstanceOf(JavaTypeVariable.class).hasErasure(String.class);
}
use of com.tngtech.archunit.core.domain.JavaType in project ArchUnit by TNG.
the class ClassFileImporterGenericFieldTypesTest method imports_generic_field_type_with_multiple_actual_type_arguments_parameterized_with_concrete_classes.
@Test
public void imports_generic_field_type_with_multiple_actual_type_arguments_parameterized_with_concrete_classes() {
@SuppressWarnings("unused")
class GenericFieldType<A, B, C> {
}
@SuppressWarnings("unused")
class SomeClass {
GenericFieldType<ClassParameterWithSingleTypeParameter<File>, InterfaceParameterWithSingleTypeParameter<Serializable>, InterfaceParameterWithSingleTypeParameter<String>> field;
}
JavaType genericFieldType = importClassWithOnlyGenericTypeResolution(SomeClass.class).getField("field").getType();
assertThatType(genericFieldType).as("generic field type").hasActualTypeArguments(parameterizedType(ClassParameterWithSingleTypeParameter.class).withTypeArguments(File.class), parameterizedType(InterfaceParameterWithSingleTypeParameter.class).withTypeArguments(Serializable.class), parameterizedType(InterfaceParameterWithSingleTypeParameter.class).withTypeArguments(String.class));
}
Aggregations