From 8bde768dd65c90129851a86a7a592cbe45405927 Mon Sep 17 00:00:00 2001 From: GeorgeC Date: Thu, 14 Nov 2024 11:28:37 -0500 Subject: [PATCH] Add tests for legacy search results in ConceptRepository 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. --- .../concept/ConceptRepositoryTest.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptRepositoryTest.java b/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptRepositoryTest.java index f371012..ee55640 100644 --- a/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptRepositoryTest.java +++ b/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptRepositoryTest.java @@ -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; @@ -323,4 +324,37 @@ void shouldGetContConceptWithDecimalNotation() { Assertions.assertEquals(0.57f, concept.min()); Assertions.assertEquals(6.77f, concept.max()); } + + @Test + void shouldGetLegacySearchResults() { + List searchResults = subject.getLegacySearchResults(new Filter(List.of(), "", List.of()), Pageable.unpaged()); + + Assertions.assertEquals(30, searchResults.size()); + } + + @Test + void shouldGetLegacySearchResultsBySearch() { + List 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 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 searchResults = subject.getLegacySearchResults(new Filter(List.of(), "", List.of()), Pageable.unpaged()); + List concepts = subject.getConcepts(new Filter(List.of(), "", List.of()), Pageable.unpaged()); + + Assertions.assertEquals(searchResults.size(), concepts.size()); + } }