use of com.tngtech.archunit.core.importer.testexamples.annotatedclassimport.SimpleAnnotation in project ArchUnit by TNG.
the class ClassFileImporterAnnotationsTest method imports_parameter_annotations_correctly_for_synthetic_constructor_parameter.
@Test
public void imports_parameter_annotations_correctly_for_synthetic_constructor_parameter() {
@SuppressWarnings("unused")
class LocalClassThusSyntheticFirstConstructorParameter {
LocalClassThusSyntheticFirstConstructorParameter(Object notAnnotated, @SimpleAnnotation("test") List<String> annotated) {
}
}
JavaConstructor constructor = getOnlyElement(new ClassFileImporter().importClasses(LocalClassThusSyntheticFirstConstructorParameter.class, String.class).get(LocalClassThusSyntheticFirstConstructorParameter.class).getConstructors());
List<Set<JavaAnnotation<JavaParameter>>> parameterAnnotations = constructor.getParameterAnnotations();
assertThat(parameterAnnotations).as("parameter annotations").hasSize(2);
assertThatAnnotations(parameterAnnotations.get(0)).isEmpty();
assertThatAnnotations(parameterAnnotations.get(1)).isNotEmpty();
List<JavaParameter> parameters = constructor.getParameters();
for (int i = 0; i < parameterAnnotations.size(); i++) {
assertThat(parameterAnnotations.get(i)).isEqualTo(parameters.get(i).getAnnotations());
assertThatAnnotations(parameterAnnotations.get(i)).match(ImmutableSet.copyOf(constructor.reflect().getParameterAnnotations()[i]));
}
}
Aggregations