diff --git a/src/main/java/cms/gov/madie/measure/dto/MeasureSearchCriteria.java b/src/main/java/cms/gov/madie/measure/dto/MeasureSearchCriteria.java new file mode 100644 index 000000000..a0c645577 --- /dev/null +++ b/src/main/java/cms/gov/madie/measure/dto/MeasureSearchCriteria.java @@ -0,0 +1,16 @@ +package cms.gov.madie.measure.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder(toBuilder = true) +@AllArgsConstructor +@NoArgsConstructor +public class MeasureSearchCriteria { + private String query; + private String model; + private Boolean draft; +} diff --git a/src/main/java/cms/gov/madie/measure/repositories/MeasureAclRepository.java b/src/main/java/cms/gov/madie/measure/repositories/MeasureAclRepository.java index 40a4b36bb..dbe66822f 100644 --- a/src/main/java/cms/gov/madie/measure/repositories/MeasureAclRepository.java +++ b/src/main/java/cms/gov/madie/measure/repositories/MeasureAclRepository.java @@ -2,6 +2,7 @@ import cms.gov.madie.measure.dto.MeasureListDTO; +import cms.gov.madie.measure.dto.MeasureSearchCriteria; import gov.cms.madie.models.dto.LibraryUsage; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -17,7 +18,11 @@ public interface MeasureAclRepository { * @param pageable- instance of Pageable * @return Pageable List of measures */ - Page findMyActiveMeasures(String userId, Pageable pageable, String searchTerm); + Page findActiveMeasures( + String userId, + Pageable pageable, + MeasureSearchCriteria searchCriteria, + boolean filterByCurrentUser); /** * Get all the measures(name, version and owner) if they include any version of given library name diff --git a/src/main/java/cms/gov/madie/measure/repositories/MeasureAclRepositoryImpl.java b/src/main/java/cms/gov/madie/measure/repositories/MeasureAclRepositoryImpl.java index 23f5cfb0b..cfad5d815 100644 --- a/src/main/java/cms/gov/madie/measure/repositories/MeasureAclRepositoryImpl.java +++ b/src/main/java/cms/gov/madie/measure/repositories/MeasureAclRepositoryImpl.java @@ -2,6 +2,7 @@ import cms.gov.madie.measure.dto.FacetDTO; import cms.gov.madie.measure.dto.MeasureListDTO; +import cms.gov.madie.measure.dto.MeasureSearchCriteria; import gov.cms.madie.models.access.RoleEnum; import gov.cms.madie.models.dto.LibraryUsage; import gov.cms.madie.models.measure.Measure; @@ -36,31 +37,56 @@ private LookupOperation getLookupOperation() { .as("measureSet"); } + // First get All Active measures + // if query string is given then search for the query string in measureName and eCQM title + // If model is provided filter out those measures based on Model + // if draft status is provided then filter out them based on draft value + // if filterByCurrentUser = true then filter measures owned by user or shared with @Override - public Page findMyActiveMeasures( - String userId, Pageable pageable, String searchTerm) { + public Page findActiveMeasures( + String userId, + Pageable pageable, + MeasureSearchCriteria measureSearchCriteria, + boolean filterByCurrentUser) { // join measure and measure_set to lookup owner and ACL info LookupOperation lookupOperation = getLookupOperation(); // prepare measure search criteria Criteria measureCriteria = Criteria.where("active").is(true); - if (StringUtils.isNotBlank(searchTerm)) { - measureCriteria.andOperator( - new Criteria() - .orOperator( - Criteria.where("measureName").regex(searchTerm, "i"), - Criteria.where("ecqmTitle").regex(searchTerm, "i"))); + + if (measureSearchCriteria != null) { + // If query is given, search for the query string in measureName and ecqmTitle + if (StringUtils.isNotBlank(measureSearchCriteria.getQuery())) { + measureCriteria.andOperator( + new Criteria() + .orOperator( + Criteria.where("measureName").regex(measureSearchCriteria.getQuery(), "i"), + Criteria.where("ecqmTitle").regex(measureSearchCriteria.getQuery(), "i"))); + } + + // If model is provided, filter out those measures with that model + if (StringUtils.isNotBlank(measureSearchCriteria.getModel())) { + measureCriteria.and("model").is(measureSearchCriteria.getModel()); + } + + // If draft is provided, filter measures based on MeasureMetaData.draft + if (measureSearchCriteria.getDraft() != null) { + measureCriteria.and("measureMetaData.draft").is(measureSearchCriteria.getDraft()); + } } // prepare measure set search criteria(user is either owner or shared with) - Criteria measureSetCriteria = - new Criteria() - .orOperator( - Criteria.where("measureSet.owner").regex("^\\Q" + userId + "\\E$", "i"), - Criteria.where("measureSet.acls.userId") - .regex("^\\Q" + userId + "\\E$", "i") - .and("measureSet.acls.roles") - .in(RoleEnum.SHARED_WITH)); + Criteria measureSetCriteria = new Criteria(); + if (filterByCurrentUser) { + measureSetCriteria = + new Criteria() + .orOperator( + Criteria.where("measureSet.owner").regex("^\\Q" + userId + "\\E$", "i"), + Criteria.where("measureSet.acls.userId") + .regex("^\\Q" + userId + "\\E$", "i") + .and("measureSet.acls.roles") + .in(RoleEnum.SHARED_WITH)); + } // combine measure and measure set criteria MatchOperation matchOperation = diff --git a/src/main/java/cms/gov/madie/measure/repositories/MeasureRepository.java b/src/main/java/cms/gov/madie/measure/repositories/MeasureRepository.java index ab49050da..e0eb5a400 100644 --- a/src/main/java/cms/gov/madie/measure/repositories/MeasureRepository.java +++ b/src/main/java/cms/gov/madie/measure/repositories/MeasureRepository.java @@ -44,12 +44,12 @@ public interface MeasureRepository @Query(value = "{'groups._id': ?0}") Optional findGroupById(String groupId); - @Query( - " {$and: [{active : true} , " - + "{$or: [{'measureName' : { $regex : /\\Q?0\\E/, $options: 'i' } }," - + "{'ecqmTitle' : { $regex : /\\Q?0\\E/, $options: 'i' }}]} " - + "]}") - Page findAllByMeasureNameOrEcqmTitle(String criteria, Pageable page); + // @Query( + // " {$and: [{active : true} , " + // + "{$or: [{'measureName' : { $regex : /\\Q?0\\E/, $options: 'i' } }," + // + "{'ecqmTitle' : { $regex : /\\Q?0\\E/, $options: 'i' }}]} " + // + "]}") + // Page findAllByMeasureNameOrEcqmTitle(String criteria, Pageable page); boolean existsByMeasureSetIdAndActiveAndMeasureMetaDataDraft( String setId, boolean active, boolean draft); diff --git a/src/main/java/cms/gov/madie/measure/resources/MeasureController.java b/src/main/java/cms/gov/madie/measure/resources/MeasureController.java index b3075b0a7..e2e48aa7e 100644 --- a/src/main/java/cms/gov/madie/measure/resources/MeasureController.java +++ b/src/main/java/cms/gov/madie/measure/resources/MeasureController.java @@ -1,6 +1,7 @@ package cms.gov.madie.measure.resources; import cms.gov.madie.measure.dto.MeasureListDTO; +import cms.gov.madie.measure.dto.MeasureSearchCriteria; import cms.gov.madie.measure.exceptions.*; import cms.gov.madie.measure.repositories.MeasureRepository; import cms.gov.madie.measure.repositories.MeasureSetRepository; @@ -37,11 +38,7 @@ import org.springframework.web.bind.annotation.RestController; import jakarta.servlet.http.HttpServletRequest; - -import java.net.URLDecoder; -import java.nio.charset.StandardCharsets; import java.security.Principal; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; @@ -60,9 +57,8 @@ public class MeasureController { @GetMapping("/measures/draftstatus") public ResponseEntity> getDraftStatuses( - @RequestParam(required = true, name = "measureSetIds") List measureSetIds) { - Map results = new HashMap<>(); - results = measureService.getMeasureDrafts(measureSetIds); + @RequestParam(name = "measureSetIds") List measureSetIds) { + Map results = measureService.getMeasureDrafts(measureSetIds); return ResponseEntity.status(HttpStatus.CREATED).body(results); } @@ -291,22 +287,24 @@ public ResponseEntity deleteStratification( measureId, groupId, stratificationId, principal.getName())); } - @GetMapping("/measures/search") - public ResponseEntity> findAllByMeasureNameOrEcqmTitle( + @PutMapping("/measures/search") + public ResponseEntity> measureSearchByCriteria( Principal principal, @RequestParam(required = false, defaultValue = "false", name = "currentUser") boolean filterByCurrentUser, - @RequestParam(required = false, name = "query") String query, + @RequestBody(required = false) MeasureSearchCriteria searchCriteria, @RequestParam(required = false, defaultValue = "10", name = "limit") int limit, @RequestParam(required = false, defaultValue = "0", name = "page") int page) { - final String username = principal.getName(); final Pageable pageReq = PageRequest.of(page, limit, Sort.by("lastModifiedAt").descending()); - // We need to decode the encoded strings we send over or we can't find stuff - String decodedQuery = URLDecoder.decode(query, StandardCharsets.UTF_8); + // searchCriteria is an optional body, so initializing the obj to avoid any potential NPE + if (searchCriteria == null) { + searchCriteria = MeasureSearchCriteria.builder().build(); + } Page measures = - measureService.getMeasuresByCriteria(filterByCurrentUser, pageReq, username, decodedQuery); + measureService.getMeasuresByCriteria( + searchCriteria, filterByCurrentUser, pageReq, username); measures.map( measure -> { MeasureSet measureSet = diff --git a/src/main/java/cms/gov/madie/measure/services/MeasureService.java b/src/main/java/cms/gov/madie/measure/services/MeasureService.java index 3bb2d1db4..32eec697b 100644 --- a/src/main/java/cms/gov/madie/measure/services/MeasureService.java +++ b/src/main/java/cms/gov/madie/measure/services/MeasureService.java @@ -1,6 +1,7 @@ package cms.gov.madie.measure.services; import cms.gov.madie.measure.dto.MeasureListDTO; +import cms.gov.madie.measure.dto.MeasureSearchCriteria; import cms.gov.madie.measure.exceptions.*; import cms.gov.madie.measure.repositories.MeasureRepository; import cms.gov.madie.measure.repositories.MeasureSetRepository; @@ -23,6 +24,8 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.time.Instant; import java.time.LocalTime; @@ -310,9 +313,7 @@ private void updateMeasurementPeriods(Measure measure) { public Page getMeasures( boolean filterByCurrentUser, Pageable pageReq, String username) { - return filterByCurrentUser - ? measureRepository.findMyActiveMeasures(username, pageReq, null) - : measureRepository.findAllByActive(true, pageReq); + return measureRepository.findActiveMeasures(username, pageReq, null, filterByCurrentUser); } public void checkDuplicateCqlLibraryName(String cqlLibraryName) { @@ -431,10 +432,16 @@ public List getAllActiveMeasureIds(boolean draftOnly) { } public Page getMeasuresByCriteria( - boolean filterByCurrentUser, Pageable pageReq, String username, String criteria) { - return filterByCurrentUser - ? measureRepository.findMyActiveMeasures(username, pageReq, criteria) - : measureRepository.findAllByMeasureNameOrEcqmTitle(criteria, pageReq); + MeasureSearchCriteria searchCriteria, + boolean filterByCurrentUser, + Pageable pageReq, + String username) { + // We need to decode the encoded strings we send over or we can't find stuff + if (StringUtils.isNotBlank(searchCriteria.getQuery())) { + searchCriteria.setQuery(URLDecoder.decode(searchCriteria.getQuery(), StandardCharsets.UTF_8)); + } + return measureRepository.findActiveMeasures( + username, pageReq, searchCriteria, filterByCurrentUser); } protected void updateReferenceId(MeasureMetaData metaData) { diff --git a/src/test/java/cms/gov/madie/measure/repositories/MeasureAclRepositoryImplTest.java b/src/test/java/cms/gov/madie/measure/repositories/MeasureAclRepositoryImplTest.java index 99e3b8098..724bbc4ac 100644 --- a/src/test/java/cms/gov/madie/measure/repositories/MeasureAclRepositoryImplTest.java +++ b/src/test/java/cms/gov/madie/measure/repositories/MeasureAclRepositoryImplTest.java @@ -2,6 +2,7 @@ import cms.gov.madie.measure.dto.FacetDTO; import cms.gov.madie.measure.dto.MeasureListDTO; +import cms.gov.madie.measure.dto.MeasureSearchCriteria; import gov.cms.madie.models.dto.LibraryUsage; import org.bson.Document; @@ -69,7 +70,7 @@ public void testFindMyActiveMeasures() { .thenReturn(pagedResults); Page page = - measureAclRepository.findMyActiveMeasures("john", pageRequest, null); + measureAclRepository.findActiveMeasures("john", pageRequest, null, true); assertEquals(page.getTotalElements(), 5); assertEquals(page.getTotalPages(), 2); assertEquals(page.getContent().size(), 3); @@ -90,8 +91,10 @@ public void testFindMyActiveMeasuresWithSearchTerm() { when(mongoTemplate.aggregate(any(Aggregation.class), (Class) any(), any())) .thenReturn(pagedResults); + MeasureSearchCriteria measureSearchCriteria = + MeasureSearchCriteria.builder().query("test measure").build(); Page page = - measureAclRepository.findMyActiveMeasures("john", pageRequest, "test measure"); + measureAclRepository.findActiveMeasures("john", pageRequest, measureSearchCriteria, true); assertEquals(page.getTotalElements(), 2); assertEquals(page.getTotalPages(), 1); assertEquals(page.getContent().size(), 2); diff --git a/src/test/java/cms/gov/madie/measure/resources/MeasureControllerMvcTest.java b/src/test/java/cms/gov/madie/measure/resources/MeasureControllerMvcTest.java index 2e6b36efd..795e3adc4 100644 --- a/src/test/java/cms/gov/madie/measure/resources/MeasureControllerMvcTest.java +++ b/src/test/java/cms/gov/madie/measure/resources/MeasureControllerMvcTest.java @@ -32,6 +32,7 @@ import java.util.Set; import cms.gov.madie.measure.dto.MeasureListDTO; +import cms.gov.madie.measure.dto.MeasureSearchCriteria; import cms.gov.madie.measure.services.MeasureSetService; import gov.cms.madie.models.access.AclOperation; import gov.cms.madie.models.access.AclSpecification; @@ -104,6 +105,7 @@ public class MeasureControllerMvcTest { @Captor private ArgumentCaptor targetIdArgumentCaptor; @Captor private ArgumentCaptor performedByArgumentCaptor; + ObjectMapper objectMapper = new ObjectMapper(); private static final String MODEL = ModelType.QI_CORE.toString(); private static final String LIBRARY_NAME_VALIDATION_ERROR = @@ -1533,13 +1535,18 @@ public void testSearchMeasuresByMeasureNameOrEcqmTitleNoQueryParams() throws Exc doReturn(allMeasures) .when(measureService) - .getMeasuresByCriteria(eq(false), any(Pageable.class), eq(TEST_USER_ID), eq("measure")); + .getMeasuresByCriteria( + any(MeasureSearchCriteria.class), eq(false), any(Pageable.class), eq(TEST_USER_ID)); MvcResult result = mockMvc .perform( - get("/measures/search") + put("/measures/search") .with(user(TEST_USER_ID)) - .queryParam("query", "measure") + .with(csrf()) + .content( + objectMapper.writeValueAsString( + MeasureSearchCriteria.builder().query("measure").build())) + .contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andReturn(); @@ -1548,7 +1555,8 @@ public void testSearchMeasuresByMeasureNameOrEcqmTitleNoQueryParams() throws Exc assertTrue(resultStr.length() > 0); verify(measureService, times(1)) - .getMeasuresByCriteria(eq(false), any(Pageable.class), eq(TEST_USER_ID), eq("measure")); + .getMeasuresByCriteria( + any(MeasureSearchCriteria.class), eq(false), any(Pageable.class), eq(TEST_USER_ID)); verifyNoMoreInteractions(measureRepository); } @@ -1565,16 +1573,21 @@ public void testSearchMeasuresByMeasureNameOrEcqmTitleWithCurrentUserFalse() thr doReturn(allMeasures) .when(measureService) - .getMeasuresByCriteria(eq(false), any(Pageable.class), eq(TEST_USER_ID), eq("ecqm")); + .getMeasuresByCriteria( + any(MeasureSearchCriteria.class), eq(false), any(Pageable.class), eq(TEST_USER_ID)); MvcResult result = mockMvc .perform( - get("/measures/search") + put("/measures/search") .with(user(TEST_USER_ID)) - .queryParam("query", "ecqm") + .with(csrf()) .queryParam("currentUser", "false") .queryParam("limit", "8") .queryParam("page", "1") + .content( + objectMapper.writeValueAsString( + MeasureSearchCriteria.builder().query("ecqm").build())) + .contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andReturn(); @@ -1582,7 +1595,8 @@ public void testSearchMeasuresByMeasureNameOrEcqmTitleWithCurrentUserFalse() thr assertTrue(resultStr.length() > 0); verify(measureService, times(1)) - .getMeasuresByCriteria(eq(false), any(Pageable.class), eq(TEST_USER_ID), eq("ecqm")); + .getMeasuresByCriteria( + any(MeasureSearchCriteria.class), eq(false), any(Pageable.class), eq(TEST_USER_ID)); verifyNoMoreInteractions(measureRepository); } @@ -1599,16 +1613,21 @@ public void testSearchMeasuresByMeasureNameOrEcqmTitleFilterByCurrentUser() thro doReturn(measures) .when(measureService) - .getMeasuresByCriteria(eq(true), any(Pageable.class), eq(TEST_USER_ID), eq("measure")); + .getMeasuresByCriteria( + any(MeasureSearchCriteria.class), eq(true), any(Pageable.class), eq(TEST_USER_ID)); MvcResult result = mockMvc .perform( - get("/measures/search") + put("/measures/search") .with(user(TEST_USER_ID)) - .queryParam("query", "measure") + .with(csrf()) .queryParam("currentUser", "true") .queryParam("limit", "8") .queryParam("page", "1") + .content( + objectMapper.writeValueAsString( + MeasureSearchCriteria.builder().query("measure").build())) + .contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andReturn(); @@ -1616,7 +1635,8 @@ public void testSearchMeasuresByMeasureNameOrEcqmTitleFilterByCurrentUser() thro assertTrue(resultStr.length() > 0); verify(measureService, times(1)) - .getMeasuresByCriteria(eq(true), any(Pageable.class), eq(TEST_USER_ID), eq("measure")); + .getMeasuresByCriteria( + any(MeasureSearchCriteria.class), eq(true), any(Pageable.class), eq(TEST_USER_ID)); verifyNoMoreInteractions(measureRepository); } diff --git a/src/test/java/cms/gov/madie/measure/resources/MeasureControllerTest.java b/src/test/java/cms/gov/madie/measure/resources/MeasureControllerTest.java index f703bd120..6568aea9f 100644 --- a/src/test/java/cms/gov/madie/measure/resources/MeasureControllerTest.java +++ b/src/test/java/cms/gov/madie/measure/resources/MeasureControllerTest.java @@ -1,6 +1,7 @@ package cms.gov.madie.measure.resources; import cms.gov.madie.measure.dto.MeasureListDTO; +import cms.gov.madie.measure.dto.MeasureSearchCriteria; import cms.gov.madie.measure.exceptions.InvalidDraftStatusException; import cms.gov.madie.measure.exceptions.InvalidIdException; import cms.gov.madie.measure.exceptions.ResourceNotFoundException; @@ -28,8 +29,6 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.mock.web.MockHttpServletRequest; - -import java.io.UnsupportedEncodingException; import java.security.Principal; import java.time.Instant; import java.time.temporal.ChronoUnit; @@ -655,22 +654,24 @@ void updateGroup() { } @Test - void searchMeasuresByNameOrEcqmTitleWithoutCurrentUserFilter() - throws UnsupportedEncodingException { + void searchAllMeasuresByNameOrEcqmTitle() { Page measures = new PageImpl<>(List.of(measureList)); - doReturn(measures) - .when(measureService) - .getMeasuresByCriteria( - eq(false), any(Pageable.class), eq("test.user"), eq("test criteria")); Principal principal = mock(Principal.class); when(principal.getName()).thenReturn("test.user"); + doReturn(measures) + .when(measureService) + .getMeasuresByCriteria( + any(MeasureSearchCriteria.class), eq(false), any(Pageable.class), eq("test.user")); + + MeasureSearchCriteria measureSearchCriteria = + MeasureSearchCriteria.builder().query("test criteria").build(); ResponseEntity> response = - controller.findAllByMeasureNameOrEcqmTitle(principal, false, "test criteria", 10, 0); + controller.measureSearchByCriteria(principal, false, measureSearchCriteria, 10, 0); verify(measureService, times(1)) .getMeasuresByCriteria( - eq(false), any(Pageable.class), eq("test.user"), eq("test criteria")); + any(MeasureSearchCriteria.class), eq(false), any(Pageable.class), eq("test.user")); verifyNoMoreInteractions(repository); assertNotNull(response.getBody()); @@ -680,19 +681,25 @@ void searchMeasuresByNameOrEcqmTitleWithoutCurrentUserFilter() } @Test - void searchMeasuresByNameOrEcqmTitleWithCurrentUserFilter() { + void searchCurrentUsersMeasuresByNameOrEcqmTitle() { Page measures = new PageImpl<>(List.of(measureList)); - doReturn(measures) - .when(measureService) - .getMeasuresByCriteria(eq(true), any(Pageable.class), eq("test.user"), eq("test criteria")); Principal principal = mock(Principal.class); when(principal.getName()).thenReturn("test.user"); + doReturn(measures) + .when(measureService) + .getMeasuresByCriteria( + any(MeasureSearchCriteria.class), eq(true), any(Pageable.class), eq("test.user")); + + MeasureSearchCriteria measureSearchCriteria = + MeasureSearchCriteria.builder().query("test criteria").build(); ResponseEntity> response = - controller.findAllByMeasureNameOrEcqmTitle(principal, true, "test criteria", 10, 0); + controller.measureSearchByCriteria(principal, true, measureSearchCriteria, 10, 0); verify(measureService, times(1)) - .getMeasuresByCriteria(eq(true), any(Pageable.class), eq("test.user"), eq("test criteria")); + .getMeasuresByCriteria( + any(MeasureSearchCriteria.class), eq(true), any(Pageable.class), eq("test.user")); + verifyNoMoreInteractions(repository); assertNotNull(response.getBody().getContent()); assertNotNull(response.getBody().getContent().get(0)); diff --git a/src/test/java/cms/gov/madie/measure/services/MeasureServiceTest.java b/src/test/java/cms/gov/madie/measure/services/MeasureServiceTest.java index 4b203e403..f7966cd6e 100644 --- a/src/test/java/cms/gov/madie/measure/services/MeasureServiceTest.java +++ b/src/test/java/cms/gov/madie/measure/services/MeasureServiceTest.java @@ -35,6 +35,7 @@ import java.util.*; import cms.gov.madie.measure.dto.MeasureListDTO; +import cms.gov.madie.measure.dto.MeasureSearchCriteria; import cms.gov.madie.measure.exceptions.*; import cms.gov.madie.measure.repositories.MeasureSetRepository; import gov.cms.madie.models.dto.LibraryUsage; @@ -358,11 +359,14 @@ public void testGetMeasuresByCriteriaWithCurrentUser() { Page activeMeasures = new PageImpl<>(List.of(measure1)); + MeasureSearchCriteria measureSearchCriteria = + MeasureSearchCriteria.builder().query("test criteria").build(); doReturn(activeMeasures) .when(measureRepository) - .findMyActiveMeasures(eq("test.user"), any(PageRequest.class), eq("test criteria")); + .findActiveMeasures( + eq("test.user"), any(PageRequest.class), any(MeasureSearchCriteria.class), eq(true)); Object measures = - measureService.getMeasuresByCriteria(true, initialPage, "test.user", "test criteria"); + measureService.getMeasuresByCriteria(measureSearchCriteria, true, initialPage, "test.user"); assertNotNull(measures); } @@ -372,11 +376,15 @@ public void testGetMeasuresByCriteriaWithoutCurrentUser() { Page activeMeasures = new PageImpl<>(List.of(measure1)); + MeasureSearchCriteria measureSearchCriteria = + MeasureSearchCriteria.builder().query("test criteria").build(); doReturn(activeMeasures) .when(measureRepository) - .findAllByMeasureNameOrEcqmTitle(eq("test criteria"), any(PageRequest.class)); + .findActiveMeasures( + eq("test.user"), any(PageRequest.class), any(MeasureSearchCriteria.class), eq(false)); Object measures = - measureService.getMeasuresByCriteria(false, initialPage, "test.user", "test criteria"); + measureService.getMeasuresByCriteria( + measureSearchCriteria, false, initialPage, "test.user"); assertNotNull(measures); } @@ -388,8 +396,8 @@ public void testGetMeasures() { doReturn(activeMeasures) .when(measureRepository) - .findAllByActive(eq(true), any(PageRequest.class)); - Object measures = measureService.getMeasures(false, initialPage, null); + .findActiveMeasures(eq("test.user"), eq(initialPage), eq(null), eq(false)); + Object measures = measureService.getMeasures(false, initialPage, "test.user"); assertNotNull(measures); }