Search in sources :

Example 21 with JavaType

use of com.tngtech.archunit.core.domain.JavaType in project ArchUnit by TNG.

the class ClassFileImporterGenericCodeUnitParameterTypesTest method test_creates_new_stub_type_variables_for_wildcards_bound_by_type_variables_of_enclosing_classes_that_are_out_of_context.

@Test
@UseDataProvider
public void test_creates_new_stub_type_variables_for_wildcards_bound_by_type_variables_of_enclosing_classes_that_are_out_of_context(JavaCodeUnit codeUnit) {
    JavaType genericParameterType = codeUnit.getParameterTypes().get(0);
    assertThatType(genericParameterType).as("generic parameter type").hasActualTypeArguments(parameterizedType(ClassParameterWithSingleTypeParameter.class).withWildcardTypeParameterWithUpperBound(typeVariable("OUTER_ONE").withoutUpperBounds()), parameterizedType(ClassParameterWithSingleTypeParameter.class).withWildcardTypeParameterWithLowerBound(typeVariable("OUTER_TWO").withoutUpperBounds()));
}
Also used : JavaType(com.tngtech.archunit.core.domain.JavaType) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 22 with JavaType

use of com.tngtech.archunit.core.domain.JavaType in project ArchUnit by TNG.

the class ClassFileImporterGenericCodeUnitParameterTypesTest method test_imports_complex_generic_code_unit_parameter_type_with_multiple_nested_actual_type_arguments_with_generic_array_bounds.

@Test
@UseDataProvider
public void test_imports_complex_generic_code_unit_parameter_type_with_multiple_nested_actual_type_arguments_with_generic_array_bounds(JavaCodeUnit codeUnit) {
    JavaType genericParameterType = codeUnit.getParameterTypes().get(0);
    assertThatType(genericParameterType).hasActualTypeArguments(genericArray("X[]").withComponentType(typeVariable("X").withUpperBounds(Serializable.class)), 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))))));
}
Also used : JavaType(com.tngtech.archunit.core.domain.JavaType) Serializable(java.io.Serializable) Map(java.util.Map) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 23 with JavaType

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_actual_type_arguments_parameterized_with_concrete_classes.

@Test
@UseDataProvider
public void test_imports_generic_code_unit_parameter_type_with_multiple_actual_type_arguments_parameterized_with_concrete_classes(JavaCodeUnit codeUnit) {
    JavaType genericParameterType = codeUnit.getParameterTypes().get(0);
    assertThatType(genericParameterType).as("generic parameter type").hasActualTypeArguments(parameterizedType(ClassParameterWithSingleTypeParameter.class).withTypeArguments(File.class), parameterizedType(InterfaceParameterWithSingleTypeParameter.class).withTypeArguments(Serializable.class), parameterizedType(InterfaceParameterWithSingleTypeParameter.class).withTypeArguments(String.class));
}
Also used : JavaType(com.tngtech.archunit.core.domain.JavaType) Serializable(java.io.Serializable) File(java.io.File) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 24 with JavaType

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_single_actual_type_argument_parameterized_with_concrete_class.

@Test
@UseDataProvider
public void test_imports_generic_code_unit_parameter_type_with_single_actual_type_argument_parameterized_with_concrete_class(JavaCodeUnit codeUnit) {
    JavaType genericParameterType = codeUnit.getParameterTypes().get(0);
    assertThatType(genericParameterType).as("generic parameter type").hasActualTypeArguments(parameterizedType(ClassParameterWithSingleTypeParameter.class).withTypeArguments(String.class));
}
Also used : JavaType(com.tngtech.archunit.core.domain.JavaType) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 25 with JavaType

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_single_actual_type_argument_parameterized_with_unbound_wildcard.

@Test
@UseDataProvider
public void test_imports_generic_code_unit_parameter_type_with_single_actual_type_argument_parameterized_with_unbound_wildcard(JavaCodeUnit codeUnit) {
    JavaType genericParameterType = codeUnit.getParameterTypes().get(0);
    assertThatType(genericParameterType).as("generic parameter type").hasActualTypeArguments(parameterizedType(ClassParameterWithSingleTypeParameter.class).withWildcardTypeParameter());
}
Also used : JavaType(com.tngtech.archunit.core.domain.JavaType) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Aggregations

JavaType (com.tngtech.archunit.core.domain.JavaType)133 Test (org.junit.Test)132 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)31 Serializable (java.io.Serializable)29 Map (java.util.Map)23 File (java.io.File)17 List (java.util.List)13 Reference (java.lang.ref.Reference)5 JavaClass (com.tngtech.archunit.core.domain.JavaClass)3 JavaTypeVariable (com.tngtech.archunit.core.domain.JavaTypeVariable)3 JavaParameterizedType (com.tngtech.archunit.core.domain.JavaParameterizedType)1 SomeDeeplyNestedInterface (com.tngtech.archunit.core.importer.ClassFileImporterGenericInterfacesTest.Outer.SomeNestedInterface.SomeDeeplyNestedInterface)1 Path (java.nio.file.Path)1 Set (java.util.Set)1