From 84486a945c4b3955f8c2364fbbcaf56f2aedffb2 Mon Sep 17 00:00:00 2001 From: Jamie Briggs Date: Mon, 20 Jan 2025 14:16:23 +0000 Subject: [PATCH 1/3] CCMSPUI-383: Implement EBS-API case search endpoint (#133) * CCMSPUI-383 Created CaseSearchRepository Signed-off-by: Jamie Briggs * CCMSPUI-383 Created mapper for CaseSearch and CaseDetails Signed-off-by: Jamie Briggs * CCMSPUI-383 Added filters to CaseSearchSpecification and added tests to test filter to CaseSearchRepositoryIntegerationTest Signed-off-by: Jamie Briggs * CCMSPUI-383 CaseSearchServiceTest Signed-off-by: Jamie Briggs * CCMSPUI-383 Refactor work to make provider ID required for the case search endpoint Signed-off-by: Jamie Briggs * CCMSPUI-383 Added javadocs and fixed checkstyle issues. Signed-off-by: Jamie Briggs * CCMSPUI-383 Modified endpoint to have required provider-id request param and updated tests to reflect this Signed-off-by: Jamie Briggs * CCMSPUI-383 Refactored CaseSearchRepository to use EntityManager instead to search for cases to return results quicker Signed-off-by: Jamie Briggs * CCMSPUI-383 Reverted ScopeLimitationServiceIntegrationTest Signed-off-by: Jamie Briggs * CCMSPUI-383 Fixed provider case reference mapping to use correct value from DB Signed-off-by: Jamie Briggs * CCMSPUI-383 Updated filter to filter by correct provider case reference column Signed-off-by: Jamie Briggs --------- Signed-off-by: Jamie Briggs --- data-api/open-api-specification.yml | 98 +++++ .../CaseSearchRepositoryIntegerationTest.java | 411 ++++++++++++++++++ ...NotificationRepositoryIntegrationTest.java | 30 +- .../ProceedingServiceIntegrationTest.java | 2 +- .../service/UserServiceIntegrationTest.java | 2 +- .../data/controller/CaseSearchController.java | 56 +++ .../controller/NotificationsController.java | 4 + .../gov/laa/ccms/data/entity/CaseSearch.java | 80 ++++ .../laa/ccms/data/entity/Notification.java | 4 +- .../ccms/data/mapper/CaseSearchMapper.java | 49 +++ .../ccms/data/mapper/NotificationsMapper.java | 8 +- .../data/repository/CaseSearchRepository.java | 124 ++++++ .../repository/NotificationRepository.java | 4 +- .../NotificationSpecification.java | 42 +- .../ccms/data/service/CaseSearchService.java | 50 +++ .../controller/CaseSearchControllerTest.java | 92 ++++ .../data/controller/LookupControllerTest.java | 22 +- .../PriorAuthorityControllerTest.java | 2 +- .../data/controller/UserControllerTest.java | 2 +- .../data/mapper/CaseSearchMapperImplTest.java | 107 +++++ .../data/service/CaseSearchServiceTest.java | 66 +++ .../ccms/data/service/LookupServiceTest.java | 38 +- .../data/service/NotificationServiceTest.java | 4 +- .../service/PriorAuthorityServiceTest.java | 2 +- .../data/service/ProceedingServiceTest.java | 5 +- .../service/ScopeLimitationServiceTest.java | 2 +- .../ccms/data/service/UserServiceTest.java | 2 +- 27 files changed, 1226 insertions(+), 82 deletions(-) create mode 100644 data-service/src/integrationTest/java/uk/gov/laa/ccms/data/repository/CaseSearchRepositoryIntegerationTest.java create mode 100644 data-service/src/main/java/uk/gov/laa/ccms/data/controller/CaseSearchController.java create mode 100644 data-service/src/main/java/uk/gov/laa/ccms/data/entity/CaseSearch.java create mode 100644 data-service/src/main/java/uk/gov/laa/ccms/data/mapper/CaseSearchMapper.java create mode 100644 data-service/src/main/java/uk/gov/laa/ccms/data/repository/CaseSearchRepository.java create mode 100644 data-service/src/main/java/uk/gov/laa/ccms/data/service/CaseSearchService.java create mode 100644 data-service/src/test/java/uk/gov/laa/ccms/data/controller/CaseSearchControllerTest.java create mode 100644 data-service/src/test/java/uk/gov/laa/ccms/data/mapper/CaseSearchMapperImplTest.java create mode 100644 data-service/src/test/java/uk/gov/laa/ccms/data/service/CaseSearchServiceTest.java diff --git a/data-api/open-api-specification.yml b/data-api/open-api-specification.yml index 863c668..37bacab 100644 --- a/data-api/open-api-specification.yml +++ b/data-api/open-api-specification.yml @@ -406,6 +406,70 @@ paths: description: 'Not found' '500': description: 'Internal server error' + /cases: + get: + tags: + - cases + summary: 'Get Cases' + operationId: 'getCases' + x-spring-paginated: true + parameters: + - name: 'provider-id' + in: 'query' + required: true + schema: + type: 'integer' + format: 'int64' + example: '123456789' + - name: 'case-reference-number' + in: 'query' + schema: + type: 'string' + example: '1234567890' + - name: 'provider-case-reference' + in: 'query' + schema: + type: 'string' + example: "1234567890" + - name: 'case-status' + in: 'query' + schema: + type: 'string' + example: 'APPL' + - name: 'client-surname' + in: 'query' + schema: + type: 'string' + example: 'smith' + - name: 'fee-earner-id' + in: 'query' + schema: + type: 'integer' + format: 'int64' + example: 1234567890 + - name: 'office-id' + in: 'query' + schema: + type: 'integer' + format: 'int64' + example: 1234567890 + responses: + '200': + description: 'Successful operation' + content: + application/json: + schema: + $ref: "#/components/schemas/caseDetails" + '400': + description: 'Bad request' + '401': + description: 'Unauthorized' + '403': + description: 'Forbidden' + '404': + description: 'Not found' + '500': + description: 'Internal server error' /lookup/case-status: get: tags: @@ -1369,6 +1433,15 @@ components: type: 'string' default_code: type: 'string' + baseClient: + type: 'object' + properties: + client_reference_number: + type: 'string' + first_name: + type: 'string' + surname: + type: 'string' clientInvolvementTypeLookupDetail: allOf: - $ref: "#/components/schemas/page" @@ -1490,6 +1563,31 @@ components: default: [] items: $ref: "#/components/schemas/evidenceDocumentTypeLookupValueDetail" + caseDetails: + allOf: + - $ref: "#/components/schemas/page" + type: 'object' + properties: + content: + type: 'array' + default: [ ] + items: + $ref: "#/components/schemas/caseSummary" + caseSummary: + type: 'object' + properties: + case_reference_number: + type: 'string' + provider_case_reference_number: + type: 'string' + client: + $ref: '#/components/schemas/baseClient' + fee_earner_name: + type: 'string' + category_of_law: + type: 'string' + case_status_display: + type: 'string' commonLookupValueDetail: type: 'object' properties: diff --git a/data-service/src/integrationTest/java/uk/gov/laa/ccms/data/repository/CaseSearchRepositoryIntegerationTest.java b/data-service/src/integrationTest/java/uk/gov/laa/ccms/data/repository/CaseSearchRepositoryIntegerationTest.java new file mode 100644 index 0000000..46e97bf --- /dev/null +++ b/data-service/src/integrationTest/java/uk/gov/laa/ccms/data/repository/CaseSearchRepositoryIntegerationTest.java @@ -0,0 +1,411 @@ +package uk.gov.laa.ccms.data.repository; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import jakarta.persistence.EntityManager; +import jakarta.persistence.PersistenceContext; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.test.context.ActiveProfiles; +import uk.gov.laa.ccms.data.entity.CaseSearch; + +@DataJpaTest +@ActiveProfiles("h2-test") +@DisplayName("Case Search Repository Integration Test") +class CaseSearchRepositoryIntegerationTest { + + private CaseSearchRepository caseSearchRepository; + + @PersistenceContext + private EntityManager entityManager; + + private CaseSearch s1; + private CaseSearch s2; + + @BeforeEach + void setUp() { + caseSearchRepository = new CaseSearchRepository(entityManager); + // Insert some test case search rows + s1 = CaseSearch.builder() + .providerFirmPartyId(100L) + .casePartyId(1001L) + .appOrCertSrId(2001L) + .lscCaseReference("3001") + .cisCaseReference("4001") + .clientPartyId(5001L) + .personFirstName("First") + .personLastName("Last") + .providerCaseReference("6001") + .providerOfficePartyId(8001L) + .feeEarnerPartyId(9001L) + .feeEarner("Fee One") + .categoryOfLaw("Category One") + .categoryOfLawDescription("Category One Description") + .actualCaseStatus("ONE") + .displayCaseStatus("Display Status One") + .build(); + s2 = CaseSearch.builder() + .providerFirmPartyId(100L) + .casePartyId(1002L) + .appOrCertSrId(2002L) + .lscCaseReference("3002") + .cisCaseReference("4002") + .clientPartyId(5002L) + .personFirstName("First Two") + .personLastName("Last Two") + .providerCaseReference("6002") + .providerOfficePartyId(8002L) + .feeEarnerPartyId(9002L) + .feeEarner("Fee Two") + .categoryOfLaw("Category Two") + .categoryOfLawDescription("Category Two Description") + .actualCaseStatus("TWO") + .displayCaseStatus("Display Status Two") + .build(); + // Persist both searchs + entityManager.persist(s1); + entityManager.persist(s2); + } + + @Test + @DisplayName("Should get all case search using provider ID") + void shouldGetAllCaseSearchRowsUsingProviderId() { + // Given + // When + Page result = caseSearchRepository.findAll(100L, + null, + null, + null, + null, + null, + null, + Pageable.ofSize(10).withPage(0)); + // Then + assertEquals(2, result.getTotalElements()); + assertTrue(result.getContent().contains(s1)); + assertTrue(result.getContent().contains(s2)); + } + + @Test + @DisplayName("Should contain correct pagination information") + void shouldContainCorrectPaginationInformation() { + // Given + // When + Page result = caseSearchRepository.findAll(100L, + null, + null, + null, + null, + null, + null, + Pageable.ofSize(1).withPage(0)); + // Then + assertTrue(result.getContent().contains(s1)); + assertEquals(2, result.getTotalElements()); + assertEquals(2, result.getTotalPages()); + assertEquals(1, result.getNumberOfElements()); + assertEquals(0, result.getNumber()); + } + + @Test + @DisplayName("Should find no cases when provider ID does not match") + void shouldFindNoCaseSearchRowsWhenProviderIdDoesNotMatch() { + // Given + // When + Page result = caseSearchRepository.findAll(200L, + "3001", + null, + null, + null, + null, + null, + Pageable.ofSize(10).withPage(0)); + // Then + assertEquals(0, result.getTotalElements()); + assertFalse(result.getContent().contains(s1)); + assertFalse(result.getContent().contains(s2)); + } + + @Test + @DisplayName("Should filter by case reference number") + void shouldFilterByCaseReferenceNumber() { + // Given + // When + Page result = caseSearchRepository.findAll(100L, + "3001", + null, + null, + null, + null, + null, + Pageable.ofSize(10).withPage(0)); + // Then + assertEquals(1, result.getTotalElements()); + assertTrue(result.getContent().contains(s1)); + assertFalse(result.getContent().contains(s2)); + } + + @Test + @DisplayName("Should filter like case reference number") + void shouldFilterLikeCaseReferenceNumber() { + // Given + // When + Page result = caseSearchRepository.findAll(100L, + "300", + null, + null, + null, + null, + null, + Pageable.ofSize(10).withPage(0)); + // Then + assertEquals(2, result.getTotalElements()); + assertTrue(result.getContent().contains(s1)); + assertTrue(result.getContent().contains(s2)); + } + + @Test + @DisplayName("Should filter by provider case reference number") + void shouldFilterByProviderCaseReferenceNumber() { + // Given + // When + Page result = caseSearchRepository.findAll(100L, + null, + "6001", + null, + null, + null, + null, + Pageable.ofSize(10).withPage(0)); + // Then + assertEquals(1, result.getTotalElements()); + assertTrue(result.getContent().contains(s1)); + assertFalse(result.getContent().contains(s2)); + } + + @Test + @DisplayName("Should filter like provider case reference number") + void shouldFilterLikeProviderCaseReferenceNumber() { + // Given + // When + Page result = caseSearchRepository.findAll(100L, + null, + "600", + null, + null, + null, + null, + Pageable.ofSize(10).withPage(0)); + // Then + assertEquals(2, result.getTotalElements()); + assertTrue(result.getContent().contains(s1)); + assertTrue(result.getContent().contains(s2)); + } + + @Test + @DisplayName("Should filter exactly status") + void shouldFilterExactlyStatus() { + // Given + // When + Page result = caseSearchRepository.findAll(100L, + null, + null, + "ONE", + null, + null, + null, + Pageable.ofSize(10).withPage(0)); + // Then + assertEquals(1, result.getTotalElements()); + assertTrue(result.getContent().contains(s1)); + assertFalse(result.getContent().contains(s2)); + } + + @Test + @DisplayName("Should filter exactly status two") + void shouldFilterExactlyStatusTwo() { + // Given + // When + Page result = caseSearchRepository.findAll(100L, + null, + null, + "TWO", + null, + null, + null, + Pageable.ofSize(10).withPage(0)); + // Then + assertEquals(1, result.getTotalElements()); + assertFalse(result.getContent().contains(s1)); + assertTrue(result.getContent().contains(s2)); + } + + @Test + @DisplayName("Should filter exactly status none") + void shouldFilterExactlyStatusNone() { + // Given + // When + Page result = caseSearchRepository.findAll(100L, + null, + null, + "ON", + null, + null, + null, + Pageable.ofSize(10).withPage(0)); + // Then + assertEquals(0, result.getTotalElements()); + assertFalse(result.getContent().contains(s1)); + assertFalse(result.getContent().contains(s2)); + } + + @Test + @DisplayName("Should filter by client surname") + void shouldFilterByClientSurname() { + // Given + // When + Page result = caseSearchRepository.findAll(100L, + null, + null, + null, + "Last Two", + null, + null, + Pageable.ofSize(10).withPage(0)); + // Then + assertEquals(1, result.getTotalElements()); + assertFalse(result.getContent().contains(s1)); + assertTrue(result.getContent().contains(s2)); + } + + @Test + @DisplayName("Should filter like client surname") + void shouldFilterLikeClientSurname() { + // Given + // When + Page result = caseSearchRepository.findAll(100L, + null, + null, + null, + "Last", + null, + null, + Pageable.ofSize(10).withPage(0)); + // Then + assertEquals(2, result.getTotalElements()); + assertTrue(result.getContent().contains(s1)); + assertTrue(result.getContent().contains(s2)); + } + + @Test + @DisplayName("Should filter like client surname ignore case") + void shouldFilterLikeClientSurnameIgnoreCase() { + // Given + // When + Page result = caseSearchRepository.findAll(100L, + null, + null, + null, + "LaSt twO", + null, + null, + Pageable.ofSize(10).withPage(0)); + // Then + assertEquals(1, result.getTotalElements()); + assertFalse(result.getContent().contains(s1)); + assertTrue(result.getContent().contains(s2)); + } + + @Test + @DisplayName("Should filter equal fee earner ID") + void shouldFilterEqualFeeEarnerId() { + // Given + // When + Page result = caseSearchRepository.findAll(100L, + null, + null, + null, + null, + 9001L, + null, + Pageable.ofSize(10).withPage(0)); + // Then + assertEquals(1, result.getTotalElements()); + assertTrue(result.getContent().contains(s1)); + assertFalse(result.getContent().contains(s2)); + } + + + @Test + @DisplayName("Should filter equal fee earner ID return none") + void shouldFilterEqualFeeEarnerIdReturnNone() { + // Given + // When + Page result = caseSearchRepository.findAll(100L, + null, + null, + null, + null, + 900L, + null, + Pageable.ofSize(10).withPage(0)); + // Then + assertEquals(0, result.getTotalElements()); + assertFalse(result.getContent().contains(s1)); + assertFalse(result.getContent().contains(s2)); + } + + + @Test + @DisplayName("Should filter equal fee earner ID") + void shouldFilterEqualOfficeId() { + // Given + // When + Page result = caseSearchRepository.findAll(100L, + null, + null, + null, + null, + null, + 8001L, + Pageable.ofSize(10).withPage(0)); + // Then + assertEquals(1, result.getTotalElements()); + assertTrue(result.getContent().contains(s1)); + assertFalse(result.getContent().contains(s2)); + } + + + @Test + @DisplayName("Should filter equal fee earner ID return none") + void shouldFilterEqualOfficeIdReturnNone() { + // Given + // When + Page result = caseSearchRepository.findAll(100L, + null, + null, + null, + null, + null, + 800L, + Pageable.ofSize(10).withPage(0)); + // Then + assertEquals(0, result.getTotalElements()); + assertFalse(result.getContent().contains(s1)); + assertFalse(result.getContent().contains(s2)); + } + + + @AfterEach + void afterEach() { + entityManager.remove(s1); + entityManager.remove(s2); + } +} diff --git a/data-service/src/integrationTest/java/uk/gov/laa/ccms/data/repository/NotificationRepositoryIntegrationTest.java b/data-service/src/integrationTest/java/uk/gov/laa/ccms/data/repository/NotificationRepositoryIntegrationTest.java index 31fdf0e..b9ddeac 100644 --- a/data-service/src/integrationTest/java/uk/gov/laa/ccms/data/repository/NotificationRepositoryIntegrationTest.java +++ b/data-service/src/integrationTest/java/uk/gov/laa/ccms/data/repository/NotificationRepositoryIntegrationTest.java @@ -20,7 +20,7 @@ @DataJpaTest @ActiveProfiles("h2-test") @DisplayName("Notification Repository Integration Test") -public class NotificationRepositoryIntegrationTest { +class NotificationRepositoryIntegrationTest { @Autowired private NotificationRepository notificationRepository; @@ -76,7 +76,7 @@ void shouldGetAllNotifications(){ null, null); // When - Page result = notificationRepository.findAll(spec, Pageable.unpaged()); + Page result = notificationRepository.findAll(spec, Pageable.ofSize(10).withPage(0)); // Then assertEquals(2, result.getTotalElements()); assertEquals(true, result.getContent().contains(n1)); @@ -98,7 +98,7 @@ void shouldFilterByCaseReferenceNumber(){ null, null); // When - Page result = notificationRepository.findAll(spec, Pageable.unpaged()); + Page result = notificationRepository.findAll(spec, Pageable.ofSize(10).withPage(0)); // Then assertEquals(1, result.getTotalElements()); assertEquals(true, result.getContent().contains(n1)); @@ -119,7 +119,7 @@ void shouldFilterBySimilarCaseReferenceNumber(){ null, null); // When - Page result = notificationRepository.findAll(spec, Pageable.unpaged()); + Page result = notificationRepository.findAll(spec, Pageable.ofSize(10).withPage(0)); // Then assertEquals(2, result.getTotalElements()); assertEquals(true, result.getContent().contains(n1)); @@ -141,7 +141,7 @@ void shouldFilterByProviderCaseReferenceNumber(){ null, null); // When - Page result = notificationRepository.findAll(spec, Pageable.unpaged()); + Page result = notificationRepository.findAll(spec, Pageable.ofSize(10).withPage(0)); // Then assertEquals(1, result.getTotalElements()); assertEquals(true, result.getContent().contains(n1)); @@ -162,7 +162,7 @@ void shouldFilterBySimilarProviderCaseReferenceNumber(){ null, null); // When - Page result = notificationRepository.findAll(spec, Pageable.unpaged()); + Page result = notificationRepository.findAll(spec, Pageable.ofSize(10).withPage(0)); // Then assertEquals(2, result.getTotalElements()); assertEquals(true, result.getContent().contains(n1)); @@ -184,7 +184,7 @@ void shouldFilterByAssignedToUserID(){ null, null); // When - Page result = notificationRepository.findAll(spec, Pageable.unpaged()); + Page result = notificationRepository.findAll(spec, Pageable.ofSize(10).withPage(0)); // Then assertEquals(1, result.getTotalElements()); assertEquals(true, result.getContent().contains(n1)); @@ -205,7 +205,7 @@ void shouldFilterByUserSurname(){ null, null); // When - Page result = notificationRepository.findAll(spec, Pageable.unpaged()); + Page result = notificationRepository.findAll(spec, Pageable.ofSize(10).withPage(0)); // Then assertEquals(1, result.getTotalElements()); assertEquals(true, result.getContent().contains(n1)); @@ -226,7 +226,7 @@ void shouldFilterByLikeUserSurname(){ null, null); // When - Page result = notificationRepository.findAll(spec, Pageable.unpaged()); + Page result = notificationRepository.findAll(spec, Pageable.ofSize(10).withPage(0)); // Then assertEquals(2, result.getTotalElements()); assertEquals(true, result.getContent().contains(n1)); @@ -248,7 +248,7 @@ void shouldFilterByFeeEarnerID(){ null, null); // When - Page result = notificationRepository.findAll(spec, Pageable.unpaged()); + Page result = notificationRepository.findAll(spec, Pageable.ofSize(10).withPage(0)); // Then assertEquals(1, result.getTotalElements()); assertEquals(true, result.getContent().contains(n1)); @@ -268,7 +268,7 @@ void shouldFilterByNotificationType(){ null, null); // When - Page result = notificationRepository.findAll(spec, Pageable.unpaged()); + Page result = notificationRepository.findAll(spec, Pageable.ofSize(10).withPage(0)); // Then assertEquals(1, result.getTotalElements()); assertEquals(true, result.getContent().contains(n1)); @@ -289,7 +289,7 @@ void shouldFilterByDateFrom(){ LocalDate.of(2025, 2, 1), null); // When - Page result = notificationRepository.findAll(spec, Pageable.unpaged()); + Page result = notificationRepository.findAll(spec, Pageable.ofSize(10).withPage(0)); // Then assertEquals(1, result.getTotalElements()); assertEquals(true, result.getContent().contains(n2)); @@ -310,7 +310,7 @@ void shouldFilterByDateFromInclusive(){ LocalDate.of(2024, 1, 1), null); // When - Page result = notificationRepository.findAll(spec, Pageable.unpaged()); + Page result = notificationRepository.findAll(spec, Pageable.ofSize(10).withPage(0)); // Then assertEquals(2, result.getTotalElements()); assertEquals(true, result.getContent().contains(n1)); @@ -332,7 +332,7 @@ void shouldFilterByDateTo(){ null, LocalDate.of(2025, 12, 1)); // When - Page result = notificationRepository.findAll(spec, Pageable.unpaged()); + Page result = notificationRepository.findAll(spec, Pageable.ofSize(10).withPage(0)); // Then assertEquals(1, result.getTotalElements()); assertEquals(true, result.getContent().contains(n1)); @@ -353,7 +353,7 @@ void shouldFilterByDateToInclusive(){ null, LocalDate.of(2026, 1, 1)); // When - Page result = notificationRepository.findAll(spec, Pageable.unpaged()); + Page result = notificationRepository.findAll(spec, Pageable.ofSize(10).withPage(0)); // Then assertEquals(2, result.getTotalElements()); assertEquals(true, result.getContent().contains(n1)); diff --git a/data-service/src/integrationTest/java/uk/gov/laa/ccms/data/service/ProceedingServiceIntegrationTest.java b/data-service/src/integrationTest/java/uk/gov/laa/ccms/data/service/ProceedingServiceIntegrationTest.java index 2e7463e..723f70e 100644 --- a/data-service/src/integrationTest/java/uk/gov/laa/ccms/data/service/ProceedingServiceIntegrationTest.java +++ b/data-service/src/integrationTest/java/uk/gov/laa/ccms/data/service/ProceedingServiceIntegrationTest.java @@ -71,7 +71,7 @@ public void testGetProceedings() { // Call the service method ProceedingDetails result = proceedingService.getProceedings( - categoryOfLawCode, null, null, null, Pageable.unpaged()); + categoryOfLawCode, null, null, null, Pageable.ofSize(10).withPage(0)); // Assert the proceeding assertNotNull(result); diff --git a/data-service/src/integrationTest/java/uk/gov/laa/ccms/data/service/UserServiceIntegrationTest.java b/data-service/src/integrationTest/java/uk/gov/laa/ccms/data/service/UserServiceIntegrationTest.java index c9dfdad..98ca673 100644 --- a/data-service/src/integrationTest/java/uk/gov/laa/ccms/data/service/UserServiceIntegrationTest.java +++ b/data-service/src/integrationTest/java/uk/gov/laa/ccms/data/service/UserServiceIntegrationTest.java @@ -86,7 +86,7 @@ public void testGetUser_noData(){ "11, 1", "12, 0"}) public void testGetUsers_returnsData(Integer providerId, int expectedElements){ - UserDetails userDetails = userService.getUsers(providerId, Pageable.unpaged()); + UserDetails userDetails = userService.getUsers(providerId, Pageable.ofSize(10).withPage(0)); assertNotNull(userDetails); assertEquals(expectedElements, userDetails.getTotalElements()); } diff --git a/data-service/src/main/java/uk/gov/laa/ccms/data/controller/CaseSearchController.java b/data-service/src/main/java/uk/gov/laa/ccms/data/controller/CaseSearchController.java new file mode 100644 index 0000000..03c879d --- /dev/null +++ b/data-service/src/main/java/uk/gov/laa/ccms/data/controller/CaseSearchController.java @@ -0,0 +1,56 @@ +package uk.gov.laa.ccms.data.controller; + +import java.util.Optional; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RestController; +import uk.gov.laa.ccms.data.api.CasesApi; +import uk.gov.laa.ccms.data.model.CaseDetails; +import uk.gov.laa.ccms.data.service.CaseSearchService; + +/** + * Controller class responsible for handling case search operations. + * + *

This controller serves as an interface to return requested case information. It + * delegates the business logic to the {@link CaseSearchService}.

+ * + *

This class implemented the {@CasesApi} interface and provides endpoints for retrieving + * case information.

+ * + * @see CaseDetails + * @see CaseSearchService + * @author Jamie Briggs + */ +@RestController +@RequiredArgsConstructor +public class CaseSearchController implements CasesApi { + + private final CaseSearchService caseSearchService; + + /** + * Retrieves a paginated list of case details based on the provided search criteria. + * + * @param providerFirmPartyId the unique identifier of the provider firm party. + * @param caseReferenceNumber the unique identifier of the case. + * @param providerCaseReference the reference provided by the external entity for the case. + * @param caseStatus the status of the case (e.g., pending, closed). + * @param clientSurname the surname of the client involved in the case. + * @param feeEarnerId the unique identifier for the corresponding fee earner. + * @param officeId the unique identifier of the office associated with the case. + * @param pageable the pagination details including page number and page size. + * @return a {@code ResponseEntity} containing the {@code CaseDetails} if found, + * or a {@code ResponseEntity} with a not found status if no cases match the criteria. + */ + @Override + public ResponseEntity getCases(Long providerFirmPartyId, String caseReferenceNumber, + String providerCaseReference, String caseStatus, String clientSurname, Long feeEarnerId, + Long officeId, Pageable pageable) { + Optional cases = + caseSearchService.getCases(providerFirmPartyId, caseReferenceNumber, + providerCaseReference, caseStatus, clientSurname, feeEarnerId, + officeId, pageable); + return cases.map(ResponseEntity::ok).orElse(ResponseEntity.notFound().build()); + + } +} diff --git a/data-service/src/main/java/uk/gov/laa/ccms/data/controller/NotificationsController.java b/data-service/src/main/java/uk/gov/laa/ccms/data/controller/NotificationsController.java index 9b27175..b7bc927 100644 --- a/data-service/src/main/java/uk/gov/laa/ccms/data/controller/NotificationsController.java +++ b/data-service/src/main/java/uk/gov/laa/ccms/data/controller/NotificationsController.java @@ -19,6 +19,10 @@ * *

This class implements the {@link NotificationsApi} interface and provides * endpoints for retrieving notification summaries for users. + * + * @see Notifications + * @see NotificationService + * @author Jamie Briggs */ @RestController @RequiredArgsConstructor diff --git a/data-service/src/main/java/uk/gov/laa/ccms/data/entity/CaseSearch.java b/data-service/src/main/java/uk/gov/laa/ccms/data/entity/CaseSearch.java new file mode 100644 index 0000000..00af552 --- /dev/null +++ b/data-service/src/main/java/uk/gov/laa/ccms/data/entity/CaseSearch.java @@ -0,0 +1,80 @@ +package uk.gov.laa.ccms.data.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import org.hibernate.annotations.Immutable; + +/** + * Represents a case search entity from the XXCCMS_CASE_SEARCH_V database view. + * + *

This entity captures various attributes associated with a legal case, + * such as case references, provider information, + * case status, and associated client information.

+ * + *

The class is immutable, and it's instances can be created using the builder pattern.

+ * + */ +@Entity +@Table(name = "XXCCMS_CASE_SEARCH_V") +@Getter +@Builder +@Immutable +@AllArgsConstructor +@RequiredArgsConstructor +public class CaseSearch { + + @Id + @Column(name = "CASE_PARTY_ID", nullable = false, precision = 15, scale = 0) + private long casePartyId; + + @Column(name = "APP_OR_CERT_SR_ID") + private Long appOrCertSrId; + + @Column(name = "LSC_CASE_REFERENCE", nullable = false, length = 360) + private String lscCaseReference; + + @Column(name = "CIS_CASE_REFERENCE", length = 150) + private String cisCaseReference; + + @Column(name = "CLIENT_PARTY_ID", precision = 15, scale = 0) + private Long clientPartyId; + + @Column(name = "PERSON_FIRST_NAME", length = 150) + private String personFirstName; + + @Column(name = "PERSON_LAST_NAME", length = 150) + private String personLastName; + + @Column(name = "PROVIDER_CASE_REFERENCE", length = 150) + private String providerCaseReference; + + @Column(name = "PROVIDER_FIRM_PARTY_ID", precision = 15, scale = 0) + private Long providerFirmPartyId; + + @Column(name = "PROVIDER_OFFICE_PARTY_ID", precision = 15, scale = 0) + private Long providerOfficePartyId; + + @Column(name = "FEE_EARNER_PARTY_ID", precision = 15, scale = 0) + private Long feeEarnerPartyId; + + @Column(name = "FEE_EARNER", length = 360) + private String feeEarner; + + @Column(name = "CATEGORY_OF_LAW", length = 150) + private String categoryOfLaw; + + @Column(name = "CATEGORY_OF_LAW_DESC", length = 80) + private String categoryOfLawDescription; + + @Column(name = "ACTUAL_CASE_STATUS", length = 30) + private String actualCaseStatus; + + @Column(name = "DISPLAY_CASE_STATUS", length = 150) + private String displayCaseStatus; +} diff --git a/data-service/src/main/java/uk/gov/laa/ccms/data/entity/Notification.java b/data-service/src/main/java/uk/gov/laa/ccms/data/entity/Notification.java index 56fa671..e00d535 100644 --- a/data-service/src/main/java/uk/gov/laa/ccms/data/entity/Notification.java +++ b/data-service/src/main/java/uk/gov/laa/ccms/data/entity/Notification.java @@ -13,11 +13,11 @@ import org.hibernate.annotations.Immutable; /** - * Represents a notification entity from the "XXCCMS_GET_NOTIFICATIONS_V" database view. + * Represents a notification entity from the XXCCMS_GET_NOTIFICATIONS_V database view. * *

This entity captures details about notifications, such as the user it is assigned to, * associated case references, client information, deadlines, and related metadata. - * It provides essential fields to track the status, associated parties, + * It provides essential fields to track the status, associated client, * supporting documents, and notes.

* *

The class is immutable, and its instances can be created using the builder pattern.

diff --git a/data-service/src/main/java/uk/gov/laa/ccms/data/mapper/CaseSearchMapper.java b/data-service/src/main/java/uk/gov/laa/ccms/data/mapper/CaseSearchMapper.java new file mode 100644 index 0000000..ff48cda --- /dev/null +++ b/data-service/src/main/java/uk/gov/laa/ccms/data/mapper/CaseSearchMapper.java @@ -0,0 +1,49 @@ +package uk.gov.laa.ccms.data.mapper; + +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.springframework.data.domain.Page; +import uk.gov.laa.ccms.data.entity.CaseSearch; +import uk.gov.laa.ccms.data.model.CaseDetails; +import uk.gov.laa.ccms.data.model.CaseSummary; + +/** + * Interface responsible for mapping {@link CaseSearch} objects to {@link CaseSummary}, or + * {@link CaseDetails} when paginated. This interface utilizes MapStruct for transformation. + * + * @see CaseSearch + * @see CaseDetails + * @see CaseSummary + * + * @author Jamie Briggs + */ +@Mapper(componentModel = "spring") +public interface CaseSearchMapper { + + /** + * Maps a {@link CaseSearch} object to a {@link CaseSummary} object. + * + * @param search the source {@link CaseSearch} object to be mapped. + * + * @return a {@link CaseSummary} object containing the mapped case. + */ + @Mapping(target = "caseReferenceNumber", source = "lscCaseReference") + @Mapping(target = "providerCaseReferenceNumber", source = "providerCaseReference") + @Mapping(target = "feeEarnerName", source = "feeEarner") + @Mapping(target = "caseStatusDisplay", source = "displayCaseStatus") + @Mapping(target = "categoryOfLaw", source = "categoryOfLawDescription") + @Mapping(target = "client.clientReferenceNumber", source = "clientPartyId") + @Mapping(target = "client.firstName", source = "personFirstName") + @Mapping(target = "client.surname", source = "personLastName") + CaseSummary toCaseSummary(CaseSearch search); + + /** + * Maps a {@link Page} of {@link CaseSearch} objects to a {@link CaseDetails} object. + * + * @param searchResults a {@link Page} containing {@link CaseSearch} entities to be mapped. + * + * @return a {@link CaseDetails} object containing the mapped case details along with pagination + * details. + */ + CaseDetails toCaseDetails(Page searchResults); +} diff --git a/data-service/src/main/java/uk/gov/laa/ccms/data/mapper/NotificationsMapper.java b/data-service/src/main/java/uk/gov/laa/ccms/data/mapper/NotificationsMapper.java index fa74434..f1fec3f 100644 --- a/data-service/src/main/java/uk/gov/laa/ccms/data/mapper/NotificationsMapper.java +++ b/data-service/src/main/java/uk/gov/laa/ccms/data/mapper/NotificationsMapper.java @@ -37,10 +37,10 @@ public interface NotificationsMapper { /** - * Maps a Page of Notification objects to a Notifications object. + * Maps a {@link Page} of {@link Notification} objects to a {@link Notifications} object. * - * @param notificationPage a Page containing Notification entities to be mapped - * @return a Notifications object containing the mapped notifications along + * @param notificationPage a {@link Page} containing {@link Notification} entities to be mapped + * @return a {@link Notifications} object containing the mapped notifications along * with pagination details */ Notifications mapToNotificationsList(Page notificationPage); @@ -49,7 +49,7 @@ public interface NotificationsMapper { * Maps a Notification object to a {@link uk.gov.laa.ccms.data.model.Notification} object. * * @param notification the source Notification object to be mapped - * @return the mapped uk.gov.laa.ccms.data.model.Notification object + * @return the mapped {@link uk.gov.laa.ccms.data.model.Notification} object */ @Mapping(target = "notes", source = "notes", qualifiedByName = "formatNotes") @Mapping(target = "uploadedDocuments", source = "uploadedDocuments", diff --git a/data-service/src/main/java/uk/gov/laa/ccms/data/repository/CaseSearchRepository.java b/data-service/src/main/java/uk/gov/laa/ccms/data/repository/CaseSearchRepository.java new file mode 100644 index 0000000..9233aa9 --- /dev/null +++ b/data-service/src/main/java/uk/gov/laa/ccms/data/repository/CaseSearchRepository.java @@ -0,0 +1,124 @@ +package uk.gov.laa.ccms.data.repository; + +import jakarta.persistence.EntityManager; +import jakarta.persistence.Query; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; +import uk.gov.laa.ccms.data.entity.CaseSearch; + +/** + * A repository class for performing search queries on {@link CaseSearch} entities. + * + *

This class utilizes a native SQL query to fetch filtered and paginated results + * from the XXCCMS_CASE_SEARCH_V database view. It combines filtering criteria such + * as provider firm party ID, case references, case status, client surname, fee earner ID, and + * provider office party ID to dynamically construct the query based on the passed parameters.

+ * + *

It relies on {@link EntityManager} to execute native SQL queries and doesn't use standard + * Spring Data repositories. All queries are read-only and do not modify the database state.

+ * + * @see Page + * @see CaseSearch + * @see EntityManager + * + * @author Jamie Briggs + */ +@Component +@RequiredArgsConstructor +public class CaseSearchRepository { + + private final EntityManager entityManager; + + /** + * Retrieves a paginated and filtered list of case search records based on the given parameters. + * + * @param providerFirmPartyId the unique identifier of the provider firm (mandatory) + * @param caseReferenceNumber the case reference number for filtering, can be partially matched + * @param providerCaseReference the reference number specific to the provider for filtering + * @param caseStatus the status of the case to filter by + * @param clientSurname the surname of the client to filter by; case-insensitive partial + * matches are allowed + * @param feeEarnerId the unique identifier of the associated fee earner to filter by + * @param officeId the unique identifier of the provider's office to filter by + * @param pageable the pagination and sorting information + * @return a paginated list of {@code CaseSearch} entities matching the filtering criteria + */ + @Transactional(readOnly = true) + public Page findAll(final long providerFirmPartyId, final String caseReferenceNumber, + final String providerCaseReference, final String caseStatus, final String clientSurname, + final Long feeEarnerId, final Long officeId, final Pageable pageable) { + + final String searchCaseQuery = + """ + SELECT * FROM XXCCMS_CASE_SEARCH_V + """ + + + getFilterSql(providerFirmPartyId, caseReferenceNumber, providerCaseReference, caseStatus, + clientSurname, feeEarnerId, officeId) + + + """ + OFFSET :offset ROWS FETCH NEXT :size ROWS ONLY + """; + + Query query = entityManager.createNativeQuery(searchCaseQuery, CaseSearch.class); + query.setHint("org.hibernate.readOnly", true); + query.setParameter("offset", pageable.getOffset()); + query.setParameter("size", pageable.getPageSize()); + + final String countCaseQuery = + """ + SELECT COUNT(*) FROM XXCCMS_CASE_SEARCH_V + """ + + getFilterSql(providerFirmPartyId, caseReferenceNumber, providerCaseReference, + caseStatus, clientSurname, feeEarnerId, officeId); + Query countQuery = entityManager.createNativeQuery(countCaseQuery); + + countQuery.setHint("org.hibernate.readOnly", true); + long total = ((Number) countQuery.getSingleResult()).longValue(); + + List resultList = query.getResultList(); + + return new PageImpl<>(resultList, pageable, total); + } + + private static String getFilterSql(long providerFirmPartyId, String caseReferenceNumber, + String providerCaseReference, String caseStatus, String clientSurname, Long feeEarnerId, + Long officeId) { + StringJoiner sj = new StringJoiner(" AND "); + // Provider firm party id + sj.add("WHERE PROVIDER_FIRM_PARTY_ID = " + providerFirmPartyId); + // Case reference number + if (!Objects.isNull(caseReferenceNumber) && !caseReferenceNumber.isBlank()) { + sj.add("LSC_CASE_REFERENCE LIKE '%" + caseReferenceNumber + "%'"); + } + // Provider case reference + if (!Objects.isNull(providerCaseReference) && !providerCaseReference.isBlank()) { + sj.add("UPPER(PROVIDER_CASE_REFERENCE) LIKE '%" + providerCaseReference.toUpperCase() + "%'"); + } + // Case status + if (!Objects.isNull(caseStatus) && !caseStatus.isBlank()) { + sj.add("ACTUAL_CASE_STATUS = '" + caseStatus + "'"); + } + // Surname + if (!Objects.isNull(clientSurname) && !clientSurname.isBlank()) { + sj.add("UPPER(PERSON_LAST_NAME) LIKE '%" + clientSurname.toUpperCase() + "%'"); + } + // Fee earner party ID + if (!Objects.isNull(feeEarnerId)) { + sj.add("FEE_EARNER_PARTY_ID = " + feeEarnerId); + } + // Provider office party ID + if (!Objects.isNull(officeId)) { + sj.add("PROVIDER_OFFICE_PARTY_ID = " + officeId); + } + return sj + " "; + } + +} diff --git a/data-service/src/main/java/uk/gov/laa/ccms/data/repository/NotificationRepository.java b/data-service/src/main/java/uk/gov/laa/ccms/data/repository/NotificationRepository.java index 06c342b..52efde8 100644 --- a/data-service/src/main/java/uk/gov/laa/ccms/data/repository/NotificationRepository.java +++ b/data-service/src/main/java/uk/gov/laa/ccms/data/repository/NotificationRepository.java @@ -11,13 +11,13 @@ *

This repository extends the {@link ReadOnlyRepository} interface, * it supports read-only operations for the {@link Notification} entity. * This repository also extends {@link JpaSpecificationExecutor}, which - * allows the use of ${@link org.springframework.data.jpa.domain.Specification} + * allows the use of {@link org.springframework.data.jpa.domain.Specification} * to filter easier.

* - * @author Jamie Briggs * @see Notification * @see ReadOnlyRepository * @see org.springframework.data.jpa.domain.Specification + * @author Jamie Briggs */ @Repository public interface NotificationRepository extends ReadOnlyRepository, diff --git a/data-service/src/main/java/uk/gov/laa/ccms/data/repository/specification/NotificationSpecification.java b/data-service/src/main/java/uk/gov/laa/ccms/data/repository/specification/NotificationSpecification.java index 1d7fc07..e9a59ec 100644 --- a/data-service/src/main/java/uk/gov/laa/ccms/data/repository/specification/NotificationSpecification.java +++ b/data-service/src/main/java/uk/gov/laa/ccms/data/repository/specification/NotificationSpecification.java @@ -4,6 +4,7 @@ import java.time.LocalDate; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import org.springframework.data.jpa.domain.Specification; import uk.gov.laa.ccms.data.entity.Notification; @@ -45,15 +46,17 @@ private NotificationSpecification() {} /** * Builds a {@link Specification} for filtering {@link Notification} entities based * on various criteria. The method dynamically constructs filter - * conditions for the provided filter parameters. + * conditions for the provided filter parameters. Multiple filters are combined using + * an AND logic. * - * @param caseReferenceNumber the case reference number to filter by (optional). - * @param providerCaseReference the provider case reference to filter by (optional). - * @param assignedToUserId the user ID assigned to the notification (optional). - * @param clientSurname the client's surname to filter by (optional). - * @param feeEarnerId the ID of the fee earner to filter by (optional). - * @param includeClosed a flag to include closed notifications in the result set. - * @param notificationType the type of notification to filter by (optional). + * @param caseReferenceNumber the case reference number to filter by (optional, partial match). + * @param providerCaseReference the provider case reference to filter + * by (optional, partial match). + * @param assignedToUserId the user ID assigned to the notification (optional, exact match). + * @param clientSurname the client's surname to filter by (optional, partial match). + * @param feeEarnerId the ID of the fee earner to filter by (optional, exact match). + * @param includeClosed a flag to include closed notifications in the result set (optional). + * @param notificationType the type of notification to filter by (optional, exact match). * @param dateFrom the starting date for filtering notifications by the date assigned (inclusive). * @param dateTo the ending date for filtering notifications by the date assigned (inclusive). * @return a {@link Specification} object encapsulating the @@ -69,39 +72,44 @@ public static Specification withFilters( List predicates = new ArrayList<>(); // Add predicates for each filter only if they are non-null - if (caseReferenceNumber != null && !caseReferenceNumber.isBlank()) { + if (stringNotEmpty(caseReferenceNumber)) { predicates.add(criteriaBuilder.like(root.get("lscCaseRefReference"), "%" + caseReferenceNumber + "%")); } - if (providerCaseReference != null && !providerCaseReference.isBlank()) { + if (stringNotEmpty(providerCaseReference)) { predicates.add(criteriaBuilder.like(root.get("providerCaseReference"), "%" + providerCaseReference + "%")); } - if (assignedToUserId != null && !assignedToUserId.isBlank()) { + if (Objects.nonNull(assignedToUserId)) { predicates.add(criteriaBuilder.equal(root.get("assignedTo"), assignedToUserId)); } - if (clientSurname != null && !clientSurname.isBlank()) { + if (stringNotEmpty(clientSurname)) { predicates.add(criteriaBuilder.like(root.get("personLastName"), "%" + clientSurname + "%")); } - if (feeEarnerId != null) { + if (Objects.nonNull(feeEarnerId)) { predicates.add(criteriaBuilder.equal(root.get("feeEarnerPartyId"), feeEarnerId)); } - if (!includeClosed) { + if (Boolean.FALSE.equals(includeClosed)) { predicates.add(criteriaBuilder.equal(root.get("isOpen"), "true")); } - if (notificationType != null && !notificationType.isBlank()) { + if (Objects.nonNull(notificationType)) { predicates.add(criteriaBuilder.equal(root.get("actionNotificationInd"), notificationType)); } - if (dateFrom != null) { + if (Objects.nonNull(dateFrom)) { predicates.add(criteriaBuilder.greaterThanOrEqualTo(root.get("dateAssigned"), dateFrom)); } - if (dateTo != null) { + if (Objects.nonNull(dateTo)) { predicates.add(criteriaBuilder.lessThanOrEqualTo(root.get("dateAssigned"), dateTo)); } // Combine all predicates with AND return criteriaBuilder.and(predicates.toArray(new Predicate[0])); }; + + } + + private static boolean stringNotEmpty(String caseReferenceNumber) { + return caseReferenceNumber != null && !caseReferenceNumber.isEmpty(); } diff --git a/data-service/src/main/java/uk/gov/laa/ccms/data/service/CaseSearchService.java b/data-service/src/main/java/uk/gov/laa/ccms/data/service/CaseSearchService.java new file mode 100644 index 0000000..1e735ec --- /dev/null +++ b/data-service/src/main/java/uk/gov/laa/ccms/data/service/CaseSearchService.java @@ -0,0 +1,50 @@ +package uk.gov.laa.ccms.data.service; + +import java.util.Optional; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import uk.gov.laa.ccms.data.entity.CaseSearch; +import uk.gov.laa.ccms.data.mapper.CaseSearchMapper; +import uk.gov.laa.ccms.data.model.CaseDetails; +import uk.gov.laa.ccms.data.repository.CaseSearchRepository; + +/** + * Service for performing search operations on case entities. + * + * @author Jamie Briggs + */ +@Service +@RequiredArgsConstructor +public class CaseSearchService { + + private final CaseSearchRepository caseSearchRepository; + private final CaseSearchMapper caseSearchMapper; + + + /** + * Retrieves case details based on the provided search criteria and pagination information. + * + * @param providerFirmPartyId the provider firm party ID to search for + * @param caseReferenceNumber the unique reference number of the case to search for + * @param providerCaseReference the case reference provided by the external provider + * @param caseStatus the status of the case (e.g., active, closed) + * @param clientSurname the surname of the client related to the case + * @param feeEarnerId the ID of the fee earner associated with the case + * @param officeId the ID of the office handling the case + * @param pageable the pagination information for retrieving a paged list of cases + * @return an {@link Optional} containing the matching {@link CaseDetails} or + * empty if no results are found + */ + public Optional getCases(long providerFirmPartyId, String caseReferenceNumber, + String providerCaseReference, String caseStatus, String clientSurname, Long feeEarnerId, + Long officeId, Pageable pageable) { + Page cases = caseSearchRepository.findAll(providerFirmPartyId, caseReferenceNumber, + providerCaseReference, caseStatus, clientSurname, feeEarnerId, officeId, + pageable); + CaseDetails caseDetails = caseSearchMapper.toCaseDetails(cases); + return Optional.ofNullable(caseDetails); + } + +} diff --git a/data-service/src/test/java/uk/gov/laa/ccms/data/controller/CaseSearchControllerTest.java b/data-service/src/test/java/uk/gov/laa/ccms/data/controller/CaseSearchControllerTest.java new file mode 100644 index 0000000..6482cfd --- /dev/null +++ b/data-service/src/test/java/uk/gov/laa/ccms/data/controller/CaseSearchControllerTest.java @@ -0,0 +1,92 @@ +package uk.gov.laa.ccms.data.controller; + +import static org.mockito.Mockito.when; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup; + +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.web.PageableHandlerMethodArgumentResolver; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.test.context.web.WebAppConfiguration; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.web.context.WebApplicationContext; +import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper; +import uk.gov.laa.ccms.data.model.CaseDetails; +import uk.gov.laa.ccms.data.model.CaseSummary; +import uk.gov.laa.ccms.data.service.CaseSearchService; + +@ExtendWith({SpringExtension.class}) +@ContextConfiguration +@WebAppConfiguration +@DisplayName("Case search controller test") +class CaseSearchControllerTest { + + @Mock + private CaseSearchService caseSearchService; + + @InjectMocks + private CaseSearchController caseSearchController; + + private MockMvc mockMvc; + + private ObjectMapper objectMapper; + + @Autowired + WebApplicationContext webApplicationContext; + + @BeforeEach + public void setup() { + mockMvc = standaloneSetup(caseSearchController) + .setCustomArgumentResolvers(new PageableHandlerMethodArgumentResolver()) + .build(); + objectMapper = new ObjectMapper(); + } + + @Test + @DisplayName("getCases: Returns data") + void getCases_returnsData() throws Exception { + // Given + CaseSummary caseSummary = new CaseSummary().caseReferenceNumber("123"); + CaseDetails caseDetails = new CaseDetails().addContentItem(caseSummary); + when(caseSearchService.getCases(Mockito.eq(123L), Mockito.any(), + Mockito.any(), Mockito.any(), Mockito.any(), + Mockito.any(), Mockito.any(), Mockito.any())) + .thenReturn(Optional.of(caseDetails)); + // Then + String jsonContent = objectMapper.writeValueAsString(caseDetails); + this.mockMvc.perform(get("/cases?provider-id=123")) + .andDo(print()) + .andExpect(status().isOk()) + .andExpect(content().json(jsonContent)); + } + + @Test + @DisplayName("getCases: Returns bad request") + void getCases_returnsBadRequest() throws Exception { + // Then + this.mockMvc.perform(get("/cases")) + .andDo(print()) + .andExpect(status().isBadRequest()); + } + + @Test + @DisplayName("getCases: Returns not found") + void getCases_returnsNotFound() throws Exception { + // Then + this.mockMvc.perform(get("/cases?provider-id=123")) + .andDo(print()) + .andExpect(status().isNotFound()); + } +} diff --git a/data-service/src/test/java/uk/gov/laa/ccms/data/controller/LookupControllerTest.java b/data-service/src/test/java/uk/gov/laa/ccms/data/controller/LookupControllerTest.java index 943e169..7449cfd 100644 --- a/data-service/src/test/java/uk/gov/laa/ccms/data/controller/LookupControllerTest.java +++ b/data-service/src/test/java/uk/gov/laa/ccms/data/controller/LookupControllerTest.java @@ -65,7 +65,7 @@ void getCommonValues_returnsCommonValuesList() { String type = "type"; String code = "code"; String desc = "desc"; - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); CommonLookupDetail expectedResponse = new CommonLookupDetail(); @@ -83,7 +83,7 @@ void getCommonValues_returnsCommonValuesList() { void getCaseStatusValues_returnsCaseStatusValuesList() { String code = "code"; Boolean copyAllowed = Boolean.TRUE; - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); CaseStatusLookupDetail expectedResponse = new CaseStatusLookupDetail(); @@ -100,7 +100,7 @@ void getCaseStatusValues_returnsCaseStatusValuesList() { @Test void getAmendmentTypeValues_returnAmendmentTypeValuesList(){ String code = "code"; - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); AmendmentTypeLookupDetail expectedResponse = new AmendmentTypeLookupDetail(); @@ -117,7 +117,7 @@ void getAmendmentTypeValues_returnAmendmentTypeValuesList(){ @Test void getCountriesValues_returnsCommonValuesList() { String code = "country_code"; - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); CommonLookupDetail expectedResponse = new CommonLookupDetail(); @@ -134,7 +134,7 @@ void getCountriesValues_returnsCommonValuesList() { void getOutcomeResultValues_returnsOutcomeResultValuesList() { String code = "code"; String result = "result"; - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); OutcomeResultLookupDetail expectedResponse = new OutcomeResultLookupDetail(); @@ -152,7 +152,7 @@ void getOutcomeResultValues_returnsOutcomeResultValuesList() { void getStageEndValues_returnsStageEndValuesList() { String code = "code"; String stageEnd = "stageEnd"; - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); StageEndLookupDetail expectedResponse = new StageEndLookupDetail(); @@ -170,7 +170,7 @@ void getStageEndValues_returnsStageEndValuesList() { void getPersonToCaseRelationshipLookupValues() { String code = "code"; String description = "description"; - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); RelationshipToCaseLookupDetail expectedResponse = new RelationshipToCaseLookupDetail(); @@ -188,7 +188,7 @@ void getPersonToCaseRelationshipLookupValues() { void getAwardTypeValues_returnsAwardTypeValuesList() { String code = "code"; String awardType = "awardType"; - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); AwardTypeLookupDetail expectedResponse = new AwardTypeLookupDetail(); @@ -206,7 +206,7 @@ void getAwardTypeValues_returnsAwardTypeValuesList() { void getOrganisationToCaseRelationshipLookupValues() { String code = "code"; String description = "description"; - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); RelationshipToCaseLookupDetail expectedResponse = new RelationshipToCaseLookupDetail(); @@ -226,7 +226,7 @@ void getCategoryOfLawValues_returnsCategoryOfLawValuesList() { String desc = "desc"; Boolean copyCostLimit = Boolean.TRUE; - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); CategoryOfLawLookupDetail expectedResponse = new CategoryOfLawLookupDetail(); @@ -319,7 +319,7 @@ void getEvidenceDocumentTypeLookupValues_returnsData() throws Exception { @Test void getAssessmentSummaryAttributes_returnsData() throws Exception { String summaryType = "summaryType"; - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); AssessmentSummaryEntityLookupDetail expectedResponse = new AssessmentSummaryEntityLookupDetail(); diff --git a/data-service/src/test/java/uk/gov/laa/ccms/data/controller/PriorAuthorityControllerTest.java b/data-service/src/test/java/uk/gov/laa/ccms/data/controller/PriorAuthorityControllerTest.java index 5726a11..0720e1e 100644 --- a/data-service/src/test/java/uk/gov/laa/ccms/data/controller/PriorAuthorityControllerTest.java +++ b/data-service/src/test/java/uk/gov/laa/ccms/data/controller/PriorAuthorityControllerTest.java @@ -27,7 +27,7 @@ class PriorAuthorityControllerTest { void getPriorAuthorityTypes_returnsData() { String code = "code"; Boolean valueRequired = Boolean.TRUE; - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); PriorAuthorityTypeDetails expectedResponse = new PriorAuthorityTypeDetails(); diff --git a/data-service/src/test/java/uk/gov/laa/ccms/data/controller/UserControllerTest.java b/data-service/src/test/java/uk/gov/laa/ccms/data/controller/UserControllerTest.java index 7723189..0444b7d 100644 --- a/data-service/src/test/java/uk/gov/laa/ccms/data/controller/UserControllerTest.java +++ b/data-service/src/test/java/uk/gov/laa/ccms/data/controller/UserControllerTest.java @@ -79,7 +79,7 @@ public void getUser_notFound() throws Exception{ @Test void getUsers_returnsData() { Integer providerId = 123; - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); UserDetails expectedResponse = new UserDetails(); diff --git a/data-service/src/test/java/uk/gov/laa/ccms/data/mapper/CaseSearchMapperImplTest.java b/data-service/src/test/java/uk/gov/laa/ccms/data/mapper/CaseSearchMapperImplTest.java new file mode 100644 index 0000000..a372ec3 --- /dev/null +++ b/data-service/src/test/java/uk/gov/laa/ccms/data/mapper/CaseSearchMapperImplTest.java @@ -0,0 +1,107 @@ +package uk.gov.laa.ccms.data.mapper; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import uk.gov.laa.ccms.data.entity.CaseSearch; +import uk.gov.laa.ccms.data.model.BaseClient; +import uk.gov.laa.ccms.data.model.CaseDetails; +import uk.gov.laa.ccms.data.model.CaseSummary; + +@DisplayName( "Case search mapper implementation test") +class CaseSearchMapperImplTest { + + CaseSearchMapper mapper = new CaseSearchMapperImpl(); + + @Test + @DisplayName("Should map empty case search") + void shouldMapEmptyCaseSearch(){ + // Given + CaseSearch search = new CaseSearch(); + // When + CaseSummary result = mapper.toCaseSummary(search); + // Then + assertNotNull(result); + } + + @Test + @DisplayName("Should map case search details") + void shouldMapCaseSearchDetails(){ + // Given + CaseSearch search = getCaseOne(); + // When + CaseSummary result = mapper.toCaseSummary(search); + // Then + assertEquals("3", result.getCaseReferenceNumber()); + assertEquals("provCaseRef", result.getProviderCaseReferenceNumber()); + assertEquals("Fee Earner Name", result.getFeeEarnerName()); + assertEquals("Category Description", result.getCategoryOfLaw()); + assertEquals("Display Status", result.getCaseStatusDisplay()); + BaseClient resultClient = result.getClient(); + assertEquals("First", resultClient.getFirstName()); + assertEquals("5", resultClient.getClientReferenceNumber()); + assertEquals("Last", resultClient.getSurname()); + } + + @Test + @DisplayName("Should map case search pageable object") + void shouldMapCaseSearchPageableObject(){ + // Given + CaseSearch search = getCaseOne(); + CaseSearch searchTwo = getCaseTwo(); + Page pageable = new PageImpl<>(java.util.List.of(search, searchTwo)); + // When + CaseDetails details = mapper.toCaseDetails(pageable); + CaseSummary expectedOne = mapper.toCaseSummary(search); + CaseSummary expectedTwo = mapper.toCaseSummary(searchTwo); + // Then + assertEquals(2, details.getTotalElements()); + assertEquals(expectedOne, details.getContent().get(0)); + assertEquals(expectedTwo, details.getContent().get(1)); + } + + private static CaseSearch getCaseOne() { + return CaseSearch.builder() + .casePartyId(1L) + .appOrCertSrId(2L) + .lscCaseReference("3") + .cisCaseReference("4") + .clientPartyId(5L) + .personFirstName("First") + .personLastName("Last") + .providerCaseReference("provCaseRef") + .providerFirmPartyId(7L) + .feeEarnerPartyId(8L) + .feeEarner("Fee Earner Name") + .categoryOfLaw("CAT") + .categoryOfLawDescription("Category Description") + .actualCaseStatus("Actual Status") + .displayCaseStatus("Display Status") + .build(); + } + + private static CaseSearch getCaseTwo() { + return CaseSearch.builder() + .casePartyId(10L) + .appOrCertSrId(20L) + .lscCaseReference("30") + .cisCaseReference("40") + .clientPartyId(50L) + .personFirstName("First Two") + .personLastName("Last Two") + .providerCaseReference("provCaseRef Two") + .providerFirmPartyId(70L) + .feeEarnerPartyId(80L) + .feeEarner("Fee Earner Name Two") + .categoryOfLaw("CAT2") + .categoryOfLawDescription("Category Description Two") + .actualCaseStatus("Actual Status Two") + .displayCaseStatus("Display Status Two") + .build(); + } + +} diff --git a/data-service/src/test/java/uk/gov/laa/ccms/data/service/CaseSearchServiceTest.java b/data-service/src/test/java/uk/gov/laa/ccms/data/service/CaseSearchServiceTest.java new file mode 100644 index 0000000..58cccc9 --- /dev/null +++ b/data-service/src/test/java/uk/gov/laa/ccms/data/service/CaseSearchServiceTest.java @@ -0,0 +1,66 @@ +package uk.gov.laa.ccms.data.service; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.Mockito.when; + +import java.util.List; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import uk.gov.laa.ccms.data.entity.CaseSearch; +import uk.gov.laa.ccms.data.mapper.CaseSearchMapperImpl; +import uk.gov.laa.ccms.data.model.CaseDetails; +import uk.gov.laa.ccms.data.repository.CaseSearchRepository; + +@ExtendWith(MockitoExtension.class) +@DisplayName("Case search service test") +class CaseSearchServiceTest { + + @Mock + private CaseSearchRepository caseSearchRepository; + + private CaseSearchService caseSearchService; + + @BeforeEach + void setup(){ + caseSearchService = new CaseSearchService(caseSearchRepository, new CaseSearchMapperImpl()); + } + + @Test + @DisplayName("Should return CaseSummary object") + void shouldReturnCaseSummaryObject(){ + // Given + new CaseSearch(); + when(caseSearchRepository.findAll(anyLong(), + any(), + any(), + any(), + any(), + any(), + any(), + any(Pageable.class))).thenReturn(new PageImpl<>(List.of( + CaseSearch.builder().lscCaseReference("123").build()))); + // When + Optional cases = caseSearchService.getCases(1L, "123", + "345", + "ACT", + "Surname", + 1L, + 2L, + PageRequest.of(1, 10)); + // Then + assertTrue(cases.isPresent()); + assertEquals("123", cases.get().getContent().getFirst().getCaseReferenceNumber()); + } + +} diff --git a/data-service/src/test/java/uk/gov/laa/ccms/data/service/LookupServiceTest.java b/data-service/src/test/java/uk/gov/laa/ccms/data/service/LookupServiceTest.java index e912a10..f7672e5 100644 --- a/data-service/src/test/java/uk/gov/laa/ccms/data/service/LookupServiceTest.java +++ b/data-service/src/test/java/uk/gov/laa/ccms/data/service/LookupServiceTest.java @@ -159,7 +159,7 @@ void getCommonValues_returnsPageOfCommonValues() { commonLookupValue.setType("type"); commonLookupValue.setDescription("desc"); Example example = Example.of(commonLookupValue); - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); Page expectedPage = new PageImpl<>( Collections.singletonList(commonLookupValue)); CommonLookupDetail expectedResponse = new CommonLookupDetail(); @@ -193,7 +193,7 @@ void getCommonValuesStartsWithWildcard_createsEndsWithMatcher() { Example wildcardExample = Example.of(exampleLookupValue, wildcardMatcher); - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); Page expectedPage = new PageImpl<>( Collections.singletonList(commonLookupValue)); CommonLookupDetail expectedResponse = new CommonLookupDetail(); @@ -228,7 +228,7 @@ void getCommonValuesEndsWithWildcard_returnsStartsWithMatcher() { Example wildcardExample = Example.of(exampleLookupValue, wildcardMatcher); - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); Page expectedPage = new PageImpl<>( Collections.singletonList(commonLookupValue)); CommonLookupDetail expectedResponse = new CommonLookupDetail(); @@ -265,7 +265,7 @@ void getCommonValuesBookendWildcard_returnsContainsMatcher() { Example wildcardExample = Example.of(exampleLookupValue, wildcardMatcher); - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); Page expectedPage = new PageImpl<>( Collections.singletonList(commonLookupValue)); CommonLookupDetail expectedResponse = new CommonLookupDetail(); @@ -289,7 +289,7 @@ void getCaseStatusValues_returnsPageOfCaseStatusValues() { caseStatusLookupValue.setCode("code"); caseStatusLookupValue.setCopyAllowed(Boolean.TRUE); Example example = Example.of(caseStatusLookupValue); - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); Page expectedPage = new PageImpl<>(Collections.singletonList(caseStatusLookupValue)); CaseStatusLookupDetail expectedResponse = new CaseStatusLookupDetail(); @@ -308,7 +308,7 @@ void getAmendmentTypesValues_returnsPageOfAmendmentTypeValues() { amendmentTypeLookupValue.setApplicationTypeCode("apptype"); Example example = Example.of(amendmentTypeLookupValue); - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); Page expectedPage = new PageImpl<>(Collections.singletonList( amendmentTypeLookupValue)); AmendmentTypeLookupDetail expectedResponse = new AmendmentTypeLookupDetail(); @@ -328,7 +328,7 @@ void getCountryValues_returnsPageOfCountryValues() { CountryLookupValue countryLookupValue = new CountryLookupValue(); countryLookupValue.setCode("code"); Example example = Example.of(countryLookupValue); - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); Page expectedPage = new PageImpl<>( Collections.singletonList(countryLookupValue)); CommonLookupDetail expectedResponse = new CommonLookupDetail(); @@ -350,7 +350,7 @@ void getOutcomeResultValues_returnsPageOfValues() { outcomeResultLookupValue.getId().setProceedingCode("code"); outcomeResultLookupValue.getId().setOutcomeResult("result"); Example example = Example.of(outcomeResultLookupValue); - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); Page expectedPage = new PageImpl<>( Collections.singletonList(outcomeResultLookupValue)); OutcomeResultLookupDetail expectedResponse = new OutcomeResultLookupDetail(); @@ -375,7 +375,7 @@ void getStageEndValues_returnsPageOfValues() { stageEndLookupValue.getId().setProceedingCode("code"); stageEndLookupValue.getId().setStageEnd("stageEnd"); Example example = Example.of(stageEndLookupValue); - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); Page expectedPage = new PageImpl<>( Collections.singletonList(stageEndLookupValue)); StageEndLookupDetail expectedResponse = new StageEndLookupDetail(); @@ -399,7 +399,7 @@ void getPersonToCaseRelationshipValues_returnsPageOfValues() { personRelationshipToCaseLookupValue.setCode("code"); personRelationshipToCaseLookupValue.setDescription("description"); Example example = Example.of(personRelationshipToCaseLookupValue); - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); Page expectedPage = new PageImpl<>( Collections.singletonList(personRelationshipToCaseLookupValue)); RelationshipToCaseLookupDetail expectedResponse = new RelationshipToCaseLookupDetail(); @@ -423,7 +423,7 @@ void getOrganisationToCaseRelationshipValues_returnsPageOfValues() { organisationRelationshipToCaseLookupValue.setCode("code"); organisationRelationshipToCaseLookupValue.setDescription("description"); Example example = Example.of(organisationRelationshipToCaseLookupValue); - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); Page expectedPage = new PageImpl<>( Collections.singletonList(organisationRelationshipToCaseLookupValue)); RelationshipToCaseLookupDetail expectedResponse = new RelationshipToCaseLookupDetail(); @@ -448,7 +448,7 @@ void getAwardTypeValues_returnsPageOfValues() { awardTypeLookupValue.setCode("code"); awardTypeLookupValue.setAwardType("awardType"); Example example = Example.of(awardTypeLookupValue); - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); Page expectedPage = new PageImpl<>( Collections.singletonList(awardTypeLookupValue)); AwardTypeLookupDetail expectedResponse = new AwardTypeLookupDetail(); @@ -474,7 +474,7 @@ void getCategoryOfLawValues_returnsPageOfValues() { categoryOfLawLookupValue.setCopyCostLimit(Boolean.TRUE); Example example = Example.of(categoryOfLawLookupValue); - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); Page expectedPage = new PageImpl<>( Collections.singletonList(categoryOfLawLookupValue)); CategoryOfLawLookupDetail expectedResponse = new CategoryOfLawLookupDetail(); @@ -498,7 +498,7 @@ void getMatterTypeLookupValues_returnsPageOfMatterTypeValues() { String description = "desc"; String matterType = "MAT1"; String categoryOfLaw = "CAT1"; - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); MatterType matterTypeEntity = new MatterType(); matterTypeEntity.setDescription(description); @@ -522,7 +522,7 @@ void getMatterTypeLookupValues_returnsPageOfMatterTypeValues() { void getClientInvolvementTypeLookupValues_returnsPageOfClientInvolvementTypeValues() { String proceedingCode = "PRO1"; String clientInvolvementType = "INV1"; - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); ProceedingClientInvolvementType proceedingClientInvolvementTypeEntity = new ProceedingClientInvolvementType(); proceedingClientInvolvementTypeEntity.setId(new ProceedingClientInvolvementTypeId()); @@ -547,7 +547,7 @@ void getLevelOfServiceLookupValues_returnsPageOfLevelOfServiceValues() { String proceedingCode = "PRO1"; String matterType = "MAT1"; String categoryOfLaw = "CAT1"; - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); LevelOfServiceId levelOfServiceId = new LevelOfServiceId(); levelOfServiceId.setMatterType(matterType); @@ -574,7 +574,7 @@ void getLevelOfServiceLookupValues_returnsPageOfLevelOfServiceValues() { void getEvidenceDocumentTypeLookupValues_returnsPageOEvidenceDocumentTypeValues() { String type = "atype"; String code = "code1"; - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); EvidenceDocumentTypeLookupValueId lookupValueId = new EvidenceDocumentTypeLookupValueId(); @@ -680,7 +680,7 @@ private AssessmentSummaryEntity createAssessmentSummaryEntity(int entityLevel) { void getDeclarationLookupValues_returnsPageOfDeclarationValues() { String declarationType = "type1"; String billType = "bill1"; - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); Declaration declaration = new Declaration(); declaration.setDeclarationType(declarationType); @@ -702,7 +702,7 @@ void getDeclarationLookupValues_returnsPageOfDeclarationValues() { void getProviderRequestTypeLookupValues_returnsPageOfProviderRequestTypeValues() { Boolean isCaseRelated = Boolean.TRUE; String type = "providerType"; - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); ProviderRequestType example = new ProviderRequestType(); example.setCaseRelated(isCaseRelated); diff --git a/data-service/src/test/java/uk/gov/laa/ccms/data/service/NotificationServiceTest.java b/data-service/src/test/java/uk/gov/laa/ccms/data/service/NotificationServiceTest.java index 53dcc80..c2b6f67 100644 --- a/data-service/src/test/java/uk/gov/laa/ccms/data/service/NotificationServiceTest.java +++ b/data-service/src/test/java/uk/gov/laa/ccms/data/service/NotificationServiceTest.java @@ -103,7 +103,7 @@ void getNotifications_returnsData() { true, "type", LocalDate.of(2000, 1, 1), - LocalDate.of(2024, 1 ,1), Pageable.unpaged()); + LocalDate.of(2024, 1 ,1), Pageable.ofSize(10).withPage(0)); // Then assertTrue(result.isPresent()); assertEquals(expected, result.get()); @@ -123,7 +123,7 @@ void getNotifications_noDataFound() { true, "type", LocalDate.of(2000, 1, 1), - LocalDate.of(2024, 1 ,1), Pageable.unpaged()); + LocalDate.of(2024, 1 ,1), Pageable.ofSize(10).withPage(0)); // Then assertFalse(result.isPresent()); } diff --git a/data-service/src/test/java/uk/gov/laa/ccms/data/service/PriorAuthorityServiceTest.java b/data-service/src/test/java/uk/gov/laa/ccms/data/service/PriorAuthorityServiceTest.java index 7bc88db..693ffc3 100644 --- a/data-service/src/test/java/uk/gov/laa/ccms/data/service/PriorAuthorityServiceTest.java +++ b/data-service/src/test/java/uk/gov/laa/ccms/data/service/PriorAuthorityServiceTest.java @@ -41,7 +41,7 @@ void getPriorAuthorityTypes_returnsData() { exampleType.setValueRequired(priorAuthorityType.getValueRequired()); Example example = Example.of(exampleType); - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); Page expectedPage = new PageImpl<>( Collections.singletonList(priorAuthorityType)); PriorAuthorityTypeDetails expectedResponse = new PriorAuthorityTypeDetails(); diff --git a/data-service/src/test/java/uk/gov/laa/ccms/data/service/ProceedingServiceTest.java b/data-service/src/test/java/uk/gov/laa/ccms/data/service/ProceedingServiceTest.java index d0ddc45..281d2d0 100644 --- a/data-service/src/test/java/uk/gov/laa/ccms/data/service/ProceedingServiceTest.java +++ b/data-service/src/test/java/uk/gov/laa/ccms/data/service/ProceedingServiceTest.java @@ -8,7 +8,6 @@ import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.when; -import java.util.ArrayList; import java.util.Collections; import java.util.Optional; import org.junit.jupiter.api.Test; @@ -76,7 +75,7 @@ void getProceeding_handlesNotFound() { void getProceedings_returnsPageOfProceeding() { Proceeding proceeding = buildProceeding(); Example example = Example.of(proceeding); - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); Page expectedPage = new PageImpl<>( Collections.singletonList(proceeding)); ProceedingDetails expectedResponse = new ProceedingDetails(); @@ -113,7 +112,7 @@ void getLeadProceedings_returnsPageOfLeadProceeding( String categoryOfLaw = "CAT1"; String matterType = "MAT1"; String appOrCertType = "APP1"; - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); Proceeding proceeding = new Proceeding(); proceeding.setCategoryOfLawCode(categoryOfLaw); diff --git a/data-service/src/test/java/uk/gov/laa/ccms/data/service/ScopeLimitationServiceTest.java b/data-service/src/test/java/uk/gov/laa/ccms/data/service/ScopeLimitationServiceTest.java index 04171b3..2dad420 100644 --- a/data-service/src/test/java/uk/gov/laa/ccms/data/service/ScopeLimitationServiceTest.java +++ b/data-service/src/test/java/uk/gov/laa/ccms/data/service/ScopeLimitationServiceTest.java @@ -44,7 +44,7 @@ void getScopeLimitations_returnsData() { scopeLimitation.getId().setCategoryOfLawCode(scopeLimitationDetail.getCategoryOfLaw()); Example example = Example.of(scopeLimitation); - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); Page expectedPage = new PageImpl<>( Collections.singletonList(scopeLimitation)); ScopeLimitationDetails expectedResponse = new ScopeLimitationDetails(); diff --git a/data-service/src/test/java/uk/gov/laa/ccms/data/service/UserServiceTest.java b/data-service/src/test/java/uk/gov/laa/ccms/data/service/UserServiceTest.java index 7a1a408..c3cbbbc 100644 --- a/data-service/src/test/java/uk/gov/laa/ccms/data/service/UserServiceTest.java +++ b/data-service/src/test/java/uk/gov/laa/ccms/data/service/UserServiceTest.java @@ -71,7 +71,7 @@ void getUsers_returnsPageOfValues() { user.setFirms(new ArrayList<>()); user.getFirms().add(firm); - Pageable pageable = Pageable.unpaged(); + Pageable pageable = Pageable.ofSize(10).withPage(0); Page expectedPage = new PageImpl<>( Collections.singletonList(user)); UserDetails expectedResponse = new UserDetails(); From d49bfb92fe9c80ac9c9c9842152a3f6a7b10b6d2 Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot Date: Mon, 20 Jan 2025 14:19:28 +0000 Subject: [PATCH 2/3] [Gradle Release Plugin] - pre tag commit: 'laa-ccms-caab-ebs-api-0.0.31'. --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 632713c..dd4cb04 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ -version=0.0.31-SNAPSHOT +version=0.0.31 group='uk.gov.laa.ccms' repositoryName=laa-ccms-data-api \ No newline at end of file From 08ef3c527058d987185c093c211d1f9caa01db53 Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot Date: Mon, 20 Jan 2025 14:19:29 +0000 Subject: [PATCH 3/3] [Gradle Release Plugin] - new version commit: 'laa-ccms-caab-ebs-api-0.0.32-SNAPSHOT'. --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index dd4cb04..a5389e2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ -version=0.0.31 +version=0.0.32-SNAPSHOT group='uk.gov.laa.ccms' repositoryName=laa-ccms-data-api \ No newline at end of file