Skip to content

Commit

Permalink
test: update unit tests with isSupported
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleAure committed Oct 30, 2024
1 parent 6d8f051 commit 0ddd843
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -57,8 +58,9 @@ void shouldReturnRepositories() {
Set<Class<?>> 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);
}
Expand Down Expand Up @@ -92,8 +94,8 @@ void shouldFieldByNoSQL() {
@Test
void shouldReturnStandardRepositories() {
Set<Class<?>> repositories = classScanner.repositoriesStandard();
assertThat(repositories).hasSize(2)
.contains(PersonRepository.class, MovieRepository.class);
assertThat(repositories).hasSize(3)
.contains(Persons.class, PersonRepository.class, MovieRepository.class);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -35,12 +35,15 @@ class RepositoryFilterTest {

private Predicate<Class<?>> valid;

private Predicate<Class<?>> invalid;
private Predicate<Class<?>> supported;

private Predicate<Class<?>> 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
Expand All @@ -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<Person, Long> {

}

private interface Persons extends BasicRepository<Person, Long> {

@jakarta.data.repository.Repository
public interface Persons extends BasicRepository<Person, Long> {
}


@jakarta.data.repository.Repository(provider = "Eclipse JNoSQL")
private interface Server extends BasicRepository<Computer, String> {

}

private interface StringSupplier extends Supplier<String> {
Expand Down

0 comments on commit 0ddd843

Please sign in to comment.