From 394e87337b1232286c42c1aa23f2558824cbc876 Mon Sep 17 00:00:00 2001 From: Oliver Drotbohm Date: Fri, 28 Apr 2023 20:22:27 +0200 Subject: [PATCH] GH-187 - Unit tests for Spring Data repository detection. Both imperative and reactive flavours. --- spring-modulith-core/pom.xml | 6 +++++ .../ArchitecturallyEvidentTypeUnitTest.java | 22 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/spring-modulith-core/pom.xml b/spring-modulith-core/pom.xml index a9bd3494..f46dcd38 100644 --- a/spring-modulith-core/pom.xml +++ b/spring-modulith-core/pom.xml @@ -91,6 +91,12 @@ test + + io.projectreactor + reactor-core + test + + diff --git a/spring-modulith-core/src/test/java/org/springframework/modulith/core/ArchitecturallyEvidentTypeUnitTest.java b/spring-modulith-core/src/test/java/org/springframework/modulith/core/ArchitecturallyEvidentTypeUnitTest.java index 9c8b57c3..da50b844 100644 --- a/spring-modulith-core/src/test/java/org/springframework/modulith/core/ArchitecturallyEvidentTypeUnitTest.java +++ b/spring-modulith-core/src/test/java/org/springframework/modulith/core/ArchitecturallyEvidentTypeUnitTest.java @@ -33,6 +33,7 @@ import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.context.ApplicationListener; import org.springframework.context.event.EventListener; import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.reactive.ReactiveCrudRepository; import org.springframework.modulith.core.ArchitecturallyEvidentType.SpringAwareArchitecturallyEvidentType; import org.springframework.modulith.core.ArchitecturallyEvidentType.SpringDataAwareArchitecturallyEvidentType; import org.springframework.stereotype.Repository; @@ -76,6 +77,24 @@ class ArchitecturallyEvidentTypeUnitTest { assertThat(type.isRepository()).isTrue(); } + @Test // GH-187 + void detectsSpringDataRepositories() { + + var type = ArchitecturallyEvidentType.of( + classes.getRequiredClass(SampleRepository.class), Classes.NONE); + + assertThat(type.isRepository()).isTrue(); + } + + @Test // GH-187 + void detectsReactiveSpringDataRepositories() { + + var type = ArchitecturallyEvidentType.of( + classes.getRequiredClass(ReactiveSampleRepository.class), Classes.NONE); + + assertThat(type.isRepository()).isTrue(); + } + @Test void doesNotConsiderEntityAggregateRoot() { @@ -197,6 +216,9 @@ class ArchitecturallyEvidentTypeUnitTest { interface SampleRepository extends CrudRepository {} + // GH-187 + interface ReactiveSampleRepository extends ReactiveCrudRepository {} + @Entity class OtherEntity {}