GH-187 - Unit tests for Spring Data repository detection.

Both imperative and reactive flavours.
This commit is contained in:
Oliver Drotbohm
2023-04-28 20:22:27 +02:00
parent bb800ba046
commit 394e87337b
2 changed files with 28 additions and 0 deletions

View File

@@ -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<SampleEntity, UUID> {}
// GH-187
interface ReactiveSampleRepository extends ReactiveCrudRepository<SampleEntity, UUID> {}
@Entity
class OtherEntity {}