Skip to content

Commit

Permalink
Add tests for legacy search results in ConceptRepository
Browse files Browse the repository at this point in the history
Added unit tests to verify the functionality of getLegacySearchResults in ConceptRepository. Tests cover basic search, search by search term, result pagination, and consistency with concept search results.
  • Loading branch information
Gcolon021 committed Nov 14, 2024
1 parent 315bcd2 commit 8bde768
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import edu.harvard.dbmi.avillach.dictionary.concept.model.ContinuousConcept;
import edu.harvard.dbmi.avillach.dictionary.facet.Facet;
import edu.harvard.dbmi.avillach.dictionary.filter.Filter;
import edu.harvard.dbmi.avillach.dictionary.legacysearch.model.SearchResult;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -323,4 +324,37 @@ void shouldGetContConceptWithDecimalNotation() {
Assertions.assertEquals(0.57f, concept.min());
Assertions.assertEquals(6.77f, concept.max());
}

@Test
void shouldGetLegacySearchResults() {
List<SearchResult> searchResults = subject.getLegacySearchResults(new Filter(List.of(), "", List.of()), Pageable.unpaged());

Assertions.assertEquals(30, searchResults.size());
}

@Test
void shouldGetLegacySearchResultsBySearch() {
List<SearchResult> searchResults =
subject.getLegacySearchResults(new Filter(List.of(), "phs000007", List.of()), Pageable.unpaged());

searchResults.forEach(searchResult -> Assertions.assertEquals("phs000007", searchResult.result().studyId()));

}

@Test
void shouldGetLegacySearchResultsByPageSize() {
List<SearchResult> searchResults = subject.getLegacySearchResults(new Filter(List.of(), "", List.of()), Pageable.ofSize(5));

Assertions.assertEquals(5, searchResults.size());
}

@Test
void legacySearchResultShouldGetEqualCountToConceptSearch() {
// This test will ensure modifications made to the conceptSearch will be reflected in the legacy search result.
// They use near equivalent queries and updates made to one should be made to the other.
List<SearchResult> searchResults = subject.getLegacySearchResults(new Filter(List.of(), "", List.of()), Pageable.unpaged());
List<Concept> concepts = subject.getConcepts(new Filter(List.of(), "", List.of()), Pageable.unpaged());

Assertions.assertEquals(searchResults.size(), concepts.size());
}
}

0 comments on commit 8bde768

Please sign in to comment.