ProjectionService implements InitializingBean { void addProjectionInterfaces(String basePackage) throws MultipleDefaultProjectionsException, MultipleSimilarlyNamedProjectionsException { for(var annotatedInterface : getAnnotatedInterfaces(basePackage)) { var annotation = annotationUtilsWrapper.findAnnotation(annotatedInterface, NamedProjection.class); addProjectionInterface(annotation, annotatedInterface); } } @Autowired  ProjectionService(AnnotatedTypeScanner typeScanner, AnnotationUtilsWrapper annotationUtilsWrapper); Class<?> getByNameOrDefault(@NonNull String projectionName, @NonNull Class<?> projectionTarget); Class<?> getDefault(Class<?> projectionTarget); @Override void afterPropertiesSet();  }
@Test public void addProjectionInterfacesAddsProjectionInterfaces() throws MultipleDefaultProjectionsException, MultipleSimilarlyNamedProjectionsException { var expectedName = "name"; var expectedTarget = (Class) Integer.class; var expectedBasePackage = "de/test"; given(typeScannerMock.findTypes(expectedBasePackage)).willReturn(Set.of(annotatedClass)); given(annotationUtilsWrapperMock.findAnnotation(annotatedClass, NamedProjection.class)) .willReturn(namedProjectionAnnotationMock); given(namedProjectionAnnotationMock.target()) .willReturn(expectedTarget); given(namedProjectionAnnotationMock.name()) .willReturn(expectedName); given(namedProjectionAnnotationMock.defaultProjection()) .willReturn(true); projectionService.addProjectionInterfaces(expectedBasePackage); var softly = new SoftAssertions(); softly.assertThat(projectionService.projectionClassMap) .containsExactly(entry(Pair.of(expectedName, expectedTarget), (Class<?>) annotatedClass)); softly.assertThat(projectionService.defaultProjectionClassMap) .containsExactly(entry((Class<?>) expectedTarget, (Class<?>) annotatedClass)); softly.assertAll(); }