diff --git a/jnosql-mapping/jnosql-mapping-reflection/src/test/java/org/eclipse/jnosql/mapping/reflection/ClassGraphClassScannerTest.java b/jnosql-mapping/jnosql-mapping-reflection/src/test/java/org/eclipse/jnosql/mapping/reflection/ClassGraphClassScannerTest.java index dee374f16..eec2d6fdc 100644 --- a/jnosql-mapping/jnosql-mapping-reflection/src/test/java/org/eclipse/jnosql/mapping/reflection/ClassGraphClassScannerTest.java +++ b/jnosql-mapping/jnosql-mapping-reflection/src/test/java/org/eclipse/jnosql/mapping/reflection/ClassGraphClassScannerTest.java @@ -16,6 +16,7 @@ import jakarta.data.repository.CrudRepository; import org.eclipse.jnosql.mapping.NoSQLRepository; +import org.eclipse.jnosql.mapping.reflection.RepositoryFilterTest.Persons; import org.eclipse.jnosql.mapping.reflection.entities.AnimalRepository; import org.eclipse.jnosql.mapping.reflection.entities.Contact; import org.eclipse.jnosql.mapping.reflection.entities.Job; @@ -57,8 +58,9 @@ void shouldReturnRepositories() { Set> reepositores = classScanner.repositories(); Assertions.assertNotNull(reepositores); - assertThat(reepositores).hasSize(3) - .contains(AnimalRepository.class, + assertThat(reepositores).hasSize(4) + .contains(Persons.class, + AnimalRepository.class, PersonRepository.class, MovieRepository.class); } @@ -92,8 +94,8 @@ void shouldFieldByNoSQL() { @Test void shouldReturnStandardRepositories() { Set> repositories = classScanner.repositoriesStandard(); - assertThat(repositories).hasSize(2) - .contains(PersonRepository.class, MovieRepository.class); + assertThat(repositories).hasSize(3) + .contains(Persons.class, PersonRepository.class, MovieRepository.class); } @Test diff --git a/jnosql-mapping/jnosql-mapping-reflection/src/test/java/org/eclipse/jnosql/mapping/reflection/RepositoryFilterTest.java b/jnosql-mapping/jnosql-mapping-reflection/src/test/java/org/eclipse/jnosql/mapping/reflection/RepositoryFilterTest.java index 7eeb40af5..bd131c814 100644 --- a/jnosql-mapping/jnosql-mapping-reflection/src/test/java/org/eclipse/jnosql/mapping/reflection/RepositoryFilterTest.java +++ b/jnosql-mapping/jnosql-mapping-reflection/src/test/java/org/eclipse/jnosql/mapping/reflection/RepositoryFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2023, 2024 Contributors to the Eclipse Foundation * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Apache License v2.0 which accompanies this distribution. @@ -35,12 +35,15 @@ class RepositoryFilterTest { private Predicate> valid; - private Predicate> invalid; + private Predicate> supported; + + private Predicate> validAndSupported; @BeforeEach void setUp() { - this.valid = RepositoryFilter.INSTANCE; - this.invalid = RepositoryFilter.INSTANCE::isInvalid; + this.valid = RepositoryFilter.INSTANCE::isValid; + this.supported = RepositoryFilter.INSTANCE::isSupported; + this.validAndSupported = RepositoryFilter.INSTANCE; } @Test @@ -58,27 +61,49 @@ void shouldReturnFalseWhenHasNotSupportRepository() { assertThat(valid.test(StringSupplier.class)).isFalse(); assertThat(valid.test(Repository.class)).isFalse(); } - + @Test - void shouldReturnInvalid(){ - assertThat(invalid.test(PersonRepository.class)).isFalse(); - assertThat(invalid.test(People.class)).isFalse(); - assertThat(invalid.test(Persons.class)).isFalse(); - assertThat(invalid.test(NoSQLVendor.class)).isTrue(); - assertThat(invalid.test(Server.class)).isTrue(); + void shouldReturnSupportedWhenAnnotatedWithRepositoryANY_PROVIDER() { + assertThat(supported.test(PersonRepository.class)).isTrue(); + assertThat(supported.test(Persons.class)).isTrue(); + } + + @Test + void shouldReturnSupportedWhenAnnotatedWithRepositoryEclipse_JNoSQL() { + assertThat(supported.test(Server.class)).isTrue(); } - + @Test + void shouldReturnUnsupportedWhenNotAnnotatedWithRepository() { + assertThat(supported.test(NoSQLVendor.class)).isFalse(); + assertThat(supported.test(People.class)).isFalse(); + assertThat(supported.test(StringSupplier.class)).isFalse(); + assertThat(supported.test(Repository.class)).isFalse(); + } + + @Test + void shouldReturnValidAndSupported() { + assertThat(validAndSupported.test(PersonRepository.class)).isTrue(); + assertThat(validAndSupported.test(Persons.class)).isTrue(); + } + + @Test + void shouldReturnReturnNotValidAndSupported() { + assertThat(validAndSupported.test(People.class)).isFalse(); + assertThat(validAndSupported.test(Server.class)).isFalse(); + assertThat(validAndSupported.test(StringSupplier.class)).isFalse(); + } + private interface People extends BasicRepository { } - private interface Persons extends BasicRepository { - + @jakarta.data.repository.Repository + public interface Persons extends BasicRepository { } - + + @jakarta.data.repository.Repository(provider = "Eclipse JNoSQL") private interface Server extends BasicRepository { - } private interface StringSupplier extends Supplier {