Skip to content

Commit 394e873

Browse files
committed
GH-187 - Unit tests for Spring Data repository detection.
Both imperative and reactive flavours.
1 parent bb800ba commit 394e873

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

spring-modulith-core/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@
9191
<scope>test</scope>
9292
</dependency>
9393

94+
<dependency>
95+
<groupId>io.projectreactor</groupId>
96+
<artifactId>reactor-core</artifactId>
97+
<scope>test</scope>
98+
</dependency>
99+
94100
</dependencies>
95101

96102
</project>

spring-modulith-core/src/test/java/org/springframework/modulith/core/ArchitecturallyEvidentTypeUnitTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.springframework.context.ApplicationListener;
3434
import org.springframework.context.event.EventListener;
3535
import org.springframework.data.repository.CrudRepository;
36+
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
3637
import org.springframework.modulith.core.ArchitecturallyEvidentType.SpringAwareArchitecturallyEvidentType;
3738
import org.springframework.modulith.core.ArchitecturallyEvidentType.SpringDataAwareArchitecturallyEvidentType;
3839
import org.springframework.stereotype.Repository;
@@ -76,6 +77,24 @@ void detectsSpringAnnotatedRepositories() {
7677
assertThat(type.isRepository()).isTrue();
7778
}
7879

80+
@Test // GH-187
81+
void detectsSpringDataRepositories() {
82+
83+
var type = ArchitecturallyEvidentType.of(
84+
classes.getRequiredClass(SampleRepository.class), Classes.NONE);
85+
86+
assertThat(type.isRepository()).isTrue();
87+
}
88+
89+
@Test // GH-187
90+
void detectsReactiveSpringDataRepositories() {
91+
92+
var type = ArchitecturallyEvidentType.of(
93+
classes.getRequiredClass(ReactiveSampleRepository.class), Classes.NONE);
94+
95+
assertThat(type.isRepository()).isTrue();
96+
}
97+
7998
@Test
8099
void doesNotConsiderEntityAggregateRoot() {
81100

@@ -197,6 +216,9 @@ class SampleEntity {}
197216

198217
interface SampleRepository extends CrudRepository<SampleEntity, UUID> {}
199218

219+
// GH-187
220+
interface ReactiveSampleRepository extends ReactiveCrudRepository<SampleEntity, UUID> {}
221+
200222
@Entity
201223
class OtherEntity {}
202224

0 commit comments

Comments
 (0)