diff --git a/build.gradle b/build.gradle index 7035befae45..03857cea73b 100644 --- a/build.gradle +++ b/build.gradle @@ -315,7 +315,7 @@ sonarqube { property "sonar.projectKey", "civil-service" property "sonar.coverage.jacoco.xmlReportPaths", "${jacocoTestReport.reports.xml.destination.path}" property "sonar.coverage.exclusions", "**/model/**, **/config/**/*Configuration.java, **/testingsupport/**, **/*ExternalTaskListener.java, **/*BaseExternalTaskHandler.java, **/stereotypes/**, **/*Exception.java, **/EventHistoryMapper*.java, **/model/hearingvalues/**, **/enums/hearing/**, **/fees/client/**, **/enums/sdo/**, **/service/PaymentsService.java" - property "sonar.cpd.exclusions", "**/*DocumentManagementService.java, **/*Spec*.java" + property "sonar.cpd.exclusions", "**/*DocumentManagementService.java, **/*Spec*.java, **/*CcdDashboardClaimantClaimMatcher.java" property "sonar.exclusions", "**/hmc/model/**, **/model/hearingvalues/**" property "sonar.host.url", "https://sonar.reform.hmcts.net/" } @@ -369,7 +369,7 @@ configurations.all { } dependencies { - implementation 'com.github.hmcts:civil-commons:1.0.33' + implementation 'com.github.hmcts:civil-commons:1.0.35' implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web' implementation group: 'org.springframework.boot', name: 'spring-boot-starter-actuator' implementation group: 'org.springframework.boot', name: 'spring-boot-starter-aop' @@ -396,7 +396,7 @@ dependencies { implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign' implementation group: 'org.springframework.cloud', name: 'spring-cloud-openfeign-core' implementation group: 'uk.gov.hmcts.reform', name: 'properties-volume-spring-boot-starter', version: '0.1.0' - implementation group: 'uk.gov.hmcts.reform', name: 'service-auth-provider-client', version: '4.0.0' + implementation group: 'uk.gov.hmcts.reform', name: 'service-auth-provider-client', version: '4.0.3' implementation group: 'io.github.openfeign', name: 'feign-httpclient', version: '12.4' implementation group: 'org.springframework.retry', name: 'spring-retry' @@ -496,6 +496,10 @@ dependencies { integrationTestImplementation sourceSets.main.runtimeClasspath integrationTestImplementation sourceSets.test.runtimeClasspath + // https://mvnrepository.com/artifact/com.opencsv/opencsv + implementation group: 'com.opencsv', name: 'opencsv', version: '5.8', { + exclude group: 'commons-collections', module: 'commons-collections' + } } mainClassName = 'uk.gov.hmcts.reform.civil.Application' diff --git a/charts/civil-service/Chart.yaml b/charts/civil-service/Chart.yaml index dbf0c702042..bc3f1ae9b6c 100644 --- a/charts/civil-service/Chart.yaml +++ b/charts/civil-service/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 description: A Helm chart for civil-service App name: civil-service home: https://github.com/hmcts/civil-service -version: 0.0.52 +version: 0.0.53 maintainers: - name: HMCTS Civil team diff --git a/charts/civil-service/values.yaml b/charts/civil-service/values.yaml index 54a997ceadd..fc9b9e0d99f 100644 --- a/charts/civil-service/values.yaml +++ b/charts/civil-service/values.yaml @@ -74,6 +74,7 @@ java: ASYNC_HANDLER_CORE_POOL_SIZE: 7 ASYNC_HANDLER_MAX_POOL_SIZE: 42 ASYNC_HANDLER_QUEUE_CAPACITY: 10 + CIVIL_S2S_AUTHORISED_SERVICES: payment_app,ccd_data,civil_service,civil-citizen-ui keyVaults: civil: diff --git a/config/owasp/suppressions.xml b/config/owasp/suppressions.xml index 8effe28d3c5..1ba8ea7ce32 100644 --- a/config/owasp/suppressions.xml +++ b/config/owasp/suppressions.xml @@ -35,5 +35,9 @@ CVE-2023-5072 CVE-2023-44487 + + CVE-2023-36052 + + diff --git a/docker/docmosis/templates/CV-UNS-GAP-ENG-01070.docx b/docker/docmosis/templates/CV-UNS-GAP-ENG-01070.docx index 3e9445b398d..df4bdf5e874 100644 Binary files a/docker/docmosis/templates/CV-UNS-GAP-ENG-01070.docx and b/docker/docmosis/templates/CV-UNS-GAP-ENG-01070.docx differ diff --git a/docker/docmosis/templates/CV-UNS-GAP-ENG-01071.docx b/docker/docmosis/templates/CV-UNS-GAP-ENG-01071.docx index 57e6930dbe3..3b9258c333f 100644 Binary files a/docker/docmosis/templates/CV-UNS-GAP-ENG-01071.docx and b/docker/docmosis/templates/CV-UNS-GAP-ENG-01071.docx differ diff --git a/docker/docmosis/templates/CV-UNS-HNO-ENG-01196.docx b/docker/docmosis/templates/CV-UNS-HNO-ENG-01196.docx index be705500ed4..a8323e9b537 100644 Binary files a/docker/docmosis/templates/CV-UNS-HNO-ENG-01196.docx and b/docker/docmosis/templates/CV-UNS-HNO-ENG-01196.docx differ diff --git a/docker/docmosis/templates/CV-UNS-HNO-ENG-01197.docx b/docker/docmosis/templates/CV-UNS-HNO-ENG-01197.docx index ac8be099ede..8fc9823f0d6 100644 Binary files a/docker/docmosis/templates/CV-UNS-HNO-ENG-01197.docx and b/docker/docmosis/templates/CV-UNS-HNO-ENG-01197.docx differ diff --git a/docker/docmosis/templates/CV-UNS-HNO-ENG-01198.docx b/docker/docmosis/templates/CV-UNS-HNO-ENG-01198.docx index 3bda9409259..74a8cfd7c0d 100644 Binary files a/docker/docmosis/templates/CV-UNS-HNO-ENG-01198.docx and b/docker/docmosis/templates/CV-UNS-HNO-ENG-01198.docx differ diff --git a/docker/docmosis/templates/CV-UNS-HNO-ENG-01200.docx b/docker/docmosis/templates/CV-UNS-HNO-ENG-01200.docx index 56e1165f73d..864bb9ebb62 100644 Binary files a/docker/docmosis/templates/CV-UNS-HNO-ENG-01200.docx and b/docker/docmosis/templates/CV-UNS-HNO-ENG-01200.docx differ diff --git a/docker/docmosis/templates/CV-UNS-HNO-ENG-01201.docx b/docker/docmosis/templates/CV-UNS-HNO-ENG-01201.docx new file mode 100644 index 00000000000..78cc5d54741 Binary files /dev/null and b/docker/docmosis/templates/CV-UNS-HNO-ENG-01201.docx differ diff --git a/docker/docmosis/templates/CV-UNS-HNO-ENG-01202.docx b/docker/docmosis/templates/CV-UNS-HNO-ENG-01202.docx new file mode 100644 index 00000000000..0409b5c1e6f Binary files /dev/null and b/docker/docmosis/templates/CV-UNS-HNO-ENG-01202.docx differ diff --git a/docker/docmosis/templates/CV-UNS-HNO-ENG-01203.docx b/docker/docmosis/templates/CV-UNS-HNO-ENG-01203.docx new file mode 100644 index 00000000000..45d3ad6dff5 Binary files /dev/null and b/docker/docmosis/templates/CV-UNS-HNO-ENG-01203.docx differ diff --git a/docker/docmosis/templates/CV-UNS-HNO-ENG-01204.docx b/docker/docmosis/templates/CV-UNS-HNO-ENG-01204.docx new file mode 100644 index 00000000000..936cbacb36e Binary files /dev/null and b/docker/docmosis/templates/CV-UNS-HNO-ENG-01204.docx differ diff --git a/infrastructure/tf-kv-secrets-cmc.tf b/infrastructure/tf-kv-secrets-cmc.tf index 0155092338f..afe11a0afa5 100644 --- a/infrastructure/tf-kv-secrets-cmc.tf +++ b/infrastructure/tf-kv-secrets-cmc.tf @@ -21,4 +21,66 @@ resource "azurerm_key_vault_secret" "civil_db_password__v11_secret" { depends_on = [ module.key-vault ] -} \ No newline at end of file +} + +data "azurerm_key_vault_secret" "db_password_v15_secret" { + key_vault_id = data.azurerm_key_vault.cmc_vault.id + name = "cmc-db-password-v15" +} + +resource "azurerm_key_vault_secret" "civil_db_password__v15_secret" { + name = "cmc-db-password-v15" + value = data.azurerm_key_vault_secret.db_password_v15_secret.value + key_vault_id = module.key-vault.key_vault_id + + content_type = "secret" + tags = merge(var.common_tags, { + "source" : "Vault ${data.azurerm_key_vault.cmc_vault.name}" + }) + + depends_on = [ + module.key-vault + ] +} + +data "azurerm_key_vault_secret" "db_username_v15_secret" { + key_vault_id = data.azurerm_key_vault.cmc_vault.id + name = "cmc-db-username-v15" +} + +resource "azurerm_key_vault_secret" "civil_db_username__v15_secret" { + name = "cmc-db-username-v15" + value = data.azurerm_key_vault_secret.db_username_v15_secret.value + key_vault_id = module.key-vault.key_vault_id + + content_type = "secret" + tags = merge(var.common_tags, { + "source" : "Vault ${data.azurerm_key_vault.cmc_vault.name}" + }) + + depends_on = [ + module.key-vault + ] +} + +data "azurerm_key_vault_secret" "db_host_v15_secret" { + key_vault_id = data.azurerm_key_vault.cmc_vault.id + name = "cmc-db-host-v15" +} + +resource "azurerm_key_vault_secret" "civil_db_host__v15_secret" { + name = "cmc-db-host-v15" + value = data.azurerm_key_vault_secret.db_host_v15_secret.value + key_vault_id = module.key-vault.key_vault_id + + content_type = "secret" + tags = merge(var.common_tags, { + "source" : "Vault ${data.azurerm_key_vault.cmc_vault.name}" + }) + + depends_on = [ + module.key-vault + ] +} + + diff --git a/src/contractTest/java/uk/gov/hmcts/reform/civil/RpaCaseHandedOfflineConsumerTest.java b/src/contractTest/java/uk/gov/hmcts/reform/civil/RpaCaseHandedOfflineConsumerTest.java index b9af898ee07..44e087ddd18 100644 --- a/src/contractTest/java/uk/gov/hmcts/reform/civil/RpaCaseHandedOfflineConsumerTest.java +++ b/src/contractTest/java/uk/gov/hmcts/reform/civil/RpaCaseHandedOfflineConsumerTest.java @@ -89,8 +89,6 @@ void setUp() { @Test @SneakyThrows void shouldGeneratePact_whenCaseTakenOffline() { - when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(true); - CaseData caseData = CaseDataBuilder.builder() .atState(FlowState.Main.TAKEN_OFFLINE_AFTER_CLAIM_NOTIFIED) .legacyCaseReference("100DC001") @@ -110,8 +108,6 @@ void shouldGeneratePact_whenCaseTakenOffline() { @Test @SneakyThrows void shouldGeneratePact_whenCaseDismissed() { - when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(true); - CaseData caseData = CaseDataBuilder.builder() .atState(FlowState.Main.CLAIM_DISMISSED_PAST_CLAIM_NOTIFICATION_DEADLINE) .legacyCaseReference("100DC001") @@ -131,8 +127,6 @@ void shouldGeneratePact_whenCaseDismissed() { @Test @SneakyThrows void shouldGeneratePact_whenNoticeOfChangeAndCaseTakenOffline() { - when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(true); - CaseData caseData = CaseDataBuilder.builder() .atState(FlowState.Main.TAKEN_OFFLINE_AFTER_CLAIM_NOTIFIED) .legacyCaseReference("100DC001") @@ -163,8 +157,6 @@ void shouldGeneratePact_whenNoticeOfChangeAndCaseTakenOffline() { @Test @SneakyThrows void shouldGeneratePact_whenNoticeOfChangeAndCaseDismissed() { - when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(true); - CaseData caseData = CaseDataBuilder.builder() .atState(FlowState.Main.CLAIM_DISMISSED_PAST_CLAIM_NOTIFICATION_DEADLINE) .legacyCaseReference("100DC001") diff --git a/src/contractTest/java/uk/gov/hmcts/reform/civil/RpaConsumerTest.java b/src/contractTest/java/uk/gov/hmcts/reform/civil/RpaConsumerTest.java index 731b59c66f5..a496f481388 100644 --- a/src/contractTest/java/uk/gov/hmcts/reform/civil/RpaConsumerTest.java +++ b/src/contractTest/java/uk/gov/hmcts/reform/civil/RpaConsumerTest.java @@ -214,10 +214,6 @@ void shouldGeneratePact_whenClaimAgainstUnrepresentedDefendantWithMinimalData_wi @Nested class UnrepresentedAndUnregisteredDefendant { - @BeforeEach - public void setup() { - when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(true); - } @Test @SneakyThrows @@ -235,30 +231,6 @@ void shouldGeneratePact_whenClaimAgainstUnrepresentedAndUnregisteredDefendant() assertEquals(PactVerificationResult.Ok.INSTANCE, result); } - - @Nested - class ToBeRemovedAfterNoc { - @Test - @SneakyThrows - void shouldGeneratePact_whenClaimAgainstUnrepresentedAndUnregisteredDefendant() { - when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(false); - - CaseData caseData = CaseDataBuilder.builder() - .atState(FlowState.Main.TAKEN_OFFLINE_UNREPRESENTED_UNREGISTERED_DEFENDANT) - .respondent1OrganisationPolicy(null) - .respondent2OrganisationPolicy(null) - .legacyCaseReference("000DC047") - .build(); - String payload = roboticsDataMapper.toRoboticsCaseData(caseData, BEARER_TOKEN).toJsonString(); - - assertThat(payload, validateJson()); - - String description = "Robotics case data for claim against unrepresented and unregistered defendant"; - PactVerificationResult result = getPactVerificationResult(payload, description); - - assertEquals(PactVerificationResult.Ok.INSTANCE, result); - } - } } @Nested diff --git a/src/integrationTest/java/uk/gov/hmcts/reform/civil/controllers/BaseIntegrationTest.java b/src/integrationTest/java/uk/gov/hmcts/reform/civil/controllers/BaseIntegrationTest.java index 139b311e778..a844c3a91fc 100644 --- a/src/integrationTest/java/uk/gov/hmcts/reform/civil/controllers/BaseIntegrationTest.java +++ b/src/integrationTest/java/uk/gov/hmcts/reform/civil/controllers/BaseIntegrationTest.java @@ -22,8 +22,10 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.ResultActions; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import uk.gov.hmcts.reform.authorisation.ServiceAuthorisationApi; import uk.gov.hmcts.reform.civil.Application; import uk.gov.hmcts.reform.civil.TestIdamConfiguration; +import uk.gov.hmcts.reform.civil.service.AuthorisationService; import uk.gov.hmcts.reform.civil.service.UserService; import uk.gov.hmcts.reform.idam.client.models.UserInfo; @@ -61,6 +63,9 @@ public abstract class BaseIntegrationTest { .roles(of("caseworker-civil-solicitor")) .build(); + private static final String s2sToken = "s2s AuthToken"; + @MockBean + private ServiceAuthorisationApi serviceAuthorisationApi; @MockBean protected UserService userService; @MockBean @@ -69,6 +74,8 @@ public abstract class BaseIntegrationTest { protected SecurityContext securityContext; @MockBean protected JwtDecoder jwtDecoder; + @MockBean + public AuthorisationService authorisationService; @Autowired protected ObjectMapper objectMapper; @@ -78,11 +85,13 @@ public abstract class BaseIntegrationTest { @BeforeEach public void setUpBase() { + when(authorisationService.isServiceAuthorized(any())).thenReturn(true); when(userService.getAccessToken(any(), any())).thenReturn("arbitrary access token"); when(userService.getUserInfo(anyString())).thenReturn(USER_INFO); when(securityContext.getAuthentication()).thenReturn(authentication); SecurityContextHolder.setContext(securityContext); setSecurityAuthorities(authentication); + when(serviceAuthorisationApi.getServiceName(any())).thenReturn("payment_app"); when(jwtDecoder.decode(anyString())).thenReturn(getJwt()); } diff --git a/src/integrationTest/java/uk/gov/hmcts/reform/civil/controllers/fees/ServiceRequestUpdateCallbackControllerTest.java b/src/integrationTest/java/uk/gov/hmcts/reform/civil/controllers/fees/ServiceRequestUpdateCallbackControllerTest.java index 32dc02b549e..6db03a393c0 100644 --- a/src/integrationTest/java/uk/gov/hmcts/reform/civil/controllers/fees/ServiceRequestUpdateCallbackControllerTest.java +++ b/src/integrationTest/java/uk/gov/hmcts/reform/civil/controllers/fees/ServiceRequestUpdateCallbackControllerTest.java @@ -4,6 +4,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.ResultActions; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; @@ -22,6 +23,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.when; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; class ServiceRequestUpdateCallbackControllerTest extends BaseIntegrationTest { @@ -31,6 +33,7 @@ class ServiceRequestUpdateCallbackControllerTest extends BaseIntegrationTest { private static final String PAID = "Paid"; private static final String REFERENCE = "reference"; private static final String ACCOUNT_NUMBER = "123445555"; + private static final String s2sToken = "s2s AuthToken"; @MockBean CoreCaseDataApi coreCaseDataApi; @@ -40,6 +43,7 @@ class ServiceRequestUpdateCallbackControllerTest extends BaseIntegrationTest { @BeforeEach void bareMinimumToMakeAPositiveRequest() { + when(authorisationService.isServiceAuthorized(any())).thenReturn(true); CaseData caseData = CaseData.builder().businessProcess(BusinessProcess.builder().processInstanceId("instance").camundaEvent("camunda event").build()).build(); CaseDetails caseDetails = CaseDetails.builder().build(); caseDetails.setData(caseData.toMap(objectMapper)); @@ -51,6 +55,30 @@ void bareMinimumToMakeAPositiveRequest() { given(coreCaseDataApi.submitEventForCaseWorker(any(), any(), any(), any(), any(), any(), anyBoolean(), any())).willReturn(caseDetails); } + @Test + public void whenValidPaymentCallbackIsReceivedReturnSuccess() throws Exception { + doPut(buildServiceDto(), PAYMENT_CALLBACK_URL, "") + .andExpect(status().isOk()); + } + + @Test + public void whenPaymentCallbackIsReceivedWithoutServiceAuthorisationReturn400() throws Exception { + mockMvc.perform( + MockMvcRequestBuilders.put(PAYMENT_CALLBACK_URL, "") + .contentType(MediaType.APPLICATION_JSON) + .content(toJson(buildServiceDto()))).andExpect(status().is4xxClientError()); + } + + @Test + public void whenPaymentCallbackIsReceivedWithServiceAuthorisationButreturnsfalseReturn400() throws Exception { + when(authorisationService.isServiceAuthorized(any())).thenReturn(false); + mockMvc.perform( + MockMvcRequestBuilders.put(PAYMENT_CALLBACK_URL, "") + .header("ServiceAuthorization", s2sToken) + .contentType(MediaType.APPLICATION_JSON) + .content(toJson(buildServiceDto()))).andExpect(status().is5xxServerError()); + } + @Test public void whenInvalidTypeOfRequestMade_ReturnMethodNotAllowed() throws Exception { @@ -96,6 +124,8 @@ private ServiceRequestUpdateDto buildServiceDto() { protected ResultActions doPut(T content, String urlTemplate, Object... uriVars) { return mockMvc.perform( MockMvcRequestBuilders.put(urlTemplate, uriVars) + .header(HttpHeaders.AUTHORIZATION, BEARER_TOKEN) + .header("ServiceAuthorization", "s2s AuthToken") .contentType(MediaType.APPLICATION_JSON) .content(toJson(content))); } @@ -104,6 +134,8 @@ protected ResultActions doPut(T content, String urlTemplate, Object... uriVa protected ResultActions doPost(T content, String urlTemplate, Object... uriVars) { return mockMvc.perform( MockMvcRequestBuilders.post(urlTemplate, uriVars) + .header(HttpHeaders.AUTHORIZATION, BEARER_TOKEN) + .header("ServiceAuthorization", "s2s AuthToken") .contentType(MediaType.APPLICATION_JSON) .content(toJson(content))); } diff --git a/src/integrationTest/java/uk/gov/hmcts/reform/civil/controllers/fees/ServiceRequestUpdateClaimIssuedCallbackControllerTest.java b/src/integrationTest/java/uk/gov/hmcts/reform/civil/controllers/fees/ServiceRequestUpdateClaimIssuedCallbackControllerTest.java index 673f90234a5..b64ef4426bb 100644 --- a/src/integrationTest/java/uk/gov/hmcts/reform/civil/controllers/fees/ServiceRequestUpdateClaimIssuedCallbackControllerTest.java +++ b/src/integrationTest/java/uk/gov/hmcts/reform/civil/controllers/fees/ServiceRequestUpdateClaimIssuedCallbackControllerTest.java @@ -4,6 +4,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.ResultActions; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; @@ -22,6 +23,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.when; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; class ServiceRequestUpdateClaimIssuedCallbackControllerTest extends BaseIntegrationTest { @@ -31,7 +33,6 @@ class ServiceRequestUpdateClaimIssuedCallbackControllerTest extends BaseIntegrat private static final String PAID = "Paid"; private static final String REFERENCE = "reference"; private static final String ACCOUNT_NUMBER = "123445555"; - @MockBean CoreCaseDataApi coreCaseDataApi; @@ -40,6 +41,7 @@ class ServiceRequestUpdateClaimIssuedCallbackControllerTest extends BaseIntegrat @BeforeEach void bareMinimumToMakeAPositiveRequest() { + when(authorisationService.isServiceAuthorized(any())).thenReturn(true); CaseData caseData = CaseData.builder().businessProcess(BusinessProcess.builder().processInstanceId("instance").camundaEvent("camunda event").build()).build(); CaseDetails caseDetails = CaseDetails.builder().build(); @@ -77,6 +79,30 @@ public void whenServiceRequestUpdateRequestButUnexpectedErrorOccurs_thenHttp5xx( .andExpect(status().is5xxServerError()); } + @Test + public void whenValidPaymentCallbackIsReceivedReturnSuccess() throws Exception { + doPut(buildServiceDto(), PAYMENT_CALLBACK_URL, "") + .andExpect(status().isOk()); + } + + @Test + public void whenPaymentCallbackIsReceivedWithoutServiceAuthorisationReturn400() throws Exception { + mockMvc.perform( + MockMvcRequestBuilders.put(PAYMENT_CALLBACK_URL, "") + .contentType(MediaType.APPLICATION_JSON) + .content(toJson(buildServiceDto()))).andExpect(status().is4xxClientError()); + } + + @Test + public void whenPaymentCallbackIsReceivedWithServiceAuthorisationButreturnsfalseReturn400() throws Exception { + when(authorisationService.isServiceAuthorized(any())).thenReturn(false); + + doPut(buildServiceDto(), PAYMENT_CALLBACK_URL, "") + // Then: the result status must be an HTTP-4xx + .andExpect(status().is5xxServerError()); + + } + private ServiceRequestUpdateDto buildServiceDto() { return ServiceRequestUpdateDto.builder() .ccdCaseNumber(CCD_CASE_NUMBER) @@ -94,6 +120,8 @@ private ServiceRequestUpdateDto buildServiceDto() { protected ResultActions doPut(T content, String urlTemplate, Object... uriVars) { return mockMvc.perform( MockMvcRequestBuilders.put(urlTemplate, uriVars) + .header(HttpHeaders.AUTHORIZATION, BEARER_TOKEN) + .header("ServiceAuthorization", "s2s AuthToken") .contentType(MediaType.APPLICATION_JSON) .content(toJson(content))); } @@ -102,6 +130,8 @@ protected ResultActions doPut(T content, String urlTemplate, Object... uriVa protected ResultActions doPost(T content, String urlTemplate, Object... uriVars) { return mockMvc.perform( MockMvcRequestBuilders.post(urlTemplate, uriVars) + .header(HttpHeaders.AUTHORIZATION, BEARER_TOKEN) + .header("ServiceAuthorization", "s2s AuthToken") .contentType(MediaType.APPLICATION_JSON) .content(toJson(content))); } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/callback/CaseEvent.java b/src/main/java/uk/gov/hmcts/reform/civil/callback/CaseEvent.java index 6ac5788bf56..f1ee5498ce0 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/callback/CaseEvent.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/callback/CaseEvent.java @@ -94,6 +94,8 @@ public enum CaseEvent { GENERATE_TRIAL_READY_DOCUMENT_RESPONDENT1(USER), GENERATE_TRIAL_READY_DOCUMENT_RESPONDENT2(USER), LIP_CLAIM_SETTLED(USER), + DEFENDANT_SIGN_SETTLEMENT_AGREEMENT(USER), + TRIGGER_TASK_RECONFIG(USER), NOTIFY_FORMER_SOLICITOR(CAMUNDA), NOTIFY_OTHER_SOLICITOR_1(CAMUNDA), NOTIFY_OTHER_SOLICITOR_2(CAMUNDA), @@ -298,8 +300,12 @@ public enum CaseEvent { SEND_CVP_JOIN_LINK(USER), SET_LIP_RESPONDENT_RESPONSE_DEADLINE(CAMUNDA), NOTIFY_LIP_RESPONDENT_CLAIMANT_CONFIRM_TO_PROCEED(CAMUNDA), - NOTIFY_LIP_APPLICANT_CLAIMANT_CONFIRM_TO_PROCEED(CAMUNDA); + NOTIFY_LIP_APPLICANT_CLAIMANT_CONFIRM_TO_PROCEED(CAMUNDA), + NOTIFY_APPLICANT1_FOR_REQUEST_JUDGEMENT_BY_ADMISSION_LIP_CLAIMANT(CAMUNDA), + NOTIFY_RESPONDENT1_FOR_REQUEST_JUDGEMENT_BY_ADMISSION_LIP_CLAIMANT(CAMUNDA), + TRIGGER_TASK_RECONFIG_GA(CAMUNDA), + RETRIGGER_CASES(CAMUNDA); private final UserType userType; public boolean isCamundaEvent() { diff --git a/src/main/java/uk/gov/hmcts/reform/civil/config/SecurityConfiguration.java b/src/main/java/uk/gov/hmcts/reform/civil/config/SecurityConfiguration.java index b768e973f22..553ce8d97dc 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/config/SecurityConfiguration.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/config/SecurityConfiguration.java @@ -51,7 +51,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { "/assignment/**", "/service-request-update", "/service-request-update-claim-issued", - "/case/document/**" + "/case/document/downloadDocument/**" }; @Value("${spring.security.oauth2.client.provider.oidc.issuer-uri}") diff --git a/src/main/java/uk/gov/hmcts/reform/civil/controllers/fees/ServiceRequestUpdateCallbackController.java b/src/main/java/uk/gov/hmcts/reform/civil/controllers/fees/ServiceRequestUpdateCallbackController.java index 02faefda690..9c6bae36e15 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/controllers/fees/ServiceRequestUpdateCallbackController.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/controllers/fees/ServiceRequestUpdateCallbackController.java @@ -7,10 +7,12 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RestController; import uk.gov.hmcts.reform.civil.enums.FeeType; import uk.gov.hmcts.reform.civil.exceptions.InternalServerErrorException; import uk.gov.hmcts.reform.civil.model.ServiceRequestUpdateDto; +import uk.gov.hmcts.reform.civil.service.AuthorisationService; import uk.gov.hmcts.reform.civil.service.PaymentRequestUpdateCallbackService; import static javax.ws.rs.core.MediaType.APPLICATION_JSON; @@ -22,6 +24,8 @@ public class ServiceRequestUpdateCallbackController { private final PaymentRequestUpdateCallbackService requestUpdateCallbackService; + private final AuthorisationService authorisationService; + @PutMapping(path = "/service-request-update", consumes = APPLICATION_JSON, produces = APPLICATION_JSON) @Operation(summary = "Ways to pay will call this API and send the status of payment with other details") @ApiResponses(value = { @@ -29,9 +33,15 @@ public class ServiceRequestUpdateCallbackController { @ApiResponse(responseCode = "400", description = "Bad Request"), @ApiResponse(responseCode = "500", description = "Internal Server Error") }) - public void serviceRequestUpdate(@RequestBody ServiceRequestUpdateDto serviceRequestUpdateDto) { + public void serviceRequestUpdate( + @RequestHeader("ServiceAuthorization") String s2sToken, + @RequestBody ServiceRequestUpdateDto serviceRequestUpdateDto) { try { - requestUpdateCallbackService.processCallback(serviceRequestUpdateDto, FeeType.HEARING.name()); + if (authorisationService.isServiceAuthorized(s2sToken)) { + requestUpdateCallbackService.processCallback(serviceRequestUpdateDto, FeeType.HEARING.name()); + } else { + throw (new RuntimeException("Invalid Client")); + } } catch (Exception ex) { log.error( "Payment callback is unsuccessful for the CaseID: {}", diff --git a/src/main/java/uk/gov/hmcts/reform/civil/controllers/fees/ServiceRequestUpdateClaimIssuedCallbackController.java b/src/main/java/uk/gov/hmcts/reform/civil/controllers/fees/ServiceRequestUpdateClaimIssuedCallbackController.java index 9627d311f54..8230424a778 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/controllers/fees/ServiceRequestUpdateClaimIssuedCallbackController.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/controllers/fees/ServiceRequestUpdateClaimIssuedCallbackController.java @@ -7,10 +7,12 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RestController; import uk.gov.hmcts.reform.civil.enums.FeeType; import uk.gov.hmcts.reform.civil.exceptions.InternalServerErrorException; import uk.gov.hmcts.reform.civil.model.ServiceRequestUpdateDto; +import uk.gov.hmcts.reform.civil.service.AuthorisationService; import uk.gov.hmcts.reform.civil.service.PaymentRequestUpdateCallbackService; import static javax.ws.rs.core.MediaType.APPLICATION_JSON; @@ -22,14 +24,21 @@ public class ServiceRequestUpdateClaimIssuedCallbackController { private final PaymentRequestUpdateCallbackService requestUpdateCallbackService; + private final AuthorisationService authorisationService; + @PutMapping(path = "/service-request-update-claim-issued", consumes = APPLICATION_JSON, produces = APPLICATION_JSON) @Operation(summary = "Ways to pay will call this API and send the status of payment with other details") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Callback processed."), @ApiResponse(responseCode = "400", description = "Bad Request")}) - public void serviceRequestUpdate(@RequestBody ServiceRequestUpdateDto serviceRequestUpdateDto) { + public void serviceRequestUpdate(@RequestHeader("ServiceAuthorization") String s2sToken, + @RequestBody ServiceRequestUpdateDto serviceRequestUpdateDto) { try { - requestUpdateCallbackService.processCallback(serviceRequestUpdateDto, FeeType.CLAIMISSUED.name()); + if (authorisationService.isServiceAuthorized(s2sToken)) { + requestUpdateCallbackService.processCallback(serviceRequestUpdateDto, FeeType.CLAIMISSUED.name()); + } else { + throw (new RuntimeException("Invalid Client")); + } } catch (Exception ex) { log.error( "Payment callback is unsuccessful for the CaseID: {}", diff --git a/src/main/java/uk/gov/hmcts/reform/civil/controllers/testingsupport/TestingSupportController.java b/src/main/java/uk/gov/hmcts/reform/civil/controllers/testingsupport/TestingSupportController.java index 8e779ede86d..350018b0076 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/controllers/testingsupport/TestingSupportController.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/controllers/testingsupport/TestingSupportController.java @@ -89,22 +89,6 @@ public ResponseEntity checkFeatureToggle( return new ResponseEntity<>(featureToggleInfo, HttpStatus.OK); } - @GetMapping("/testing-support/feature-toggle/noc") - @Operation(summary = "Check if noc feature toggle is enabled") - public ResponseEntity checkNoCToggleEnabled() { - boolean featureEnabled = featureToggleService.isNoticeOfChangeEnabled(); - FeatureToggleInfo featureToggleInfo = new FeatureToggleInfo(featureEnabled); - return new ResponseEntity<>(featureToggleInfo, HttpStatus.OK); - } - - @GetMapping("/testing-support/feature-toggle/isCertificateOfServiceEnabled") - @Operation(summary = "Check if access profiles feature toggle is enabled") - public ResponseEntity checkCertificateOfServiceEnabled() { - boolean featureEnabled = featureToggleService.isCertificateOfServiceEnabled(); - FeatureToggleInfo featureToggleInfo = new FeatureToggleInfo(featureEnabled); - return new ResponseEntity<>(featureToggleInfo, HttpStatus.OK); - } - @Data private static class BusinessProcessInfo { private BusinessProcess businessProcess; diff --git a/src/main/java/uk/gov/hmcts/reform/civil/enums/PersonalInjuryType.java b/src/main/java/uk/gov/hmcts/reform/civil/enums/PersonalInjuryType.java index 14e611b322d..0ac4ac0b110 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/enums/PersonalInjuryType.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/enums/PersonalInjuryType.java @@ -6,5 +6,6 @@ public enum PersonalInjuryType { PUBLIC_LIABILITY, HOLIDAY_ILLNESS, DISEASE_CLAIM, + NOISE_INDUCED_HEARING_LOSS, PERSONAL_INJURY_OTHER } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/enums/UnrepresentedOrUnregisteredScenario.java b/src/main/java/uk/gov/hmcts/reform/civil/enums/UnrepresentedOrUnregisteredScenario.java index 0251e6e0807..e479191be1d 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/enums/UnrepresentedOrUnregisteredScenario.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/enums/UnrepresentedOrUnregisteredScenario.java @@ -9,8 +9,7 @@ public enum UnrepresentedOrUnregisteredScenario { UNREPRESENTED, - UNREGISTERED, - UNREGISTERED_NOTICE_OF_CHANGE; + UNREGISTERED; public static List getDefendantNames(UnrepresentedOrUnregisteredScenario scenario, CaseData caseData) { List defendantNames = new ArrayList<>(); @@ -24,20 +23,6 @@ public static List getDefendantNames(UnrepresentedOrUnregisteredScenario } break; case UNREGISTERED: - if (caseData.getRespondent1OrgRegistered() != YES - && caseData.getRespondent1OrganisationPolicy() == null - && caseData.getRespondent1Represented() == YES) { - defendantNames.add(caseData.getRespondent1().getPartyName()); - } - if (caseData.getRespondent2OrgRegistered() != YES - && caseData.getRespondent2Represented() == YES - && caseData.getRespondent2OrganisationPolicy() == null - && caseData.getRespondent2() != null) { - defendantNames.add(caseData.getRespondent2().getPartyName()); - } - break; - //this should be removed during removal of notice of change flag - case UNREGISTERED_NOTICE_OF_CHANGE: if (caseData.getRespondent1OrgRegistered() != YES && caseData.getRespondent1OrganisationPolicy() != null && caseData.getRespondent1OrganisationPolicy().getOrganisation() == null diff --git a/src/main/java/uk/gov/hmcts/reform/civil/enums/caseprogression/BundleFileNameList.java b/src/main/java/uk/gov/hmcts/reform/civil/enums/caseprogression/BundleFileNameList.java index ec628a0643f..5ed04e34a79 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/enums/caseprogression/BundleFileNameList.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/enums/caseprogression/BundleFileNameList.java @@ -17,7 +17,7 @@ public enum BundleFileNameList { WITNESS_STATEMENT_OTHER_DISPLAY_NAME("Witness Statement %s %s %s"), WITNESS_STATEMENT("Witness Statement"), WITNESS_SUMMARY("Witness Summary %s %s"), - DOC_REFERRED_TO("Documents referred to in statement %s %s"), + DOC_REFERRED_TO("%s referred to in the statement of %s %s"), HEARSAY_NOTICE("Hearsay notice %s %s"), NOTICE_TO_ADMIT_FACTS("Notice to admit facts %s %s"), DF_RESPONSE("DF Response %s"), diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/ResendNotifyRPAEventsHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/ResendNotifyRPAEventsHandler.java deleted file mode 100644 index 7479189bf39..00000000000 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/ResendNotifyRPAEventsHandler.java +++ /dev/null @@ -1,110 +0,0 @@ -package uk.gov.hmcts.reform.civil.handler; - -import feign.FeignException; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.io.IOUtils; -import org.camunda.bpm.client.task.ExternalTask; -import org.springframework.stereotype.Component; -import uk.gov.hmcts.reform.ccd.client.model.CaseDataContent; -import uk.gov.hmcts.reform.ccd.client.model.Event; -import uk.gov.hmcts.reform.ccd.client.model.StartEventResponse; -import uk.gov.hmcts.reform.civil.callback.CaseEvent; -import uk.gov.hmcts.reform.civil.handler.tasks.BaseExternalTaskHandler; -import uk.gov.hmcts.reform.civil.service.CoreCaseDataService; - -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_RPA_ON_CONTINUOUS_FEED; -import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_RPA_ON_CASE_HANDED_OFFLINE; - -@Slf4j -@RequiredArgsConstructor -@Component -public class ResendNotifyRPAEventsHandler implements BaseExternalTaskHandler { - - private final CoreCaseDataService coreCaseDataService; - - @Override - public void handleTask(ExternalTask externalTask) { - log.info("User authentication successful."); - var caseIdForNotifyRpaOnCaseHandedOffline = readCaseIds("/caseIdForNotifyRpaOnCaseHandedOffline.txt"); - updateCaseByEvent(caseIdForNotifyRpaOnCaseHandedOffline, NOTIFY_RPA_ON_CASE_HANDED_OFFLINE); - - var caseIdForNotifyRpaOnContinuousFeed = readCaseIds("/caseIdForNotifyRpaOnContinuousFeed.txt"); - updateCaseByEvent(caseIdForNotifyRpaOnContinuousFeed, NOTIFY_RPA_ON_CONTINUOUS_FEED); - - } - - private void updateCaseByEvent(List caseIdList, CaseEvent caseEvent) { - if (caseIdList != null && !caseIdList.isEmpty()) { - log.info("Resend notify RPA started for event: {}", caseEvent); - caseIdList.forEach(caseId -> { - try { - log.info("Resend CaseId: {} started", caseId); - var startEventResponse = coreCaseDataService.startUpdate(caseId, caseEvent); - - Map caseDataMap = coreCaseDataService.getCase(Long.valueOf(caseId)).getData(); - - coreCaseDataService.submitUpdate(caseId, caseDataContent(startEventResponse, caseDataMap)); - log.info("Resend CaseId: {} finished", caseId); - - } catch (FeignException e) { - log.error("ERROR Resend CaseId: {}", caseId); - log.error(String.format("Updating case data failed: %s", e.contentUTF8())); - throw e; - } catch (Exception e) { - log.error("ERROR Resend CaseId: {}", caseId); - log.error(String.format("Updating case data failed: %s", e.getMessage())); - } - log.info("Resend notify RPA Finished for event: {}", caseEvent); - }); - } else { - log.info("List id empty for: {}", caseEvent); - } - - } - - private CaseDataContent caseDataContent(StartEventResponse startEventResponse, Map caseDataMap) { - Map data = startEventResponse.getCaseDetails().getData(); - data.putAll(caseDataMap); - - return CaseDataContent.builder() - .eventToken(startEventResponse.getToken()) - .event(Event.builder().id(startEventResponse.getEventId()).build()) - .data(data) - .build(); - } - - private List readCaseIds(String file) { - - String data = readString(file); - return Arrays.stream(data.split("[\r\n]+")) - .filter(Objects::nonNull) - .map(String::trim) - .filter(Predicate.not(String::isEmpty)) - .collect(Collectors.toList()); - } - - private String readString(String resourcePath) { - return new String(readBytes(resourcePath), StandardCharsets.UTF_8); - } - - private byte[] readBytes(String resourcePath) { - try (InputStream inputStream = ResendNotifyRPAEventsHandler.class.getResourceAsStream(resourcePath)) { - return IOUtils.toByteArray(inputStream); - } catch (IOException e) { - throw new IllegalStateException(e); - } catch (NullPointerException e) { - throw new IllegalStateException("Unable to read resource: " + resourcePath, e); - } - } -} diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/RetriggerCasesEventHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/RetriggerCasesEventHandler.java new file mode 100644 index 00000000000..ecb14390ff5 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/RetriggerCasesEventHandler.java @@ -0,0 +1,85 @@ +package uk.gov.hmcts.reform.civil.handler; + +import feign.FeignException; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.io.IOUtils; +import org.camunda.bpm.client.task.ExternalTask; +import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.civil.callback.CaseEvent; +import uk.gov.hmcts.reform.civil.handler.tasks.BaseExternalTaskHandler; +import uk.gov.hmcts.reform.civil.service.CoreCaseDataService; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.RETRIGGER_CASES; + +@Slf4j +@RequiredArgsConstructor +@Component +public class RetriggerCasesEventHandler implements BaseExternalTaskHandler { + + private final CoreCaseDataService coreCaseDataService; + + @Override + public void handleTask(ExternalTask externalTask) { + log.info("User authentication successful."); + var caseIdForNotifyRpaOnCaseHandedOffline = readCaseIds("/caseIdForRetrigger.txt"); + updateCaseByEvent(caseIdForNotifyRpaOnCaseHandedOffline, RETRIGGER_CASES); + } + + public void updateCaseByEvent(List caseIdList, CaseEvent caseEvent) { + if (caseIdList != null && !caseIdList.isEmpty()) { + log.info("Retrigger cases started for event: {}", caseEvent); + caseIdList.forEach(caseId -> { + try { + log.info("Retrigger CaseId: {} started", caseId); + coreCaseDataService.triggerEvent(Long.parseLong(caseId), caseEvent); + log.info("Retrigger CaseId: {} finished", caseId); + + } catch (FeignException e) { + log.error("ERROR Retrigger CaseId: {}", caseId); + log.error(String.format("Retrigger case failed: %s", e.contentUTF8())); + throw e; + } catch (Exception e) { + throw e; + } + log.info("Retrigger cases Finished for event: {}", caseEvent); + }); + } else { + log.info("List id empty for: {}", caseEvent); + } + + } + + public List readCaseIds(String file) { + + String data = readString(file); + return Arrays.stream(data.split("[\r\n]+")) + .filter(Objects::nonNull) + .map(String::trim) + .filter(Predicate.not(String::isEmpty)) + .collect(Collectors.toList()); + } + + private String readString(String resourcePath) { + return new String(readBytes(resourcePath), StandardCharsets.UTF_8); + } + + byte[] readBytes(String resourcePath) { + try (InputStream inputStream = RetriggerCasesEventHandler.class.getResourceAsStream(resourcePath)) { + return IOUtils.toByteArray(inputStream); + } catch (IOException e) { + throw new IllegalStateException(e); + } catch (NullPointerException e) { + throw new IllegalStateException("Unable to read resource: " + resourcePath, e); + } + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/caseevents/TriggerGenAppLocationUpdateCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/caseevents/TriggerGenAppLocationUpdateCallbackHandler.java index 6a7c730596d..4664afc38b7 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/caseevents/TriggerGenAppLocationUpdateCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/caseevents/TriggerGenAppLocationUpdateCallbackHandler.java @@ -20,13 +20,16 @@ import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIGGER_LOCATION_UPDATE; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIGGER_UPDATE_GA_LOCATION; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIGGER_TASK_RECONFIG; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIGGER_TASK_RECONFIG_GA; @Slf4j @Service @RequiredArgsConstructor public class TriggerGenAppLocationUpdateCallbackHandler extends CallbackHandler { - private static final List EVENTS = List.of(TRIGGER_UPDATE_GA_LOCATION); + private static final List EVENTS = List.of(TRIGGER_UPDATE_GA_LOCATION, + TRIGGER_TASK_RECONFIG_GA); private final GenAppStateHelperService helperService; private final ObjectMapper objectMapper; @@ -49,7 +52,11 @@ private CallbackResponse triggerGaEvent(CallbackParams callbackParams) { try { if (caseData.getGeneralApplications() != null && !caseData.getGeneralApplications().isEmpty()) { caseData = helperService.updateApplicationLocationDetailsInClaim(caseData, authToken); - helperService.triggerEvent(caseData, TRIGGER_LOCATION_UPDATE); + if (callbackParams.getRequest().getEventId().equals(TRIGGER_UPDATE_GA_LOCATION.name())) { + helperService.triggerEvent(caseData, TRIGGER_LOCATION_UPDATE); + } else if (callbackParams.getRequest().getEventId().equals(TRIGGER_TASK_RECONFIG_GA.name())) { + helperService.triggerEvent(caseData, TRIGGER_TASK_RECONFIG); + } } } catch (Exception e) { String errorMessage = "Could not trigger event to update location on application under case: " diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateClaimFormCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateClaimFormCallbackHandler.java index 5b8cb3ec373..7b4c098951c 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateClaimFormCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateClaimFormCallbackHandler.java @@ -80,7 +80,7 @@ private CallbackResponse generateClaimForm(CallbackParams callbackParams) { ); assignCategoryId.assignCategoryIdToCaseDocument(sealedClaim, "detailsOfClaim"); - if (featureToggleService.isNoticeOfChangeEnabled() && stitchEnabled + if (stitchEnabled && (YesOrNo.NO.equals(caseData.getRespondent1Represented()) || YesOrNo.NO.equals(caseData.getRespondent2Represented()))) { diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateClaimFormForSpecCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateClaimFormForSpecCallbackHandler.java index ad19e6b8e9f..f5566efef7e 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateClaimFormForSpecCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateClaimFormForSpecCallbackHandler.java @@ -154,7 +154,7 @@ private List fetchDocumentsFromCaseData(CaseData caseData, Cas LocalDate.now().toString())); //LiP Claim form guidance needs be sent as the 2nd doc to go on the back of the claim form - if (toggleService.isNoticeOfChangeEnabled() && stitchEnabled) { + if (stitchEnabled) { if (YesOrNo.NO.equals(caseData.getSpecRespondent1Represented()) || YesOrNo.NO.equals(caseData.getSpecRespondent2Represented())) { diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateHearingNoticeHmcHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateHearingNoticeHmcHandler.java index 51e1cfaef56..92666ce2608 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateHearingNoticeHmcHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateHearingNoticeHmcHandler.java @@ -11,7 +11,11 @@ import uk.gov.hmcts.reform.civil.callback.CaseEvent; import uk.gov.hmcts.reform.civil.documentmanagement.model.CaseDocument; import uk.gov.hmcts.reform.civil.model.CaseData; +import uk.gov.hmcts.reform.civil.model.common.DynamicList; +import uk.gov.hmcts.reform.civil.model.common.DynamicListElement; import uk.gov.hmcts.reform.civil.model.common.Element; +import uk.gov.hmcts.reform.civil.referencedata.LocationRefDataService; +import uk.gov.hmcts.reform.civil.referencedata.model.LocationRefData; import uk.gov.hmcts.reform.civil.service.docmosis.hearing.HearingNoticeHmcGenerator; import uk.gov.hmcts.reform.civil.service.hearingnotice.HearingNoticeCamundaService; import uk.gov.hmcts.reform.civil.utils.HearingFeeUtils; @@ -30,6 +34,7 @@ import static uk.gov.hmcts.reform.civil.utils.DateUtils.convertFromUTC; import static uk.gov.hmcts.reform.civil.utils.ElementUtils.element; import static uk.gov.hmcts.reform.civil.utils.HmcDataUtils.getHearingDays; +import static uk.gov.hmcts.reform.civil.utils.HmcDataUtils.getLocationRefData; @Service @RequiredArgsConstructor @@ -45,6 +50,7 @@ public class GenerateHearingNoticeHmcHandler extends CallbackHandler { private final HearingsService hearingsService; private final HearingNoticeHmcGenerator hearingNoticeHmcGenerator; private final ObjectMapper objectMapper; + private final LocationRefDataService locationRefDataService; @Override protected Map callbacks() { @@ -65,17 +71,20 @@ private CallbackResponse generateHearingNotice(CallbackParams callbackParams) { CaseData caseData = callbackParams.getCaseData(); CaseData.CaseDataBuilder caseDataBuilder = caseData.toBuilder(); String processInstanceId = caseData.getBusinessProcess().getProcessInstanceId(); + String bearerToken = callbackParams.getParams().get(BEARER_TOKEN).toString(); var camundaVars = camundaService.getProcessVariables(processInstanceId); var hearing = hearingsService.getHearingResponse( - callbackParams.getParams().get(BEARER_TOKEN).toString(), + bearerToken, camundaVars.getHearingId() ); var hearingStartDay = HmcDataUtils.getHearingStartDay(hearing); var hearingStartDate = convertFromUTC(hearingStartDay.getHearingStartDateTime()); + String hearingLocation = getHearingLocation(camundaVars.getHearingId(), hearing, + bearerToken, locationRefDataService); - buildDocument(callbackParams, caseDataBuilder, hearing); + buildDocument(callbackParams, caseDataBuilder, hearing, hearingLocation, camundaVars.getHearingId()); camundaService.setProcessVariables( processInstanceId, @@ -93,16 +102,22 @@ private CallbackResponse generateHearingNotice(CallbackParams callbackParams) { .data(caseDataBuilder .hearingDate(hearingStartDate.toLocalDate()) .hearingDueDate(HearingFeeUtils.calculateHearingDueDate(LocalDate.now(), hearingStartDate.toLocalDate())) + .hearingLocation(DynamicList.builder().value(DynamicListElement.builder() + .label(hearingLocation) + .build()).build()) .build().toMap(objectMapper)) .build(); } - private void buildDocument(CallbackParams callbackParams, CaseData.CaseDataBuilder caseDataBuilder, HearingGetResponse hearing) { + private void buildDocument(CallbackParams callbackParams, CaseData.CaseDataBuilder caseDataBuilder, HearingGetResponse hearing, + String hearingLocation, String hearingId) { CaseData caseData = callbackParams.getCaseData(); List caseDocuments = hearingNoticeHmcGenerator.generate( caseData, hearing, - callbackParams.getParams().get(BEARER_TOKEN).toString() + callbackParams.getParams().get(BEARER_TOKEN).toString(), + hearingLocation, + hearingId ); List> systemGeneratedCaseDocuments = new ArrayList<>(); systemGeneratedCaseDocuments.add(element(caseDocuments.get(0))); @@ -111,4 +126,17 @@ private void buildDocument(CallbackParams callbackParams, CaseData.CaseDataBuild } caseDataBuilder.hearingDocuments(systemGeneratedCaseDocuments); } + + private String getHearingLocation(String hearingId, HearingGetResponse hearing, + String bearerToken, LocationRefDataService locationRefDataService) { + LocationRefData hearingLocation = getLocationRefData( + hearingId, + HmcDataUtils.getHearingStartDay(hearing).getHearingVenueId(), + bearerToken, + locationRefDataService); + if (hearingLocation != null) { + return LocationRefDataService.getDisplayEntry(hearingLocation); + } + return null; + } } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimContinuingOnlineApplicantNotificationHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimContinuingOnlineApplicantNotificationHandler.java index 238cb42db57..342a4b278bc 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimContinuingOnlineApplicantNotificationHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimContinuingOnlineApplicantNotificationHandler.java @@ -54,10 +54,7 @@ public List handledEvents() { private CallbackResponse notifyApplicantSolicitorForClaimContinuingOnline(CallbackParams callbackParams) { CaseData caseData = callbackParams.getCaseData(); - boolean isCosEnabled = featureToggleService.isCertificateOfServiceEnabled(); - String emailTemplateID = isCosEnabled != true - ? notificationsProperties.getClaimantSolicitorClaimContinuingOnline() - : notificationsProperties.getClaimantSolicitorClaimContinuingOnlineCos(); + String emailTemplateID = notificationsProperties.getClaimantSolicitorClaimContinuingOnlineCos(); notificationService.sendMail( caseData.getApplicantSolicitor1UserDetails().getEmail(), diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimantLipRequestJudgementByAdmissionApplicantNotificationHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimantLipRequestJudgementByAdmissionApplicantNotificationHandler.java new file mode 100644 index 00000000000..28b0d028c8f --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimantLipRequestJudgementByAdmissionApplicantNotificationHandler.java @@ -0,0 +1,83 @@ +package uk.gov.hmcts.reform.civil.handler.callback.camunda.notification; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; +import uk.gov.hmcts.reform.ccd.client.model.CallbackResponse; +import uk.gov.hmcts.reform.civil.callback.Callback; +import uk.gov.hmcts.reform.civil.callback.CallbackHandler; +import uk.gov.hmcts.reform.civil.callback.CallbackParams; +import uk.gov.hmcts.reform.civil.callback.CaseEvent; +import uk.gov.hmcts.reform.civil.config.PinInPostConfiguration; +import uk.gov.hmcts.reform.civil.model.CaseData; +import uk.gov.hmcts.reform.civil.notify.NotificationService; +import uk.gov.hmcts.reform.civil.notify.NotificationsProperties; + +import java.util.List; +import java.util.Map; + +import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_APPLICANT1_FOR_REQUEST_JUDGEMENT_BY_ADMISSION_LIP_CLAIMANT; +import static uk.gov.hmcts.reform.civil.utils.PartyUtils.getPartyNameBasedOnType; + +@Service +@RequiredArgsConstructor +public class ClaimantLipRequestJudgementByAdmissionApplicantNotificationHandler extends CallbackHandler implements NotificationData { + + private static final List EVENTS = List.of( + NOTIFY_APPLICANT1_FOR_REQUEST_JUDGEMENT_BY_ADMISSION_LIP_CLAIMANT); + public static final String TASK_ID = "RequestJudgementByAdmissionLipClaimantNotifyRespondent1"; + private static final String REFERENCE_TEMPLATE = "request-judgement-by-admission-applicant-notification-%s"; + + private final NotificationService notificationService; + private final NotificationsProperties notificationsProperties; + private final PinInPostConfiguration pipInPostConfiguration; + + @Override + protected Map callbacks() { + return Map.of( + callbackKey(ABOUT_TO_SUBMIT), + this::notifyApplicant1ForRequestJudgementByAdmission + ); + } + + @Override + public String camundaActivityId(CallbackParams callbackParams) { + return TASK_ID; + } + + @Override + public List handledEvents() { + return EVENTS; + } + + private CallbackResponse notifyApplicant1ForRequestJudgementByAdmission(CallbackParams callbackParams) { + CaseData caseData = callbackParams.getCaseData(); + + if (!caseData.isLipvLipOneVOne() || caseData.getApplicant1Email() == null) { + return AboutToStartOrSubmitCallbackResponse.builder().build(); + } + + notificationService.sendMail( + addEmail(caseData), + notificationsProperties.getNotifyApplicantLipRequestJudgementByAdmissionNotificationTemplate(), + addProperties(caseData), + String.format(REFERENCE_TEMPLATE, caseData.getLegacyCaseReference()) + ); + return AboutToStartOrSubmitCallbackResponse.builder().build(); + } + + @Override + public Map addProperties(CaseData caseData) { + return Map.of( + CLAIMANT_NAME, getPartyNameBasedOnType(caseData.getApplicant1()), + RESPONDENT_NAME, getPartyNameBasedOnType(caseData.getRespondent1()), + CLAIM_REFERENCE_NUMBER, caseData.getLegacyCaseReference(), + FRONTEND_URL, pipInPostConfiguration.getCuiFrontEndUrl() + ); + } + + private String addEmail(CaseData caseData) { + return caseData.getApplicant1Email(); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimantLipRequestJudgementByAdmissionRespondentNotificationHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimantLipRequestJudgementByAdmissionRespondentNotificationHandler.java new file mode 100644 index 00000000000..11ea01de632 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimantLipRequestJudgementByAdmissionRespondentNotificationHandler.java @@ -0,0 +1,83 @@ +package uk.gov.hmcts.reform.civil.handler.callback.camunda.notification; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; +import uk.gov.hmcts.reform.ccd.client.model.CallbackResponse; +import uk.gov.hmcts.reform.civil.callback.Callback; +import uk.gov.hmcts.reform.civil.callback.CallbackHandler; +import uk.gov.hmcts.reform.civil.callback.CallbackParams; +import uk.gov.hmcts.reform.civil.callback.CaseEvent; +import uk.gov.hmcts.reform.civil.config.PinInPostConfiguration; +import uk.gov.hmcts.reform.civil.model.CaseData; +import uk.gov.hmcts.reform.civil.notify.NotificationService; +import uk.gov.hmcts.reform.civil.notify.NotificationsProperties; + +import java.util.List; +import java.util.Map; + +import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_RESPONDENT1_FOR_REQUEST_JUDGEMENT_BY_ADMISSION_LIP_CLAIMANT; +import static uk.gov.hmcts.reform.civil.utils.PartyUtils.getPartyNameBasedOnType; + +@Service +@RequiredArgsConstructor +public class ClaimantLipRequestJudgementByAdmissionRespondentNotificationHandler extends CallbackHandler implements NotificationData { + + private static final List EVENTS = List.of( + NOTIFY_RESPONDENT1_FOR_REQUEST_JUDGEMENT_BY_ADMISSION_LIP_CLAIMANT); + public static final String TASK_ID = "RequestJudgementByAdmissionLipClaimantNotifyRespondent1"; + private static final String REFERENCE_TEMPLATE = "request-judgement-by-admission-respondent-notification-%s"; + + private final NotificationService notificationService; + private final NotificationsProperties notificationsProperties; + private final PinInPostConfiguration pipInPostConfiguration; + + @Override + protected Map callbacks() { + return Map.of( + callbackKey(ABOUT_TO_SUBMIT), + this::notifyRespondent1ForRequestJudgementByAdmission + ); + } + + @Override + public String camundaActivityId(CallbackParams callbackParams) { + return TASK_ID; + } + + @Override + public List handledEvents() { + return EVENTS; + } + + private CallbackResponse notifyRespondent1ForRequestJudgementByAdmission(CallbackParams callbackParams) { + CaseData caseData = callbackParams.getCaseData(); + + if (!caseData.isLipvLipOneVOne() || caseData.getRespondent1().getPartyEmail() == null) { + return AboutToStartOrSubmitCallbackResponse.builder().build(); + } + + notificationService.sendMail( + addEmail(caseData), + notificationsProperties.getNotifyRespondentLipRequestJudgementByAdmissionNotificationTemplate(), + addProperties(caseData), + String.format(REFERENCE_TEMPLATE, caseData.getLegacyCaseReference()) + ); + return AboutToStartOrSubmitCallbackResponse.builder().build(); + } + + @Override + public Map addProperties(CaseData caseData) { + return Map.of( + CLAIMANT_NAME, getPartyNameBasedOnType(caseData.getApplicant1()), + RESPONDENT_NAME, getPartyNameBasedOnType(caseData.getRespondent1()), + CLAIM_REFERENCE_NUMBER, caseData.getLegacyCaseReference(), + FRONTEND_URL, pipInPostConfiguration.getCuiFrontEndUrl() + ); + } + + private String addEmail(CaseData caseData) { + return caseData.getRespondent1().getPartyEmail(); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/CreateSDOApplicantsNotificationHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/CreateSDOApplicantsNotificationHandler.java index 7c69a19f9fe..c7ea157702d 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/CreateSDOApplicantsNotificationHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/CreateSDOApplicantsNotificationHandler.java @@ -57,18 +57,10 @@ public List handledEvents() { private CallbackResponse notifyApplicantsSolicitorSDOTriggered(CallbackParams callbackParams) { CaseData caseData = callbackParams.getCaseData(); - String unspecTemplate = featureToggleService.isEarlyAdoptersEnabled() - ? notificationsProperties.getSdoOrderedEA() : notificationsProperties.getSdoOrdered(); - - String specTemplate = featureToggleService.isEarlyAdoptersEnabled() - ? notificationsProperties.getSdoOrderedSpecEA() : notificationsProperties.getSdoOrderedSpec(); - notificationService.sendMail( - caseData.getApplicantSolicitor1UserDetails().getEmail(), - caseData.getCaseAccessCategory() == CaseCategory.SPEC_CLAIM - ? specTemplate - : unspecTemplate, - addProperties(caseData), + getRecipientEmail(caseData), + getNotificationTemplate(caseData), + getEmailProperties(caseData), String.format(REFERENCE_TEMPLATE, caseData.getLegacyCaseReference()) ); @@ -84,9 +76,45 @@ CLAIM_LEGAL_ORG_NAME_SPEC, getApplicantsLegalOrganizationName(caseData.getApplic ); } + public Map addPropertiesLip(CaseData caseData) { + return Map.of( + CLAIM_REFERENCE_NUMBER, caseData.getLegacyCaseReference(), + CLAIMANT_NAME, caseData.getApplicant1().getPartyName() + ); + } + public String getApplicantsLegalOrganizationName(String id, CaseData caseData) { Optional organisation = organisationService.findOrganisationById(id); return organisation.isPresent() ? organisation.get().getName() : caseData.getApplicantSolicitor1ClaimStatementOfTruth().getName(); } + + private String getNotificationTemplate(CaseData caseData) { + + String unspecTemplate = featureToggleService.isEarlyAdoptersEnabled() + ? notificationsProperties.getSdoOrderedEA() : notificationsProperties.getSdoOrdered(); + + String specTemplate = featureToggleService.isEarlyAdoptersEnabled() + ? notificationsProperties.getSdoOrderedSpecEA() : notificationsProperties.getSdoOrderedSpec(); + + if (caseData.isApplicantLiP()) { + return notificationsProperties.getClaimantLipClaimUpdatedTemplate(); + } else { + if (caseData.getCaseAccessCategory() == CaseCategory.SPEC_CLAIM) { + return specTemplate; + } else { + return unspecTemplate; + } + } + } + + private String getRecipientEmail(CaseData caseData) { + return caseData.isApplicantLiP() ? caseData.getClaimantUserDetails().getEmail() + : caseData.getApplicantSolicitor1UserDetails().getEmail(); + } + + private Map getEmailProperties(CaseData caseData) { + return caseData.isApplicantLiP() ? addPropertiesLip(caseData) + : addProperties(caseData); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/NotifyClaimantClaimSubmitted.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/NotifyClaimantClaimSubmitted.java index 5904bcff271..db83dd1d822 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/NotifyClaimantClaimSubmitted.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/NotifyClaimantClaimSubmitted.java @@ -8,9 +8,11 @@ import uk.gov.hmcts.reform.civil.callback.CallbackHandler; import uk.gov.hmcts.reform.civil.callback.CallbackParams; import uk.gov.hmcts.reform.civil.callback.CaseEvent; +import uk.gov.hmcts.reform.civil.config.PinInPostConfiguration; import uk.gov.hmcts.reform.civil.model.CaseData; import uk.gov.hmcts.reform.civil.notify.NotificationService; import uk.gov.hmcts.reform.civil.notify.NotificationsProperties; +import uk.gov.hmcts.reform.civil.service.FeatureToggleService; import java.util.List; import java.util.Map; @@ -27,6 +29,8 @@ public class NotifyClaimantClaimSubmitted extends CallbackHandler implements Not public static final String TASK_ID_Applicant1 = "NotifyApplicant1ClaimSubmitted"; private static final String REFERENCE_TEMPLATE = "claim-submitted-notification-%s"; private final NotificationService notificationService; + private final FeatureToggleService toggleService; + private final PinInPostConfiguration pipInPostConfiguration; private final NotificationsProperties notificationsProperties; private final Map callBackMap = Map.of( callbackKey(ABOUT_TO_SUBMIT), this::notifyApplicantForClaimSubmitted @@ -45,7 +49,7 @@ public String camundaActivityId(CallbackParams callbackParams) { private CallbackResponse notifyApplicantForClaimSubmitted(CallbackParams callbackParams) { CaseData caseData = callbackParams.getCaseData(); - if (Objects.isNull(caseData.getHelpWithFeesReferenceNumber())) { + if (caseData.isLipvLipOneVOne() && toggleService.isLipVLipEnabled()) { generateEmail(caseData); } @@ -61,15 +65,23 @@ public List handledEvents() { @Override public Map addProperties(CaseData caseData) { return Map.of( - CLAIMANT_NAME, getPartyNameBasedOnType(caseData.getApplicant1()) + CLAIMANT_NAME, getPartyNameBasedOnType(caseData.getApplicant1()), + DEFENDANT_NAME, getPartyNameBasedOnType(caseData.getRespondent1()), + FRONTEND_URL, pipInPostConfiguration.getCuiFrontEndUrl() ); } + private String addTemplate(CaseData caseData) { + return Objects.isNull(caseData.getHelpWithFeesReferenceNumber()) + ? notificationsProperties.getNotifyLiPClaimantClaimSubmittedAndPayClaimFeeTemplate() + : notificationsProperties.getNotifyLiPClaimantClaimSubmittedAndHelpWithFeeTemplate(); + } + private void generateEmail(CaseData caseData) { if (Objects.nonNull(caseData.getApplicant1Email())) { notificationService.sendMail( caseData.getApplicant1Email(), - notificationsProperties.getNotifyLiPClaimantClaimSubmittedAndPayClaimFeeTemplate(), + addTemplate(caseData), addProperties(caseData), String.format(REFERENCE_TEMPLATE, caseData.getLegacyCaseReference()) ); diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/ClaimantResponseCuiCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/ClaimantResponseCuiCallbackHandler.java index b42f274c8df..77008f21ffd 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/ClaimantResponseCuiCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/ClaimantResponseCuiCallbackHandler.java @@ -15,11 +15,13 @@ import uk.gov.hmcts.reform.civil.model.CaseData; import uk.gov.hmcts.reform.civil.service.citizenui.ResponseOneVOneShowTagService; import uk.gov.hmcts.reform.civil.service.citizen.UpdateCaseManagementDetailsService; +import uk.gov.hmcts.reform.civil.service.Time; import java.time.LocalDateTime; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Objects; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_START; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; @@ -36,6 +38,7 @@ public class ClaimantResponseCuiCallbackHandler extends CallbackHandler { private final ResponseOneVOneShowTagService responseOneVOneService; private final ObjectMapper objectMapper; + private final Time time; private final UpdateCaseManagementDetailsService updateCaseManagementLocationDetailsService; @Override @@ -72,21 +75,39 @@ private CallbackResponse aboutToSubmit(CallbackParams callbackParams) { CaseData updatedData = builder.build(); AboutToStartOrSubmitCallbackResponse.AboutToStartOrSubmitCallbackResponseBuilder response = - AboutToStartOrSubmitCallbackResponse.builder() - .data(updatedData.toMap(objectMapper)); + AboutToStartOrSubmitCallbackResponse.builder() + .data(updatedData.toMap(objectMapper)); + updateClaimStateJudicialReferral(response, updatedData); updateClaimEndState(response, updatedData); return response.build(); } + private void updateClaimStateJudicialReferral( + AboutToStartOrSubmitCallbackResponse.AboutToStartOrSubmitCallbackResponseBuilder response, + CaseData caseData) { + if (isJudicialReferralAllowed(caseData)) { + response.state(CaseState.JUDICIAL_REFERRAL.name()); + } + } + + private boolean isJudicialReferralAllowed(CaseData caseData) { + return (caseData.isClaimantNotSettlePartAdmitClaim() || caseData.isFullDefence()) + && (Objects.nonNull(caseData.getCaseDataLiP()) && caseData.getCaseDataLiP().hasClaimantNotAgreedToFreeMediation()); + } + private void updateClaimEndState(AboutToStartOrSubmitCallbackResponse.AboutToStartOrSubmitCallbackResponseBuilder response, CaseData updatedData) { - if (updatedData.hasClaimantAgreedToFreeMediation()) { + if (updatedData.hasClaimantAgreedToFreeMediation() && updatedData.hasDefendantAgreedToFreeMediation()) { response.state(CaseState.IN_MEDIATION.name()); + } else if (updatedData.hasApplicant1SignedSettlementAgreement() && updatedData.hasApplicantAcceptedRepaymentPlan()) { + response.state(CaseState.All_FINAL_ORDERS_ISSUED.name()); + } else if (!updatedData.hasApplicantProceededWithClaim()) { + response.state(updatedData.isClaimantConfirmAmountPaidPartAdmit() || updatedData.hasDefendantPayedTheAmountClaimed() + ? CaseState.CASE_SETTLED.name() + : CaseState.CASE_DISMISSED.name()); } else if (updatedData.hasApplicantRejectedRepaymentPlan() && updatedData.getRespondent1().isCompanyOROrganisation()) { response.state(CaseState.PROCEEDS_IN_HERITAGE_SYSTEM.name()); - } else { - response.state(CaseState.JUDICIAL_REFERRAL.name()); } } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/CreateClaimCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/CreateClaimCallbackHandler.java index 2f19c71c23e..5e9b9441fa4 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/CreateClaimCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/CreateClaimCallbackHandler.java @@ -19,7 +19,6 @@ import uk.gov.hmcts.reform.civil.config.ToggleConfiguration; import uk.gov.hmcts.reform.civil.enums.CaseCategory; import uk.gov.hmcts.reform.civil.enums.CaseState; -import uk.gov.hmcts.reform.civil.enums.MultiPartyScenario; import uk.gov.hmcts.reform.civil.enums.YesOrNo; import uk.gov.hmcts.reform.civil.helpers.LocationHelper; import uk.gov.hmcts.reform.civil.model.BusinessProcess; @@ -78,11 +77,11 @@ import static uk.gov.hmcts.reform.civil.enums.AllocatedTrack.getAllocatedTrack; import static uk.gov.hmcts.reform.civil.enums.CaseRole.APPLICANTSOLICITORONE; import static uk.gov.hmcts.reform.civil.enums.CaseRole.RESPONDENTSOLICITORTWO; -import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.getMultiPartyScenario; import static uk.gov.hmcts.reform.civil.enums.YesOrNo.NO; import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES; import static uk.gov.hmcts.reform.civil.utils.CaseListSolicitorReferenceUtils.getAllDefendantSolicitorReferences; import static uk.gov.hmcts.reform.civil.utils.CaseListSolicitorReferenceUtils.getAllOrganisationPolicyReferences; +import static uk.gov.hmcts.reform.civil.utils.CaseNameUtils.buildCaseNameInternal; import static uk.gov.hmcts.reform.civil.utils.ElementUtils.element; import static uk.gov.hmcts.reform.civil.utils.PartyUtils.getAllPartyNames; import static uk.gov.hmcts.reform.civil.utils.PartyUtils.populateWithPartyIds; @@ -483,10 +482,8 @@ private CallbackResponse submitClaim(CallbackParams callbackParams) { handleCourtLocationData(caseData, dataBuilder, callbackParams); - if (toggleService.isNoticeOfChangeEnabled()) { - // LiP are not represented or registered - OrgPolicyUtils.addMissingOrgPolicies(dataBuilder); - } + // LiP are not represented or registered + OrgPolicyUtils.addMissingOrgPolicies(dataBuilder); // temporarily default to yes for CIV-2659 if (YES.equals(caseData.getRespondent1Represented()) && caseData.getRespondent1OrgRegistered() == null) { @@ -499,7 +496,7 @@ private CallbackResponse submitClaim(CallbackParams callbackParams) { //assign casemanagementcategory to the case and assign casenamehmctsinternal //casename - dataBuilder.caseNameHmctsInternal(caseParticipants(caseData).toString()); + dataBuilder.caseNameHmctsInternal(buildCaseNameInternal(caseData)); //case management category CaseManagementCategoryElement civil = @@ -511,20 +508,17 @@ private CallbackResponse submitClaim(CallbackParams callbackParams) { log.info("Case management equals: " + caseData.getCaseManagementCategory()); log.info("CaseName equals: " + caseData.getCaseNameHmctsInternal()); - //Adding variables for feature Certificate of Service - if (toggleService.isCertificateOfServiceEnabled()) { - if (caseData.getRespondent1Represented().equals(NO)) { - dataBuilder.defendant1LIPAtClaimIssued(YES); - } else { - dataBuilder.defendant1LIPAtClaimIssued(NO); - } + if (caseData.getRespondent1Represented().equals(NO)) { + dataBuilder.defendant1LIPAtClaimIssued(YES); + } else { + dataBuilder.defendant1LIPAtClaimIssued(NO); + } - if (YES.equals(caseData.getAddRespondent2())) { - if (caseData.getRespondent2Represented() == NO) { - dataBuilder.defendant2LIPAtClaimIssued(YES); - } else { - dataBuilder.defendant2LIPAtClaimIssued(NO); - } + if (YES.equals(caseData.getAddRespondent2())) { + if (caseData.getRespondent2Represented() == NO) { + dataBuilder.defendant2LIPAtClaimIssued(YES); + } else { + dataBuilder.defendant2LIPAtClaimIssued(NO); } } //assign category ids to documents uploaded as part of particulars of claim @@ -607,18 +601,11 @@ private boolean isSecondRespondentLitigantInPerson(CaseData caseData) { private String getBody(CaseData caseData) { return areRespondentsRepresentedAndRegistered(caseData) ? getConfirmationSummary(caseData) - : toggleService.isCertificateOfServiceEnabled() - ? format(CONFIRMATION_BODY_LIP_COS, + : format(CONFIRMATION_BODY_LIP_COS, format("/cases/case-details/%s#Service%%20Request", caseData.getCcdCaseReference()), format(caseDocLocation, caseData.getCcdCaseReference()), claimUrlsConfiguration.getResponsePackLink()) - + exitSurveyContentService.applicantSurvey() - : format(CONFIRMATION_BODY_COS, - format("/cases/case-details/%s#Service%%20Request", caseData.getCcdCaseReference()), - format(caseDocLocation, caseData.getCcdCaseReference()), - claimUrlsConfiguration.getResponsePackLink()) - + exitSurveyContentService.applicantSurvey(); - + + exitSurveyContentService.applicantSurvey(); } private String getConfirmationSummary(CaseData caseData) { @@ -639,30 +626,6 @@ private List validateCourtChoice(CaseData caseData) { return errorsMessages; } - public StringBuilder caseParticipants(CaseData caseData) { - StringBuilder participantString = new StringBuilder(); - MultiPartyScenario multiPartyScenario = getMultiPartyScenario(caseData); - if (multiPartyScenario.equals(MultiPartyScenario.ONE_V_TWO_ONE_LEGAL_REP) - || multiPartyScenario.equals(MultiPartyScenario.ONE_V_TWO_TWO_LEGAL_REP)) { - participantString.append(caseData.getApplicant1().getPartyName()) - .append(" v ").append(caseData.getRespondent1().getPartyName()) - .append(" and ").append(caseData.getRespondent2().getPartyName()); - - } else if (multiPartyScenario.equals(MultiPartyScenario.TWO_V_ONE)) { - participantString.append(caseData.getApplicant1().getPartyName()) - .append(" and ").append(caseData.getApplicant2().getPartyName()).append(" v ") - .append(caseData.getRespondent1() - .getPartyName()); - - } else { - participantString.append(caseData.getApplicant1().getPartyName()).append(" v ") - .append(caseData.getRespondent1() - .getPartyName()); - } - return participantString; - - } - private void handleCourtLocationData(CaseData caseData, CaseData.CaseDataBuilder dataBuilder, CallbackParams callbackParams) { // data for court location diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/CreateClaimSpecCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/CreateClaimSpecCallbackHandler.java index 7dc8d457b95..43e1f27e4f0 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/CreateClaimSpecCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/CreateClaimSpecCallbackHandler.java @@ -11,6 +11,7 @@ import uk.gov.hmcts.reform.ccd.client.model.SubmittedCallbackResponse; import uk.gov.hmcts.reform.ccd.model.OrganisationPolicy; import uk.gov.hmcts.reform.civil.callback.Callback; +import uk.gov.hmcts.reform.civil.callback.CallbackException; import uk.gov.hmcts.reform.civil.callback.CallbackHandler; import uk.gov.hmcts.reform.civil.callback.CallbackParams; import uk.gov.hmcts.reform.civil.callback.CaseEvent; @@ -18,15 +19,17 @@ import uk.gov.hmcts.reform.civil.config.ClaimUrlsConfiguration; import uk.gov.hmcts.reform.civil.enums.CaseCategory; import uk.gov.hmcts.reform.civil.enums.ClaimType; -import uk.gov.hmcts.reform.civil.enums.MultiPartyScenario; import uk.gov.hmcts.reform.civil.enums.YesOrNo; import uk.gov.hmcts.reform.civil.model.Address; +import uk.gov.hmcts.reform.civil.service.AirlineEpimsDataLoader; +import uk.gov.hmcts.reform.civil.model.AirlineEpimsId; import uk.gov.hmcts.reform.civil.model.BusinessProcess; import uk.gov.hmcts.reform.civil.model.CaseData; import uk.gov.hmcts.reform.civil.model.CaseManagementCategory; import uk.gov.hmcts.reform.civil.model.CaseManagementCategoryElement; import uk.gov.hmcts.reform.civil.model.ClaimAmountBreakup; import uk.gov.hmcts.reform.civil.model.CorrectEmail; +import uk.gov.hmcts.reform.civil.model.FlightDelayDetails; import uk.gov.hmcts.reform.civil.model.IdamUserDetails; import uk.gov.hmcts.reform.civil.model.Party; import uk.gov.hmcts.reform.civil.model.PaymentDetails; @@ -38,8 +41,11 @@ import uk.gov.hmcts.reform.civil.model.common.Element; import uk.gov.hmcts.reform.civil.model.defaultjudgment.CaseLocationCivil; import uk.gov.hmcts.reform.civil.prd.model.Organisation; +import uk.gov.hmcts.reform.civil.referencedata.LocationRefDataService; +import uk.gov.hmcts.reform.civil.referencedata.model.LocationRefData; import uk.gov.hmcts.reform.civil.repositories.ReferenceNumberRepository; import uk.gov.hmcts.reform.civil.repositories.SpecReferenceNumberRepository; +import uk.gov.hmcts.reform.civil.service.AirlineEpimsService; import uk.gov.hmcts.reform.civil.service.ExitSurveyContentService; import uk.gov.hmcts.reform.civil.service.FeatureToggleService; import uk.gov.hmcts.reform.civil.service.FeesService; @@ -88,6 +94,7 @@ import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES; import static uk.gov.hmcts.reform.civil.helpers.DateFormatHelper.DATE_TIME_AT; import static uk.gov.hmcts.reform.civil.helpers.DateFormatHelper.formatLocalDateTime; +import static uk.gov.hmcts.reform.civil.utils.CaseNameUtils.buildCaseNameInternal; import static uk.gov.hmcts.reform.civil.utils.ElementUtils.element; import static uk.gov.hmcts.reform.civil.utils.PartyUtils.populateWithPartyIds; @@ -156,6 +163,10 @@ public class CreateClaimSpecCallbackHandler extends CallbackHandler implements P + "to : OCMCNton@justice.gov.uk. The Certificate of Service form can be found here:" + "%n%n"; + private static final String ERROR_MESSAGE_SCHEDULED_DATE_OF_FLIGHT_MUST_BE_TODAY_OR_IN_THE_PAST = "Scheduled date of flight must be today or in the past"; + + private static final String LOCATION_NOT_FOUND_MESSAGE = "Location not found for ePIMS_ID: %s"; + private final ClaimUrlsConfiguration claimUrlsConfiguration; private final ExitSurveyContentService exitSurveyContentService; private final ReferenceNumberRepository referenceNumberRepository; @@ -176,7 +187,10 @@ public class CreateClaimSpecCallbackHandler extends CallbackHandler implements P private final StateFlowEngine stateFlowEngine; private final CaseFlagsInitialiser caseFlagInitialiser; private final ToggleConfiguration toggleConfiguration; + private final LocationRefDataService locationRefDataService; private final String caseDocLocation = "/cases/case-details/%s#CaseDocuments"; + private final AirlineEpimsDataLoader airlineEpimsDataLoader; + private final AirlineEpimsService airlineEpimsService; @Value("${court-location.specified-claim.region-id}") private String regionId; @@ -232,6 +246,8 @@ protected Map callbacks() { .put(callbackKey(MID, "validate-spec-defendant-legal-rep-email"), this::validateSpecRespondentRepEmail) .put(callbackKey(MID, "validate-spec-defendant2-legal-rep-email"), this::validateSpecRespondent2RepEmail) .put(callbackKey(MID, "is-flight-delay-claim"), this::isFlightDelayClaim) + .put(callbackKey(MID, "get-airline-list"), this::getAirlineList) + .put(callbackKey(MID, "validate-date-of-flight"), this::validateDateOfFlight) .build(); } @@ -461,7 +477,7 @@ private CallbackResponse submitClaim(CallbackParams callbackParams) { dataBuilder.featureToggleWA(toggleConfiguration.getFeatureToggle()); //assign case management category to the case and caseNameHMCTSinternal - dataBuilder.caseNameHmctsInternal(caseParticipants(caseData).toString()); + dataBuilder.caseNameHmctsInternal(buildCaseNameInternal(caseData)); CaseManagementCategoryElement civil = CaseManagementCategoryElement.builder().code("Civil").label("Civil").build(); @@ -472,9 +488,7 @@ private CallbackResponse submitClaim(CallbackParams callbackParams) { log.info("Case management equals: " + caseData.getCaseManagementCategory()); log.info("CaseName equals: " + caseData.getCaseNameHmctsInternal()); - if (featureToggleService.isNoticeOfChangeEnabled()) { - OrgPolicyUtils.addMissingOrgPolicies(dataBuilder); - } + OrgPolicyUtils.addMissingOrgPolicies(dataBuilder); caseFlagInitialiser.initialiseCaseFlags(CREATE_CLAIM_SPEC, dataBuilder); @@ -525,7 +539,6 @@ private CallbackResponse submitClaim(CallbackParams callbackParams) { populateWithPartyIds(dataBuilder); } - List errors = new ArrayList<>(); if (caseData.getSdtRequestIdFromSdt() != null) { // assign StdRequestId, to ensure duplicate requests from SDT/bulk claims are not processed List> stdRequestIdList = new ArrayList<>(); @@ -542,6 +555,7 @@ private CallbackResponse submitClaim(CallbackParams callbackParams) { .build()).build()); } + List errors = new ArrayList<>(); if (getMultiPartyScenario(caseData) == ONE_V_TWO_ONE_LEGAL_REP && caseData.getSpecRespondentCorrespondenceAddressdetails() != null) { // to keep with heading tab @@ -552,6 +566,19 @@ private CallbackResponse submitClaim(CallbackParams callbackParams) { caseData.getSpecRespondentCorrespondenceAddressdetails()); } + if ((toggleService.isSdoR2Enabled() && callbackParams.getCaseData().getFlightDelayDetails() != null)) { + FlightDelayDetails flightDelayDetails = callbackParams.getCaseData().getFlightDelayDetails(); + String selectedAirlineCode = flightDelayDetails.getAirlineList().getValue().getCode(); + + dataBuilder.flightDelayDetails(FlightDelayDetails.builder() + .airlineList(DynamicList.builder().value(flightDelayDetails.getAirlineList().getValue()).build()) + .nameOfAirline(flightDelayDetails.getNameOfAirline()) + .flightNumber(flightDelayDetails.getFlightNumber()) + .scheduledDate(flightDelayDetails.getScheduledDate()) + .flightCourtLocation(getAirlineCaseLocation(selectedAirlineCode, callbackParams)) + .build()); + } + return AboutToStartOrSubmitCallbackResponse.builder() .errors(errors) .data(dataBuilder.build().toMap(objectMapper)) @@ -919,6 +946,36 @@ private CallbackResponse isFlightDelayClaim(CallbackParams callbackParams) { .build(); } + private CallbackResponse getAirlineList(CallbackParams callbackParams) { + CaseData.CaseDataBuilder caseDataBuilder = callbackParams.getCaseData().toBuilder(); + List airlineEpimsIDList = new ArrayList<>(airlineEpimsDataLoader.getAirlineEpimsIDList()); + DynamicList airlineList = DynamicList + .fromList(airlineEpimsIDList.stream() + .map(AirlineEpimsId::getAirline).toList(), Object::toString, Object::toString, null, false); + DynamicList dropdownAirlineList = DynamicList.builder() + .listItems(airlineList.getListItems()).build(); + + FlightDelayDetails flightDelayDetails = FlightDelayDetails.builder().airlineList(dropdownAirlineList).build(); + caseDataBuilder.flightDelayDetails(flightDelayDetails); + return AboutToStartOrSubmitCallbackResponse.builder() + .data(caseDataBuilder.build().toMap(objectMapper)) + .build(); + } + + private CallbackResponse validateDateOfFlight(CallbackParams callbackParams) { + CaseData.CaseDataBuilder caseDataBuilder = callbackParams.getCaseData().toBuilder(); + List errors = new ArrayList<>(); + LocalDate today = LocalDate.now(); + LocalDate scheduledDate = callbackParams.getCaseData().getFlightDelayDetails().getScheduledDate(); + if (scheduledDate.isAfter(today)) { + errors.add(ERROR_MESSAGE_SCHEDULED_DATE_OF_FLIGHT_MUST_BE_TODAY_OR_IN_THE_PAST); + } + return AboutToStartOrSubmitCallbackResponse.builder() + .data(caseDataBuilder.build().toMap(objectMapper)) + .errors(errors) + .build(); + } + private CallbackResponse setRespondent2SameLegalRepToNo(CallbackParams callbackParams) { CaseData.CaseDataBuilder caseDataBuilder = callbackParams.getCaseData().toBuilder(); @@ -946,27 +1003,24 @@ private boolean areRespondentsRepresentedAndRegistered(CaseData caseData) { || caseData.getRespondent2OrgRegistered() == NO); } - public StringBuilder caseParticipants(CaseData caseData) { - StringBuilder participantString = new StringBuilder(); - MultiPartyScenario multiPartyScenario = getMultiPartyScenario(caseData); - if (multiPartyScenario.equals(MultiPartyScenario.ONE_V_TWO_ONE_LEGAL_REP) - || multiPartyScenario.equals(MultiPartyScenario.ONE_V_TWO_TWO_LEGAL_REP)) { - participantString.append(caseData.getApplicant1().getPartyName()) - .append(" v ").append(caseData.getRespondent1().getPartyName()) - .append(" and ").append(caseData.getRespondent2().getPartyName()); - - } else if (multiPartyScenario.equals(MultiPartyScenario.TWO_V_ONE)) { - participantString.append(caseData.getApplicant1().getPartyName()) - .append(" and ").append(caseData.getApplicant2().getPartyName()).append(" v ") - .append(caseData.getRespondent1() - .getPartyName()); - + private CaseLocationCivil getAirlineCaseLocation(String airline, CallbackParams callbackParams) { + if (airline.equals("OTHER")) { + return null; + } + String locationEpimmsId = airlineEpimsService.getEpimsIdForAirline(airline); + List locations = fetchLocationData(callbackParams); + var matchedLocations = locations.stream().filter(loc -> loc.getEpimmsId().equals(locationEpimmsId)).toList(); + if (matchedLocations.isEmpty()) { + throw new CallbackException(String.format(LOCATION_NOT_FOUND_MESSAGE, locationEpimmsId)); } else { - participantString.append(caseData.getApplicant1().getPartyName()).append(" v ") - .append(caseData.getRespondent1() - .getPartyName()); + return CaseLocationCivil.builder() + .region(matchedLocations.get(0).getRegionId()) + .baseLocation(matchedLocations.get(0).getEpimmsId()).build(); } - return participantString; + } + private List fetchLocationData(CallbackParams callbackParams) { + String authToken = callbackParams.getParams().get(BEARER_TOKEN).toString(); + return locationRefDataService.getCourtLocationsForDefaultJudgments(authToken); } } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/DefendantSignSettlementAgreementCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/DefendantSignSettlementAgreementCallbackHandler.java new file mode 100644 index 00000000000..4a721827ddb --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/DefendantSignSettlementAgreementCallbackHandler.java @@ -0,0 +1,56 @@ +package uk.gov.hmcts.reform.civil.handler.callback.user; + +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; +import uk.gov.hmcts.reform.ccd.client.model.CallbackResponse; +import uk.gov.hmcts.reform.civil.callback.Callback; +import uk.gov.hmcts.reform.civil.callback.CallbackHandler; +import uk.gov.hmcts.reform.civil.callback.CallbackParams; +import uk.gov.hmcts.reform.civil.callback.CaseEvent; +import uk.gov.hmcts.reform.civil.model.BusinessProcess; +import uk.gov.hmcts.reform.civil.model.CaseData; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_START; +import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; +import static uk.gov.hmcts.reform.civil.callback.CallbackType.SUBMITTED; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.DEFENDANT_SIGN_SETTLEMENT_AGREEMENT; + +@Service +@RequiredArgsConstructor +public class DefendantSignSettlementAgreementCallbackHandler extends CallbackHandler { + + private final ObjectMapper objectMapper; + + private final Map callbackMap = Map.of( + callbackKey(ABOUT_TO_START), this::emptyCallbackResponse, + callbackKey(ABOUT_TO_SUBMIT), this::aboutToSubmit, + callbackKey(SUBMITTED), this::emptySubmittedCallbackResponse); + + @Override + protected Map callbacks() { + return callbackMap; + } + + @Override + public List handledEvents() { + return Collections.singletonList( + DEFENDANT_SIGN_SETTLEMENT_AGREEMENT + ); + } + + private CallbackResponse aboutToSubmit(CallbackParams callbackParams) { + CaseData caseDataUpdated = callbackParams.getCaseData().toBuilder() + .businessProcess(BusinessProcess.ready(DEFENDANT_SIGN_SETTLEMENT_AGREEMENT)) + .build(); + + return AboutToStartOrSubmitCallbackResponse.builder() + .data(caseDataUpdated.toMap(objectMapper)) + .build(); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadHandlerBase.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadHandlerBase.java index 5277c8351c6..c5ef42454a2 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadHandlerBase.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadHandlerBase.java @@ -455,8 +455,8 @@ private void renameDocuments(List> documentUpload, String theId) RESPONDENT_TWO_WITNESS_REFERRED, APPLICANT_WITNESS_REFERRED, APPLICANT_TWO_WITNESS_REFERRED: - prefix = "Referred Document"; - renameUploadEvidenceDocumentType(documentUpload, prefix); + prefix = " referred to in the statement of "; + renameUploadEvidenceDocumentTypeWithName(documentUpload, prefix); break; case RESPONDENT_ONE_TRIAL_DOC_CORRESPONDENCE, RESPONDENT_TWO_TRIAL_DOC_CORRESPONDENCE, @@ -564,6 +564,21 @@ private void renameUploadEvidenceExpert(final List> documentUploa }); } + private void renameUploadEvidenceDocumentTypeWithName(final List> documentUpload, String body) { + documentUpload.forEach(x -> { + UploadEvidenceDocumentType type = (UploadEvidenceDocumentType) x.getValue(); + String ext = FilenameUtils.getExtension(type.getDocumentUpload().getDocumentFileName()); + String newName = type.getTypeOfDocument() + + body + + type.getWitnessOptionName() + + SPACE + + type.getDocumentIssuedDate() + .format(DateTimeFormatter.ofPattern(DATE_FORMAT, Locale.UK)) + + END + ext; + type.getDocumentUpload().setDocumentFileName(newName); + }); + } + private void renameUploadEvidenceDocumentType(final List> documentUpload, String prefix) { documentUpload.forEach(x -> { UploadEvidenceDocumentType type = (UploadEvidenceDocumentType) x.getValue(); @@ -1010,6 +1025,7 @@ private List> deepCopyUploadEvidenceDocument .documentUrl(from.getValue().getDocumentUpload().getDocumentUrl()) .build(); UploadEvidenceDocumentType type = UploadEvidenceDocumentType.builder() + .witnessOptionName(from.getValue().getWitnessOptionName()) .documentIssuedDate(from.getValue().getDocumentIssuedDate()) .typeOfDocument(from.getValue().getTypeOfDocument()) .createdDatetime(from.getValue().getCreatedDatetime()) @@ -1149,6 +1165,7 @@ void addUploadDocList(List> uploadedEvidence && uploadEvidenceDocumentType.getValue().getCreatedDatetime() .isAfter(bundleDetails.get().getCreatedOn().get())) { uploadedEvidenceAfterBundle.add(ElementUtils.element(UploadEvidenceDocumentType.builder() + .witnessOptionName(uploadEvidenceDocumentType.getValue().getWitnessOptionName()) .typeOfDocument(docType) .createdDatetime(uploadEvidenceDocumentType.getValue().getCreatedDatetime()) .documentUpload(uploadEvidenceDocumentType.getValue().getDocumentUpload()) diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadJudgeHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadJudgeHandler.java index 12ca69bdb86..97086348cb3 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadJudgeHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadJudgeHandler.java @@ -18,12 +18,14 @@ import uk.gov.hmcts.reform.civil.model.documents.DocumentWithName; import uk.gov.hmcts.reform.civil.service.CaseNoteService; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.stream.IntStream; import static java.lang.String.format; +import static java.util.Objects.nonNull; import static uk.gov.hmcts.reform.civil.callback.CallbackParams.Params.BEARER_TOKEN; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_START; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; @@ -75,10 +77,11 @@ private AboutToStartOrSubmitCallbackResponse removeCaseNoteType(CallbackParams c private AboutToStartOrSubmitCallbackResponse populateSubmittedDateTime(CallbackParams callbackParams) { var caseData = callbackParams.getCaseData(); CaseData.CaseDataBuilder caseDataBuilder = caseData.toBuilder(); + String userAuth = callbackParams.getParams().get(BEARER_TOKEN).toString(); if (caseData.getCaseNoteType().equals(CaseNoteType.NOTE_ONLY)) { CaseNote caseNoteTA = caseNoteService.buildCaseNote( - callbackParams.getParams().get(BEARER_TOKEN).toString(), + userAuth, caseData.getCaseNoteTA() ); @@ -92,35 +95,28 @@ private AboutToStartOrSubmitCallbackResponse populateSubmittedDateTime(CallbackP if (caseData.getCaseNoteType().equals(CaseNoteType.DOCUMENT_ONLY)) { List> documentAndNameToAdd = caseData.getDocumentAndNameToAdd(); - List> documentAndNameCurrent = caseData.getDocumentAndName(); - - if (documentAndNameCurrent == null) { - documentAndNameCurrent = documentAndNameToAdd; - } else { - for (Element document : documentAndNameToAdd) { - documentAndNameCurrent.add(document); - } + List> documentAndNameCurrent = new ArrayList<>(); + if (nonNull(caseData.getDocumentAndName())) { + documentAndNameCurrent.addAll(caseData.getDocumentAndName()); } - caseDataBuilder - .documentAndName(documentAndNameCurrent) - .build(); + documentAndNameToAdd.forEach(documentAndName -> { + List> newJudgeCaseNoteDocumentAndName = caseNoteService.buildJudgeCaseNoteDocumentAndName(documentAndName.getValue(), userAuth); + documentAndNameCurrent.addAll(newJudgeCaseNoteDocumentAndName); + }); + caseDataBuilder.documentAndName(documentAndNameCurrent); } if (caseData.getCaseNoteType().equals(CaseNoteType.DOCUMENT_AND_NOTE)) { List> documentAndNoteToAdd = caseData.getDocumentAndNoteToAdd(); - List> documentAndNoteCurrent = caseData.getDocumentAndNote(); - - if (documentAndNoteCurrent == null) { - documentAndNoteCurrent = documentAndNoteToAdd; - } else { - for (Element document : documentAndNoteToAdd) { - documentAndNoteCurrent.add(document); - } + List> documentAndNoteCurrent = new ArrayList<>(); + if (nonNull(caseData.getDocumentAndNote())) { + documentAndNoteCurrent.addAll(caseData.getDocumentAndNote()); } - caseDataBuilder - .documentAndNote(documentAndNoteCurrent) - .build(); - + documentAndNoteToAdd.forEach(documentAndNote -> { + List> newJudgeCaseNoteAndDocument = caseNoteService.buildJudgeCaseNoteAndDocument(documentAndNote.getValue(), userAuth); + documentAndNoteCurrent.addAll(newJudgeCaseNoteAndDocument); + }); + caseDataBuilder.documentAndNote(documentAndNoteCurrent); } return AboutToStartOrSubmitCallbackResponse.builder() diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/ManageContactInformationCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/ManageContactInformationCallbackHandler.java index 1ce5e75b370..3100b3e1253 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/ManageContactInformationCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/ManageContactInformationCallbackHandler.java @@ -18,6 +18,7 @@ import uk.gov.hmcts.reform.civil.model.CaseData; import uk.gov.hmcts.reform.civil.model.LitigationFriend; import uk.gov.hmcts.reform.civil.model.Party; +import uk.gov.hmcts.reform.civil.model.PartyFlagStructure; import uk.gov.hmcts.reform.civil.model.UpdateDetailsForm; import uk.gov.hmcts.reform.civil.model.UpdatePartyDetailsForm; import uk.gov.hmcts.reform.civil.model.common.DynamicList; @@ -45,12 +46,14 @@ import static uk.gov.hmcts.reform.civil.callback.CaseEvent.MANAGE_CONTACT_INFORMATION; import static uk.gov.hmcts.reform.civil.enums.CaseCategory.SPEC_CLAIM; import static uk.gov.hmcts.reform.civil.enums.CaseState.AWAITING_APPLICANT_INTENTION; +import static uk.gov.hmcts.reform.civil.enums.CaseState.AWAITING_RESPONDENT_ACKNOWLEDGEMENT; import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.ONE_V_TWO_TWO_LEGAL_REP; import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.getMultiPartyScenario; import static uk.gov.hmcts.reform.civil.enums.YesOrNo.NO; import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES; -import static uk.gov.hmcts.reform.civil.utils.CaseFlagUtils.addApplicantExpertAndWitnessFlagsStructure; -import static uk.gov.hmcts.reform.civil.utils.CaseFlagUtils.addRespondentDQPartiesFlagStructure; +import static uk.gov.hmcts.reform.civil.utils.CaseNameUtils.buildCaseNameInternal; +import static uk.gov.hmcts.reform.civil.utils.CaseNameUtils.buildCaseNamePublic; +import static uk.gov.hmcts.reform.civil.utils.ElementUtils.unwrapElements; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_ONE_EXPERTS_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_ONE_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_ONE_LITIGATION_FRIEND_ID; @@ -75,6 +78,8 @@ import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.mapUpdatePartyDetailsFormToDQExperts; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.mapUpdatePartyDetailsFormToDQWitnesses; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.mapWitnessesToUpdatePartyDetailsForm; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.updatePartyDQExperts; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.updatePartyDQWitnesses; import static uk.gov.hmcts.reform.civil.utils.UserRoleUtils.isApplicantSolicitor; import static uk.gov.hmcts.reform.civil.utils.UserRoleUtils.isRespondentSolicitorOne; import static uk.gov.hmcts.reform.civil.utils.UserRoleUtils.isRespondentSolicitorTwo; @@ -125,7 +130,7 @@ private CallbackResponse prepareEvent(CallbackParams callbackParams) { UserInfo userInfo = userService.getUserInfo(authToken); boolean isAdmin = isAdmin(authToken); - List errors = isAwaitingClaimantIntention(caseData) + List errors = isBeforeAwaitingApplicantIntention(caseData) && !isAdmin ? List.of(INVALID_CASE_STATE_ERROR) : null; if (errors != null) { @@ -343,10 +348,17 @@ private Boolean isLitigationFriend(String partyChosen) { private CallbackResponse submitChanges(CallbackParams callbackParams) { CaseData caseData = callbackParams.getCaseData(); CaseData.CaseDataBuilder builder = caseData.toBuilder(); + String partyChosen = caseData.getUpdateDetailsForm().getPartyChosen().getValue().getCode(); updateExperts(caseData.getUpdateDetailsForm().getPartyChosenId(), caseData, builder); updateWitnesses(caseData.getUpdateDetailsForm().getPartyChosenId(), caseData, builder); + if (isParty(partyChosen) || isLitigationFriend(partyChosen)) { + // update case name for hmc if applicant/respondent/litigation friend was updated + builder.caseNameHmctsInternal(buildCaseNameInternal(caseData)); + builder.caseNamePublic(buildCaseNamePublic(caseData)); + } + // last step before clearing update details form caseFlagsInitialiser.initialiseCaseFlags(MANAGE_CONTACT_INFORMATION, builder); @@ -386,8 +398,11 @@ private void updateExperts(String partyId, CaseData caseData, CaseData.CaseDataB .details(mappedExperts) .build()) .build()); - addApplicantExpertAndWitnessFlagsStructure(builder, caseData); - //TODO: need to add it to top level party object + List> updatedApplicantExperts = updatePartyDQExperts( + unwrapElements(caseData.getApplicantExperts()), + unwrapElements(mappedExperts) + ); + builder.applicantExperts(updatedApplicantExperts); } else if (partyId.equals(DEFENDANT_ONE_EXPERTS_ID)) { mappedExperts = mapUpdatePartyDetailsFormToDQExperts( caseData.getRespondent1DQ().getRespondent1DQExperts().getDetails(), formData); @@ -398,8 +413,11 @@ private void updateExperts(String partyId, CaseData caseData, CaseData.CaseDataB .details(mappedExperts) .build()) .build()); - addRespondentDQPartiesFlagStructure(builder, caseData); - //TODO: need to add it to top level party object + List> updatedRespondent1Experts = updatePartyDQExperts( + unwrapElements(caseData.getRespondent1Experts()), + unwrapElements(mappedExperts) + ); + builder.respondent1Experts(updatedRespondent1Experts); } else if (partyId.equals(DEFENDANT_TWO_EXPERTS_ID)) { mappedExperts = mapUpdatePartyDetailsFormToDQExperts( caseData.getRespondent2DQ().getRespondent2DQExperts().getDetails(), formData); @@ -410,8 +428,11 @@ private void updateExperts(String partyId, CaseData caseData, CaseData.CaseDataB .details(mappedExperts) .build()) .build()); - addRespondentDQPartiesFlagStructure(builder, caseData); - //TODO: need to add it to top level party object + List> updatedRespondent2Experts = updatePartyDQExperts( + unwrapElements(caseData.getRespondent2Experts()), + unwrapElements(mappedExperts) + ); + builder.respondent2Experts(updatedRespondent2Experts); } } @@ -430,8 +451,11 @@ private void updateWitnesses(String partyId, CaseData caseData, CaseData.CaseDat .details(mappedWitnesses) .build()) .build()); - addApplicantExpertAndWitnessFlagsStructure(builder, caseData); - //TODO: need to add it to top level party object + List> updatedApplicantWitnesses = updatePartyDQWitnesses( + unwrapElements(caseData.getApplicantWitnesses()), + unwrapElements(mappedWitnesses) + ); + builder.applicantWitnesses(updatedApplicantWitnesses); } else if (partyId.equals(DEFENDANT_ONE_WITNESSES_ID)) { mappedWitnesses = mapUpdatePartyDetailsFormToDQWitnesses( caseData.getRespondent1DQ().getRespondent1DQWitnesses().getDetails(), formData); @@ -442,8 +466,11 @@ private void updateWitnesses(String partyId, CaseData caseData, CaseData.CaseDat .details(mappedWitnesses) .build()) .build()); - addRespondentDQPartiesFlagStructure(builder, caseData); - //TODO: need to add it to top level party object + List> updatedRespondent1Witnesses = updatePartyDQWitnesses( + unwrapElements(caseData.getRespondent1Witnesses()), + unwrapElements(mappedWitnesses) + ); + builder.respondent1Witnesses(updatedRespondent1Witnesses); } else if (partyId.equals(DEFENDANT_TWO_WITNESSES_ID)) { mappedWitnesses = mapUpdatePartyDetailsFormToDQWitnesses( caseData.getRespondent2DQ().getRespondent2DQWitnesses().getDetails(), formData); @@ -454,8 +481,11 @@ private void updateWitnesses(String partyId, CaseData caseData, CaseData.CaseDat .details(mappedWitnesses) .build()) .build()); - addRespondentDQPartiesFlagStructure(builder, caseData); - //TODO: need to add it to top level party object + List> updatedRespondent2Witnesses = updatePartyDQWitnesses( + unwrapElements(caseData.getRespondent2Witnesses()), + unwrapElements(mappedWitnesses) + ); + builder.respondent2Witnesses(updatedRespondent2Witnesses); } } @@ -466,8 +496,8 @@ private SubmittedCallbackResponse buildConfirmation(CallbackParams callbackParam .build(); } - private boolean isAwaitingClaimantIntention(CaseData caseData) { - return caseData.getCcdState().equals(AWAITING_APPLICANT_INTENTION); + private boolean isBeforeAwaitingApplicantIntention(CaseData caseData) { + return caseData.getCcdState().equals(AWAITING_APPLICANT_INTENTION) || caseData.getCcdState().equals(AWAITING_RESPONDENT_ACKNOWLEDGEMENT); } private boolean isAdmin(String userAuthToken) { diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimCallbackHandler.java index 8ac6181347f..29bb2f10da9 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimCallbackHandler.java @@ -103,11 +103,6 @@ public List handledEvents() { private CallbackResponse prepareDefendantSolicitorOptions(CallbackParams callbackParams) { CaseData caseData = callbackParams.getCaseData(); - if (!featureToggleService.isCertificateOfServiceEnabled() && areAnyRespondentsLitigantInPerson(caseData)) { - return AboutToStartOrSubmitCallbackResponse.builder() - .errors(List.of(ERROR_PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT)) - .build(); - } List dynamicListOptions = new ArrayList<>(); dynamicListOptions.add("Both"); dynamicListOptions.add("Defendant One: " + caseData.getRespondent1().getPartyName()); @@ -190,7 +185,7 @@ private CallbackResponse submitClaim(CallbackParams callbackParams) { // workaround for hiding cases in CAA list before case notify setOrganisationPolicy(caseData, caseDataBuilder); LocalDateTime claimDetailsNotificationDeadline; - if (featureToggleService.isCertificateOfServiceEnabled() && areAnyRespondentsLitigantInPerson(caseData)) { + if (areAnyRespondentsLitigantInPerson(caseData)) { claimDetailsNotificationDeadline = getDeadline(getServiceDate(caseData)); if (Objects.nonNull(caseData.getCosNotifyClaimDefendant1())) { caseDataBuilder @@ -254,7 +249,7 @@ private SubmittedCallbackResponse buildConfirmation(CallbackParams callbackParam String header = ""; String body = ""; - if (featureToggleService.isCertificateOfServiceEnabled() && isConfirmationForLip(caseData)) { + if (isConfirmationForLip(caseData)) { String formattedDeadline = formatLocalDate(caseData.getClaimDetailsNotificationDeadline().toLocalDate(), DATE); header = String.format(CONFIRMATION_COS_HEADER, caseData.getLegacyCaseReference()); diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java index 9dd8d9fe63b..c407f75720a 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java @@ -124,13 +124,11 @@ private CallbackResponse submitClaim(CallbackParams callbackParams) { LocalDate notificationDate = notificationDateTime.toLocalDate(); MultiPartyScenario multiPartyScenario = getMultiPartyScenario(caseData); - if (featureToggleService.isCertificateOfServiceEnabled()) { - caseData = saveCoSDetailsDoc(caseData, 1); - caseData = saveCoSDetailsDoc(caseData, 2); + caseData = saveCoSDetailsDoc(caseData, 1); + caseData = saveCoSDetailsDoc(caseData, 2); - if (multiPartyScenario == ONE_V_TWO_TWO_LEGAL_REP && isConfirmationForLip(caseData)) { - multiPartyScenario = null; - } + if (multiPartyScenario == ONE_V_TWO_TWO_LEGAL_REP && isConfirmationForLip(caseData)) { + multiPartyScenario = null; } CaseData updatedCaseData; @@ -171,7 +169,7 @@ private CallbackResponse submitClaim(CallbackParams callbackParams) { builder.respondent2ResponseDeadline( deadlinesCalculator.plus14DaysAt4pmDeadline(notificationDateTime)); } - if (featureToggleService.isCertificateOfServiceEnabled() && areAnyRespondentsLitigantInPerson(caseData)) { + if (areAnyRespondentsLitigantInPerson(caseData)) { if (Objects.nonNull(caseData.getCosNotifyClaimDetails1())) { builder .cosNotifyClaimDetails1(updateStatementOfTruthForLip(caseData.getCosNotifyClaimDetails1())) @@ -196,22 +194,20 @@ private CallbackResponse submitClaim(CallbackParams callbackParams) { private LocalDateTime getEarliestDateOfService(CaseData caseData) { LocalDateTime date = time.now(); - if (featureToggleService.isCertificateOfServiceEnabled()) { - if (Objects.nonNull(caseData.getCosNotifyClaimDetails1()) - && Objects.nonNull(caseData.getCosNotifyClaimDetails1().getCosDateOfServiceForDefendant())) { - LocalDateTime cosDate1 = caseData.getCosNotifyClaimDetails1() - .getCosDateOfServiceForDefendant().atTime(time.now().toLocalTime()); - if (cosDate1.isBefore(date)) { - date = cosDate1; - } + if (Objects.nonNull(caseData.getCosNotifyClaimDetails1()) + && Objects.nonNull(caseData.getCosNotifyClaimDetails1().getCosDateOfServiceForDefendant())) { + LocalDateTime cosDate1 = caseData.getCosNotifyClaimDetails1() + .getCosDateOfServiceForDefendant().atTime(time.now().toLocalTime()); + if (cosDate1.isBefore(date)) { + date = cosDate1; } - if (Objects.nonNull(caseData.getCosNotifyClaimDetails2()) - && Objects.nonNull(caseData.getCosNotifyClaimDetails2().getCosDateOfServiceForDefendant())) { - LocalDateTime cosDate2 = caseData.getCosNotifyClaimDetails2() - .getCosDateOfServiceForDefendant().atTime(time.now().toLocalTime()); - if (cosDate2.isBefore(date)) { - date = cosDate2; - } + } + if (Objects.nonNull(caseData.getCosNotifyClaimDetails2()) + && Objects.nonNull(caseData.getCosNotifyClaimDetails2().getCosDateOfServiceForDefendant())) { + LocalDateTime cosDate2 = caseData.getCosNotifyClaimDetails2() + .getCosDateOfServiceForDefendant().atTime(time.now().toLocalTime()); + if (cosDate2.isBefore(date)) { + date = cosDate2; } } return date; @@ -273,23 +269,15 @@ private String getConfirmationBody(CaseData caseData) { || caseData.getDefendantSolicitorNotifyClaimDetailsOptions() == null ? CONFIRMATION_SUMMARY : NOTIFICATION_ONE_PARTY_SUMMARY; - if (featureToggleService.isCertificateOfServiceEnabled()) { - return isConfirmationForLip(caseData) - ? CONFIRMATION_COS_SUMMARY - : confirmationTextLR; - } else { - return confirmationTextLR; - } + return isConfirmationForLip(caseData) + ? CONFIRMATION_COS_SUMMARY + : confirmationTextLR; } private String getConfirmationHeader(CaseData caseData) { - if (featureToggleService.isCertificateOfServiceEnabled()) { - return isConfirmationForLip(caseData) - ? CONFIRMATION_COS_HEADER - : CONFIRMATION_HEADER; - } else { - return CONFIRMATION_HEADER; - } + return isConfirmationForLip(caseData) + ? CONFIRMATION_COS_HEADER + : CONFIRMATION_HEADER; } private boolean isConfirmationForLip(CaseData caseData) { @@ -362,23 +350,21 @@ private CallbackResponse validateCoSDetailsDefendant1(final CallbackParams callb CaseData caseData = callbackParams.getCaseData(); ArrayList errors = new ArrayList<>(); - CertificateOfService certificateOfService = caseData.getCosNotifyClaimDetails1(); - if (featureToggleService.isCertificateOfServiceEnabled()) { - if (Objects.nonNull(caseData.getCosNotifyClaimDetails1())) { - caseData.getCosNotifyClaimDetails1().setCosDocSaved(NO); - } + if (Objects.nonNull(caseData.getCosNotifyClaimDetails1())) { + caseData.getCosNotifyClaimDetails1().setCosDocSaved(NO); + } - final String dateValidationErrorMessage = getServiceOfDateValidationMessage( - caseData.getCosNotifyClaimDetails1()); + final String dateValidationErrorMessage = getServiceOfDateValidationMessage( + caseData.getCosNotifyClaimDetails1()); - if (!dateValidationErrorMessage.isEmpty()) { - errors.add(dateValidationErrorMessage); - } - if (Objects.nonNull(caseData.getCosNotifyClaimDetails1()) - && isMandatoryDocMissing(caseData.getCosNotifyClaimDetails1())) { - errors.add(DOC_SERVED_MANDATORY); - } + if (!dateValidationErrorMessage.isEmpty()) { + errors.add(dateValidationErrorMessage); + } + if (Objects.nonNull(caseData.getCosNotifyClaimDetails1()) + && isMandatoryDocMissing(caseData.getCosNotifyClaimDetails1())) { + errors.add(DOC_SERVED_MANDATORY); } + CertificateOfService certificateOfService = caseData.getCosNotifyClaimDetails1(); CaseData.CaseDataBuilder caseDataBuilder = caseData.toBuilder(); caseDataBuilder.cosNotifyClaimDetails1(certificateOfService.toBuilder() .build()); @@ -391,28 +377,26 @@ && isMandatoryDocMissing(caseData.getCosNotifyClaimDetails1())) { private CallbackResponse validateCoSDetailsDefendant2(final CallbackParams callbackParams) { CaseData caseData = callbackParams.getCaseData(); - CertificateOfService certificateOfServiceDef2 = caseData.getCosNotifyClaimDetails2(); ArrayList errors = new ArrayList<>(); - if (featureToggleService.isCertificateOfServiceEnabled()) { - if (Objects.nonNull(caseData.getCosNotifyClaimDetails2())) { - caseData.getCosNotifyClaimDetails2().setCosDocSaved(NO); - } - final String dateValidationErrorMessage = getServiceOfDateValidationMessage( - caseData.getCosNotifyClaimDetails2()); + if (Objects.nonNull(caseData.getCosNotifyClaimDetails2())) { + caseData.getCosNotifyClaimDetails2().setCosDocSaved(NO); + } + final String dateValidationErrorMessage = getServiceOfDateValidationMessage( + caseData.getCosNotifyClaimDetails2()); - if (!dateValidationErrorMessage.isEmpty()) { - errors.add(dateValidationErrorMessage); - } + if (!dateValidationErrorMessage.isEmpty()) { + errors.add(dateValidationErrorMessage); + } - if (isBothDefendantLip(caseData) && !isBothDefendantWithSameDateOfService(caseData)) { - errors.add(BOTH_CERTIFICATE_SERVED_SAME_DATE); - } + if (isBothDefendantLip(caseData) && !isBothDefendantWithSameDateOfService(caseData)) { + errors.add(BOTH_CERTIFICATE_SERVED_SAME_DATE); + } - if (Objects.nonNull(caseData.getCosNotifyClaimDetails2()) - && isMandatoryDocMissing(caseData.getCosNotifyClaimDetails2())) { - errors.add(DOC_SERVED_MANDATORY); - } + if (Objects.nonNull(caseData.getCosNotifyClaimDetails2()) + && isMandatoryDocMissing(caseData.getCosNotifyClaimDetails2())) { + errors.add(DOC_SERVED_MANDATORY); } + CertificateOfService certificateOfServiceDef2 = caseData.getCosNotifyClaimDetails2(); CaseData.CaseDataBuilder caseDataBuilder = caseData.toBuilder(); caseDataBuilder.cosNotifyClaimDetails2(certificateOfServiceDef2.toBuilder() .build()); diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/RespondToClaimSpecCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/RespondToClaimSpecCallbackHandler.java index 5640b94350a..5a666f36a17 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/RespondToClaimSpecCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/RespondToClaimSpecCallbackHandler.java @@ -138,7 +138,6 @@ import static uk.gov.hmcts.reform.civil.utils.ElementUtils.wrapElements; import static uk.gov.hmcts.reform.civil.utils.ExpertUtils.addEventAndDateAddedToRespondentExperts; import static uk.gov.hmcts.reform.civil.utils.PartyUtils.populateDQPartyIds; -import static uk.gov.hmcts.reform.civil.utils.PartyUtils.populateWithPartyIds; import static uk.gov.hmcts.reform.civil.utils.WitnessUtils.addEventAndDateAddedToRespondentWitnesses; @Service @@ -1528,10 +1527,6 @@ && ifResponseTypeIsPartOrFullAdmission(caseData)) { } } - if (toggleService.isHmcEnabled()) { - populateWithPartyIds(updatedData); - } - updateCorrespondenceAddress(callbackParams, updatedData, caseData); if (getMultiPartyScenario(caseData) == ONE_V_TWO_TWO_LEGAL_REP diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/TransferOnlineCaseCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/TransferOnlineCaseCallbackHandler.java index 85837b957ac..9aa24b4646f 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/TransferOnlineCaseCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/TransferOnlineCaseCallbackHandler.java @@ -12,6 +12,7 @@ import uk.gov.hmcts.reform.civil.callback.CallbackParams; import uk.gov.hmcts.reform.civil.callback.CaseEvent; import uk.gov.hmcts.reform.civil.helpers.LocationHelper; +import uk.gov.hmcts.reform.civil.model.BusinessProcess; import uk.gov.hmcts.reform.civil.model.CaseData; import uk.gov.hmcts.reform.civil.model.common.DynamicList; import uk.gov.hmcts.reform.civil.referencedata.LocationRefDataService; @@ -22,7 +23,6 @@ import java.util.Collections; import java.util.List; import java.util.Map; - import static java.util.Objects.nonNull; import static uk.gov.hmcts.reform.civil.callback.CallbackParams.Params.BEARER_TOKEN; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_START; @@ -30,6 +30,7 @@ import static uk.gov.hmcts.reform.civil.callback.CallbackType.MID; import static uk.gov.hmcts.reform.civil.callback.CallbackType.SUBMITTED; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRANSFER_ONLINE_CASE; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIGGER_TASK_RECONFIG_GA; import static uk.gov.hmcts.reform.civil.model.common.DynamicList.fromList; @Service @@ -110,10 +111,12 @@ private CallbackResponse saveTransferOnlineCase(CallbackParams callbackParams) { callbackParams.getCaseData().getTransferCourtLocationList()); if (nonNull(newCourtLocation)) { caseDataBuilder.caseManagementLocation(LocationHelper.buildCaseLocation(newCourtLocation)); + caseDataBuilder.locationName(newCourtLocation.getSiteName()); } DynamicList tempLocationList = caseData.getTransferCourtLocationList(); tempLocationList.setListItems(null); caseDataBuilder.transferCourtLocationList(tempLocationList); + caseDataBuilder.businessProcess(BusinessProcess.ready(TRIGGER_TASK_RECONFIG_GA)); return AboutToStartOrSubmitCallbackResponse.builder() .data(caseDataBuilder.build().toMap(objectMapper)) .build(); diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/tasks/CaseEventTaskHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/tasks/CaseEventTaskHandler.java index 00377207bab..d10600c3301 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/tasks/CaseEventTaskHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/tasks/CaseEventTaskHandler.java @@ -35,7 +35,6 @@ import static uk.gov.hmcts.reform.civil.enums.ReasonForProceedingOnPaper.JUDGEMENT_REQUEST; import static uk.gov.hmcts.reform.civil.enums.ReasonForProceedingOnPaper.OTHER; import static uk.gov.hmcts.reform.civil.enums.UnrepresentedOrUnregisteredScenario.UNREGISTERED; -import static uk.gov.hmcts.reform.civil.enums.UnrepresentedOrUnregisteredScenario.UNREGISTERED_NOTICE_OF_CHANGE; import static uk.gov.hmcts.reform.civil.enums.UnrepresentedOrUnregisteredScenario.UNREPRESENTED; import static uk.gov.hmcts.reform.civil.enums.UnrepresentedOrUnregisteredScenario.getDefendantNames; import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES; @@ -181,8 +180,7 @@ private String getDescription(String eventId, Map data, String state, CaseData c case PENDING_CLAIM_ISSUED_UNREGISTERED_DEFENDANT: return format("Unregistered defendant solicitor firm: %s", StringUtils.join( - getDefendantNames(featureToggleService.isNoticeOfChangeEnabled() - ? UNREGISTERED_NOTICE_OF_CHANGE : UNREGISTERED, + getDefendantNames(UNREGISTERED, caseData), " and " )); case PENDING_CLAIM_ISSUED_UNREPRESENTED_UNREGISTERED_DEFENDANT: @@ -191,8 +189,7 @@ private String getDescription(String eventId, Map data, String state, CaseData c + "Unregistered defendant solicitor firm: %s.", StringUtils.join(getDefendantNames(UNREPRESENTED, caseData), " and "), StringUtils.join( - getDefendantNames(featureToggleService.isNoticeOfChangeEnabled() - ? UNREGISTERED_NOTICE_OF_CHANGE : UNREGISTERED, + getDefendantNames(UNREGISTERED, caseData), " and " )); case FULL_DEFENCE_PROCEED: diff --git a/src/main/java/uk/gov/hmcts/reform/civil/helpers/bundle/BundleRequestMapper.java b/src/main/java/uk/gov/hmcts/reform/civil/helpers/bundle/BundleRequestMapper.java index 8267d327903..537d7300e70 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/helpers/bundle/BundleRequestMapper.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/helpers/bundle/BundleRequestMapper.java @@ -27,6 +27,7 @@ import uk.gov.hmcts.reform.civil.documentmanagement.model.DocumentType; import uk.gov.hmcts.reform.civil.utils.ElementUtils; +import java.time.format.DateTimeFormatter; import java.util.Arrays; import java.util.Collections; import java.util.Collection; @@ -34,6 +35,7 @@ import java.util.HashMap; import java.util.Comparator; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Set; @@ -750,10 +752,7 @@ private String getFileNameBaseOnType(String fileNamePrefix, Element covertExpertEvidenceTypeToBundleRequestDocs(List> evidenceUploadExpert, String fileNamePrefix, String documentType) { List bundlingRequestDocuments = new ArrayList<>(); diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/AirlineEpimsId.java b/src/main/java/uk/gov/hmcts/reform/civil/model/AirlineEpimsId.java new file mode 100644 index 00000000000..d03bb5bdc02 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/AirlineEpimsId.java @@ -0,0 +1,14 @@ +package uk.gov.hmcts.reform.civil.model; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Value; + +@Value +@Builder +@AllArgsConstructor +public class AirlineEpimsId { + + String airline; + String epimsID; +} diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/CaseData.java b/src/main/java/uk/gov/hmcts/reform/civil/model/CaseData.java index 96dd6656365..caa3f46a47b 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/CaseData.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/CaseData.java @@ -40,6 +40,7 @@ import uk.gov.hmcts.reform.civil.model.breathing.BreathingSpaceInfo; import uk.gov.hmcts.reform.civil.model.caseprogression.FreeFormOrderValues; import uk.gov.hmcts.reform.civil.model.citizenui.CaseDataLiP; +import uk.gov.hmcts.reform.civil.model.citizenui.ClaimantLiPResponse; import uk.gov.hmcts.reform.civil.model.citizenui.HelpWithFees; import uk.gov.hmcts.reform.civil.model.citizenui.RespondentLiPResponse; import uk.gov.hmcts.reform.civil.model.citizenui.ManageDocument; @@ -637,6 +638,7 @@ public boolean hasNoOngoingBusinessProcess() { //SDO-R2 private YesOrNo isFlightDelayClaim; + private FlightDelayDetails flightDelayDetails; /** * There are several fields that can hold the I2P of applicant1 depending @@ -670,6 +672,11 @@ public boolean isRespondent1LiP() { return YesOrNo.NO == getRespondent1Represented(); } + @JsonIgnore + public boolean isApplicantLiP() { + return YesOrNo.NO == getApplicant1Represented(); + } + public YesOrNo getRespondent2Represented() { return Stream.of( respondent2Represented, @@ -981,9 +988,10 @@ private String getOrganisationId(Optional policy) { @JsonIgnore public boolean isPartAdmitPayImmediatelyAccepted() { - return SPEC_CLAIM.equals(getCaseAccessCategory()) + return SPEC_CLAIM.equals(getCaseAccessCategory()) && YES.equals(getApplicant1AcceptAdmitAmountPaidSpec()) - && getShowResponseOneVOneFlag().equals(ResponseOneVOneShowTag.ONE_V_ONE_PART_ADMIT_PAY_IMMEDIATELY); + && (getShowResponseOneVOneFlag() != null + && getShowResponseOneVOneFlag().equals(ResponseOneVOneShowTag.ONE_V_ONE_PART_ADMIT_PAY_IMMEDIATELY)); } @JsonIgnore @@ -1099,4 +1107,16 @@ public String getRespondent1Email() { } return null; } + + @JsonIgnore + public boolean hasApplicant1SignedSettlementAgreement() { + return Optional.ofNullable(getCaseDataLiP()) + .map(CaseDataLiP::getApplicant1LiPResponse) + .filter(ClaimantLiPResponse::hasApplicant1SignedSettlementAgreement).isPresent(); + } + + @JsonIgnore + public boolean isRespondentSignSettlementAgreement() { + return getCaseDataLiP() != null && getCaseDataLiP().getRespondentSignSettlementAgreement() != null; + } } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/CaseDataParent.java b/src/main/java/uk/gov/hmcts/reform/civil/model/CaseDataParent.java index 7d2a5546ce9..84f5051d9b0 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/CaseDataParent.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/CaseDataParent.java @@ -67,6 +67,7 @@ import uk.gov.hmcts.reform.civil.model.citizenui.RespondentLiPResponse; import uk.gov.hmcts.reform.civil.model.citizenui.TranslatedDocument; import uk.gov.hmcts.reform.civil.model.common.DynamicList; +import uk.gov.hmcts.reform.civil.model.common.DynamicListElement; import uk.gov.hmcts.reform.civil.model.common.Element; import uk.gov.hmcts.reform.civil.model.common.MappableObject; import uk.gov.hmcts.reform.civil.model.defaultjudgment.DisposalHearingBundleDJ; @@ -155,6 +156,7 @@ import java.util.Set; import static java.math.BigDecimal.ZERO; +import static java.util.Optional.ofNullable; import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES; @Jacksonized @@ -780,4 +782,12 @@ public boolean hasClaimantNotAgreedToFreeMediation() { .map(CaseDataLiP::getApplicant1ClaimMediationSpecRequiredLip) .filter(ClaimantMediationLip::hasClaimantNotAgreedToFreeMediation).isPresent(); } + + @JsonIgnore + public String getHearingLocationText() { + return ofNullable(hearingLocation) + .map(DynamicList::getValue) + .map(DynamicListElement::getLabel) + .orElse(null); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/FlightDelayDetails.java b/src/main/java/uk/gov/hmcts/reform/civil/model/FlightDelayDetails.java new file mode 100644 index 00000000000..514f0f0ab52 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/FlightDelayDetails.java @@ -0,0 +1,23 @@ +package uk.gov.hmcts.reform.civil.model; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.reform.civil.model.common.DynamicList; +import uk.gov.hmcts.reform.civil.model.defaultjudgment.CaseLocationCivil; + +import java.time.LocalDate; + +@Data +@Builder(toBuilder = true) +@NoArgsConstructor +@AllArgsConstructor +public class FlightDelayDetails { + + private DynamicList airlineList; + private String nameOfAirline; + private String flightNumber; + private LocalDate scheduledDate; + private CaseLocationCivil flightCourtLocation; +} diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/caseprogression/UploadEvidenceDocumentType.java b/src/main/java/uk/gov/hmcts/reform/civil/model/caseprogression/UploadEvidenceDocumentType.java index 3d02a3d2e44..6dffcc43598 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/caseprogression/UploadEvidenceDocumentType.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/caseprogression/UploadEvidenceDocumentType.java @@ -16,6 +16,7 @@ @AllArgsConstructor public class UploadEvidenceDocumentType { + private String witnessOptionName; private String typeOfDocument; private LocalDate documentIssuedDate; private Document documentUpload; diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/citizenui/CaseDataLiP.java b/src/main/java/uk/gov/hmcts/reform/civil/model/citizenui/CaseDataLiP.java index b66b6b1ffbc..f16fd0b272b 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/citizenui/CaseDataLiP.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/citizenui/CaseDataLiP.java @@ -6,6 +6,7 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import uk.gov.hmcts.reform.civil.enums.YesOrNo; import uk.gov.hmcts.reform.civil.model.common.Element; import java.util.List; @@ -33,6 +34,9 @@ public class CaseDataLiP { @JsonProperty("applicant1AdditionalLipPartyDetails") private AdditionalLipPartyDetails applicant1AdditionalLipPartyDetails; + @JsonProperty("respondentSignSettlementAgreement") + private YesOrNo respondentSignSettlementAgreement; + @JsonIgnore public boolean hasClaimantAgreedToFreeMediation() { return applicant1ClaimMediationSpecRequiredLip != null diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/citizenui/CcdDashboardClaimMatcher.java b/src/main/java/uk/gov/hmcts/reform/civil/model/citizenui/CcdDashboardClaimantClaimMatcher.java similarity index 99% rename from src/main/java/uk/gov/hmcts/reform/civil/model/citizenui/CcdDashboardClaimMatcher.java rename to src/main/java/uk/gov/hmcts/reform/civil/model/citizenui/CcdDashboardClaimantClaimMatcher.java index bf8f04b06dd..9855f6be349 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/citizenui/CcdDashboardClaimMatcher.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/citizenui/CcdDashboardClaimantClaimMatcher.java @@ -18,7 +18,7 @@ @Slf4j @AllArgsConstructor -public class CcdDashboardClaimMatcher implements Claim { +public class CcdDashboardClaimantClaimMatcher implements Claim { private static final LocalTime FOUR_PM = LocalTime.of(16, 1, 0); private CaseData caseData; diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/citizenui/CcdDashboardDefendantClaimMatcher.java b/src/main/java/uk/gov/hmcts/reform/civil/model/citizenui/CcdDashboardDefendantClaimMatcher.java new file mode 100644 index 00000000000..03a1ebab9d1 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/citizenui/CcdDashboardDefendantClaimMatcher.java @@ -0,0 +1,297 @@ +package uk.gov.hmcts.reform.civil.model.citizenui; + +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import uk.gov.hmcts.reform.civil.enums.CaseState; +import uk.gov.hmcts.reform.civil.enums.RespondentResponsePartAdmissionPaymentTimeLRspec; +import uk.gov.hmcts.reform.civil.enums.RespondentResponseTypeSpec; +import uk.gov.hmcts.reform.civil.enums.YesOrNo; +import uk.gov.hmcts.reform.civil.model.CaseData; +import uk.gov.hmcts.reform.civil.model.sdo.FastTrackHearingTime; +import uk.gov.hmcts.reform.civil.model.sdo.SmallClaimsHearing; +import uk.gov.hmcts.reform.civil.service.FeatureToggleService; + +import java.time.LocalDate; +import java.time.LocalTime; +import java.util.Objects; +import java.util.Optional; + +@Slf4j +@AllArgsConstructor +public class CcdDashboardDefendantClaimMatcher implements Claim { + + private static final LocalTime FOUR_PM = LocalTime.of(16, 1, 0); + private CaseData caseData; + private FeatureToggleService featureToggleService; + + @Override + public boolean hasResponsePending() { + return caseData.getRespondent1ResponseDate() == null && !isPaperResponse(); + } + + @Override + public boolean hasResponsePendingOverdue() { + return caseData.getRespondent1ResponseDeadline() != null + && caseData.getRespondent1ResponseDeadline().isBefore(LocalDate.now().atTime(FOUR_PM)) + && caseData.hasBreathingSpace(); + } + + @Override + public boolean hasResponseDueToday() { + return caseData.getRespondent1ResponseDeadline() != null + && caseData.getRespondent1ResponseDeadline().toLocalDate().isEqual(LocalDate.now()) + && caseData.getRespondent1ResponseDeadline().isBefore(LocalDate.now().atTime(FOUR_PM)); + } + + @Override + public boolean hasResponseFullAdmit() { + return caseData.getRespondent1ClaimResponseTypeForSpec() != null + && caseData.getRespondent1ClaimResponseTypeForSpec() == RespondentResponseTypeSpec.FULL_ADMISSION; + } + + @Override + public boolean defendantRespondedWithFullAdmitAndPayImmediately() { + return hasResponseFullAdmit() + && isPayImmediately(); + } + + @Override + public boolean defendantRespondedWithFullAdmitAndPayBySetDate() { + return hasResponseFullAdmit() + && caseData.isPayBySetDate() + && (Objects.isNull(caseData.getApplicant1AcceptFullAdmitPaymentPlanSpec())); + } + + @Override + public boolean defendantRespondedWithFullAdmitAndPayByInstallments() { + return hasResponseFullAdmit() + && caseData.isPayByInstallment() + && (Objects.isNull(caseData.getApplicant1AcceptFullAdmitPaymentPlanSpec())); + } + + @Override + public boolean hasResponseDeadlineBeenExtended() { + return caseData.getRespondent1TimeExtensionDate() != null; + } + + @Override + public boolean isEligibleForCCJ() { + return caseData.getRespondent1ResponseDeadline() != null + && caseData.getRespondent1ResponseDeadline().isBefore(LocalDate.now().atTime(FOUR_PM)) + && caseData.getPaymentTypeSelection() == null; + } + + @Override + public boolean claimantConfirmedDefendantPaid() { + return caseData.getRespondent1CourtOrderPayment() != null && caseData.respondent1PaidInFull(); + } + + @Override + public boolean isSettled() { + return !caseData.isRespondentResponseFullDefence() + && (caseData.respondent1PaidInFull() + || caseData.isResponseAcceptedByClaimant()) + && Objects.isNull(caseData.getCcjPaymentDetails()) + && !caseData.hasApplicantRejectedRepaymentPlan() + || caseData.isPartAdmitClaimSettled(); + } + + @Override + public boolean isSentToCourt() { + return false; + } + + @Override + public boolean claimantRequestedCountyCourtJudgement() { + return caseData.getApplicant1DQ() != null && caseData.getApplicant1DQ().getApplicant1DQRequestedCourt() != null + && !hasSdoBeenDrawn(); + } + + @Override + public boolean isWaitingForClaimantToRespond() { + return RespondentResponseTypeSpec.FULL_DEFENCE == caseData.getRespondent1ClaimResponseTypeForSpec() + && caseData.getApplicant1ResponseDate() == null; + } + + @Override + public boolean isProceedOffline() { + return false; + } + + @Override + public boolean isPaperResponse() { + if (!featureToggleService.isLipVLipEnabled()) { + return false; + } + + return Objects.nonNull(caseData.getTakenOfflineDate()) && Objects.nonNull(caseData.getCcdState()) + && caseData.getCcdState().equals(CaseState.PROCEEDS_IN_HERITAGE_SYSTEM); + } + + @Override + public boolean hasChangeRequestFromDefendant() { + return false; + } + + @Override + public boolean hasChangeRequestedFromClaimant() { + return false; + } + + @Override + public boolean isPassedToCountyCourtBusinessCentre() { + return false; + } + + @Override + public boolean hasClaimantAskedToSignSettlementAgreement() { + return false; + } + + @Override + public boolean hasClaimantAcceptedPartialAdmissionAmount() { + return hasDefendantStatedTheyPaid() && caseData.isResponseAcceptedByClaimant(); + } + + @Override + public boolean haveBothPartiesSignedSettlementAgreement() { + return false; + } + + @Override + public boolean hasCCJByRedetermination() { + return caseData.hasApplicantAcceptedRepaymentPlan(); + } + + @Override + public boolean hasDefendantStatedTheyPaid() { + return defendantRespondedWithPartAdmit() + && isPayImmediately() && !caseData.getApplicant1ResponseDeadlinePassed() + && !(caseData.hasApplicantRejectedRepaymentPlan() || caseData.isPartAdmitClaimNotSettled()); + } + + private boolean isPayImmediately() { + return RespondentResponsePartAdmissionPaymentTimeLRspec.IMMEDIATELY == caseData.getDefenceAdmitPartPaymentTimeRouteRequired(); + } + + @Override + public boolean defendantRespondedWithPartAdmit() { + return RespondentResponseTypeSpec.PART_ADMISSION == caseData.getRespondent1ClaimResponseTypeForSpec() + && !caseData.getApplicant1ResponseDeadlinePassed() + && !(caseData.hasApplicantRejectedRepaymentPlan() || caseData.isPartAdmitClaimNotSettled()); + } + + @Override + public boolean isHearingFormGenerated() { + return !caseData.getHearingDocuments().isEmpty(); + } + + @Override + public boolean hasSdoBeenDrawn() { + return caseData.getSDODocument().isPresent(); + } + + @Override + public boolean isBeforeHearing() { + return isBeforeSmallClaimHearing() || (isBeforeFastTrackHearing() || noHearingScheduled()); + } + + private boolean noHearingScheduled() { + return caseData.getSmallClaimsHearing() == null && caseData.getFastTrackHearingTime() == null; + } + + private boolean isBeforeSmallClaimHearing() { + return Optional.ofNullable(caseData.getSmallClaimsHearing()) + .map(SmallClaimsHearing::getDateFrom) + .map(hearingFromDate -> hearingFromDate.isAfter(LocalDate.now())) + .orElse(false); + } + + private boolean isBeforeFastTrackHearing() { + return Optional.ofNullable(caseData.getFastTrackHearingTime()) + .map(FastTrackHearingTime::getDateFrom) + .map(hearingFromDate -> hearingFromDate.isAfter(LocalDate.now())) + .orElse(false); + } + + @Override + public boolean isMoreDetailsRequired() { + return hasSdoBeenDrawn() && isBeforeHearing() && featureToggleService.isCaseProgressionEnabled(); + } + + @Override + public boolean isMediationSuccessful() { + return !hasSdoBeenDrawn() + && Objects.nonNull(caseData.getMediation()) + && Objects.nonNull(caseData.getMediation().getMediationSuccessful()) + && Objects.nonNull(caseData.getMediation().getMediationSuccessful().getMediationAgreement()); + } + + @Override + public boolean isMediationUnsuccessful() { + return !hasSdoBeenDrawn() + && Objects.nonNull(caseData.getMediation()) + && Objects.nonNull(caseData.getMediation().getUnsuccessfulMediationReason()) + && !caseData.getMediation().getUnsuccessfulMediationReason().isEmpty(); + } + + @Override + public boolean isMediationPending() { + return Objects.nonNull(caseData.getCcdState()) + && caseData.getCcdState().equals(CaseState.IN_MEDIATION) + && Objects.nonNull(caseData.getMediation()) + && Objects.nonNull(caseData.getMediation().getMediationSuccessful()) + && Objects.isNull(caseData.getMediation().getMediationSuccessful().getMediationAgreement()); + } + + @Override + public boolean isCourtReviewing() { + return (!hasSdoBeenDrawn() + && caseData.isRespondentResponseFullDefence() + && caseData.getCcdState().equals(CaseState.JUDICIAL_REFERRAL)) + || (caseData.hasApplicantRejectedRepaymentPlan()); + } + + @Override + public boolean hasClaimEnded() { + return (Objects.nonNull(caseData.getApplicant1ProceedsWithClaimSpec()) + && caseData.getApplicant1ProceedsWithClaimSpec().equals(YesOrNo.NO) + && caseData.isRespondentResponseFullDefence()) + || caseData.getApplicant1ResponseDeadlinePassed(); + } + + @Override + public boolean isClaimRejectedAndOfferSettleOutOfCourt() { + return false; + } + + @Override + public boolean claimantAcceptedOfferOutOfCourt() { + return false; + } + + @Override + public boolean hasClaimantRejectOffer() { + return false; + } + + @Override + public boolean isPartialAdmissionRejected() { + return CaseState.JUDICIAL_REFERRAL.equals(caseData.getCcdState()) + && caseData.isPartAdmitClaimSpec(); + } + + @Override + public boolean isSDOOrderCreated() { + return caseData.getHearingDate() == null + && CaseState.CASE_PROGRESSION.equals(caseData.getCcdState()); + } + + @Override + public boolean isClaimantDefaultJudgement() { + return caseData.getRespondent1ResponseDeadline() != null + && caseData.getRespondent1ResponseDeadline().isBefore(LocalDate.now().atTime(FOUR_PM)) + && caseData.getPaymentTypeSelection() != null; + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/citizenui/ChooseHowToProceed.java b/src/main/java/uk/gov/hmcts/reform/civil/model/citizenui/ChooseHowToProceed.java new file mode 100644 index 00000000000..c163aec3d5e --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/citizenui/ChooseHowToProceed.java @@ -0,0 +1,6 @@ +package uk.gov.hmcts.reform.civil.model.citizenui; + +public enum ChooseHowToProceed { + SIGN_A_SETTLEMENT_AGREEMENT, + REQUEST_A_CCJ, +} diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/citizenui/ClaimantLiPResponse.java b/src/main/java/uk/gov/hmcts/reform/civil/model/citizenui/ClaimantLiPResponse.java index b9cd00096fa..63d103d80b8 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/citizenui/ClaimantLiPResponse.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/citizenui/ClaimantLiPResponse.java @@ -1,9 +1,11 @@ package uk.gov.hmcts.reform.civil.model.citizenui; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import uk.gov.hmcts.reform.civil.enums.YesOrNo; @Data @Builder @@ -13,4 +15,11 @@ public class ClaimantLiPResponse { private DQExtraDetailsLip applicant1DQExtraDetails; private HearingSupportLip applicant1DQHearingSupportLip; + private YesOrNo applicant1SignedSettlementAgreement; + private ChooseHowToProceed applicant1ChoosesHowToProceed; + + @JsonIgnore + public boolean hasApplicant1SignedSettlementAgreement() { + return YesOrNo.YES.equals(applicant1SignedSettlementAgreement); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/docmosis/hearing/HearingForm.java b/src/main/java/uk/gov/hmcts/reform/civil/model/docmosis/hearing/HearingForm.java index 3a1fa19368c..3aba6a0e5ad 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/docmosis/hearing/HearingForm.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/docmosis/hearing/HearingForm.java @@ -16,6 +16,7 @@ public class HearingForm implements MappableObject { private final String caseNumber; private final String court; + private final String courtName; private final String creationDate; private final String claimant; private final String defendant; diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/documents/DocumentAndNote.java b/src/main/java/uk/gov/hmcts/reform/civil/model/documents/DocumentAndNote.java index fee4c6e850a..69b3dd9cda9 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/documents/DocumentAndNote.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/documents/DocumentAndNote.java @@ -20,5 +20,7 @@ public class DocumentAndNote { private String documentNote; @Builder.Default private LocalDateTime createdDateTime = LocalDateTime.now(ZoneId.of("Europe/London")); + private String createdBy; + private String documentNoteForTab; } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/documents/DocumentWithName.java b/src/main/java/uk/gov/hmcts/reform/civil/model/documents/DocumentWithName.java index 9aabf622994..f19ba0c57a9 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/documents/DocumentWithName.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/documents/DocumentWithName.java @@ -19,4 +19,5 @@ public class DocumentWithName { private String documentName; @Builder.Default private LocalDateTime createdDateTime = LocalDateTime.now(ZoneId.of("Europe/London")); + private String createdBy; } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/AirlineEpimsDataLoader.java b/src/main/java/uk/gov/hmcts/reform/civil/service/AirlineEpimsDataLoader.java new file mode 100644 index 00000000000..718c4755838 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/AirlineEpimsDataLoader.java @@ -0,0 +1,44 @@ +package uk.gov.hmcts.reform.civil.service; + +import com.google.common.collect.ImmutableList; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import javax.annotation.PostConstruct; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; +import com.opencsv.CSVReader; +import com.opencsv.exceptions.CsvException; +import uk.gov.hmcts.reform.civil.model.AirlineEpimsId; + +@Service +@Slf4j +public class AirlineEpimsDataLoader { + + private static final String CSV_FILE_PATH = "airline_ePimsID_csv/airline_ePimsID.csv"; + private final List airlineEpimsIDList = new ArrayList<>(); + + @PostConstruct + protected void init() { + InputStream inputStream = getClass().getClassLoader().getResourceAsStream(CSV_FILE_PATH); + try (CSVReader reader = new CSVReader(new InputStreamReader(inputStream))) { + + List linesList = reader.readAll(); + linesList.forEach(line -> { + AirlineEpimsId airlineEpimsID = AirlineEpimsId.builder() + .airline(line[0]) + .epimsID(line[1]) + .build(); + airlineEpimsIDList.add(airlineEpimsID); + }); + } catch (IOException | CsvException e) { + log.error("Error occurred while loading the airline_ePimsID.csv file: " + CSV_FILE_PATH + e); + } + } + + public List getAirlineEpimsIDList() { + return ImmutableList.copyOf(airlineEpimsIDList); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/AirlineEpimsService.java b/src/main/java/uk/gov/hmcts/reform/civil/service/AirlineEpimsService.java new file mode 100644 index 00000000000..00e47a34789 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/AirlineEpimsService.java @@ -0,0 +1,22 @@ +package uk.gov.hmcts.reform.civil.service; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import uk.gov.hmcts.reform.civil.model.AirlineEpimsId; +import java.util.Optional; + +@Service +@RequiredArgsConstructor +public class AirlineEpimsService { + + private final AirlineEpimsDataLoader airlineEpimsDataLoader; + + public String getEpimsIdForAirline(String airline) { + AirlineEpimsId airlineEpimsID = airlineEpimsDataLoader.getAirlineEpimsIDList() + .stream().filter(item -> item.getAirline().equals(airline)).findFirst().orElse(null); + + return Optional.ofNullable(airlineEpimsID) + .map(AirlineEpimsId::getEpimsID) + .orElseThrow(() -> new IllegalStateException("Unable to find epims ID for airline: " + airline)); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/AuthorisationService.java b/src/main/java/uk/gov/hmcts/reform/civil/service/AuthorisationService.java new file mode 100644 index 00000000000..b50f8c1f597 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/AuthorisationService.java @@ -0,0 +1,65 @@ +package uk.gov.hmcts.reform.civil.service; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import uk.gov.hmcts.reform.authorisation.ServiceAuthorisationApi; +import uk.gov.hmcts.reform.idam.client.IdamClient; +import uk.gov.hmcts.reform.idam.client.models.UserInfo; + +import java.util.List; + +@Service +@Slf4j +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +public class AuthorisationService { + + private final ServiceAuthorisationApi serviceAuthorisationApi; + + @Value("${civil.authorised-services}") + private List s2sAuthorisedServices; + + private final IdamClient idamClient; + + private UserInfo userInfo; + + public Boolean authoriseService(String serviceAuthHeader) { + String callingService; + try { + String bearerJwt = serviceAuthHeader.startsWith("Bearer ") ? serviceAuthHeader : "Bearer " + serviceAuthHeader; + callingService = serviceAuthorisationApi.getServiceName(bearerJwt); + log.info("Calling Service... {}", callingService); + return (callingService != null && s2sAuthorisedServices.contains(callingService)); + } catch (Exception ex) { + //do nothing + log.error("S2S token is not authorised" + ex); + } + return false; + } + + public Boolean authoriseUser(String authorisation) { + try { + userInfo = idamClient.getUserInfo(authorisation); + return (null != userInfo); + } catch (Exception ex) { + //do nothing + log.error("User token is invalid"); + } + return false; + } + + public UserInfo getUserInfo() { + return this.userInfo; + } + + public boolean isServiceAndUserAuthorized(String authorisation, String s2sToken) { + return Boolean.TRUE.equals(authoriseUser(authorisation)) + && Boolean.TRUE.equals(authoriseService(s2sToken)); + } + + public boolean isServiceAuthorized(String s2sToken) { + return Boolean.TRUE.equals(authoriseService(s2sToken)); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/CaseNoteService.java b/src/main/java/uk/gov/hmcts/reform/civil/service/CaseNoteService.java index 4c6f63654eb..76240eb63c1 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/CaseNoteService.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/CaseNoteService.java @@ -4,6 +4,8 @@ import org.springframework.stereotype.Service; import uk.gov.hmcts.reform.civil.model.CaseNote; import uk.gov.hmcts.reform.civil.model.common.Element; +import uk.gov.hmcts.reform.civil.model.documents.DocumentAndNote; +import uk.gov.hmcts.reform.civil.model.documents.DocumentWithName; import uk.gov.hmcts.reform.idam.client.IdamClient; import uk.gov.hmcts.reform.idam.client.models.UserDetails; @@ -43,4 +45,35 @@ public List> addNoteToListEnd(CaseNote caseNote, List> buildJudgeCaseNoteAndDocument(DocumentAndNote documentAndNote, String authorisation) { + UserDetails userDetails = idamClient.getUserDetails(authorisation); + + var updatedJudgeNote = DocumentAndNote.builder() + .documentName(documentAndNote.getDocumentName()) + .document(documentAndNote.getDocument()) + .documentNote(documentAndNote.getDocumentNote()) + .createdBy(userDetails.getFullName()) + .documentNoteForTab(documentAndNote.getDocumentNote()) + .build(); + List> updatedJudgeNoteAndDocument = newArrayList(); + updatedJudgeNoteAndDocument.add(element(updatedJudgeNote)); + + return updatedJudgeNoteAndDocument; + } + + public List> buildJudgeCaseNoteDocumentAndName(DocumentWithName documentAndNote, String authorisation) { + UserDetails userDetails = idamClient.getUserDetails(authorisation); + + var updatedJudgeNote = DocumentWithName.builder() + .document(documentAndNote.getDocument()) + .documentName(documentAndNote.getDocumentName()) + .createdBy(userDetails.getFullName()) + .build(); + List> updatedJudgeNoteDocumentAndName = newArrayList(); + updatedJudgeNoteDocumentAndName.add(element(updatedJudgeNote)); + + return updatedJudgeNoteDocumentAndName; + + } } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/FeatureToggleService.java b/src/main/java/uk/gov/hmcts/reform/civil/service/FeatureToggleService.java index 8b11403a6fc..1480a91bb46 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/FeatureToggleService.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/FeatureToggleService.java @@ -24,10 +24,6 @@ public boolean isBulkClaimEnabled() { return this.featureToggleApi.isFeatureEnabled("bulk_claim_enabled"); } - public boolean isNoticeOfChangeEnabled() { - return this.featureToggleApi.isFeatureEnabled("notice-of-change"); - } - public boolean isCaseFlagsEnabled() { return this.featureToggleApi.isFeatureEnabled("case-flags"); } @@ -40,10 +36,6 @@ public boolean isPbaV3Enabled() { return this.featureToggleApi.isFeatureEnabled("pba-version-3-ways-to-pay"); } - public boolean isCertificateOfServiceEnabled() { - return this.featureToggleApi.isFeatureEnabled("isCertificateOfServiceEnabled"); - } - public boolean isRPAEmailEnabled() { return this.featureToggleApi.isFeatureEnabled("enable-rpa-emails"); } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/InitiateGeneralApplicationServiceHelper.java b/src/main/java/uk/gov/hmcts/reform/civil/service/InitiateGeneralApplicationServiceHelper.java index d6d35fe839d..57bb35d38bd 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/InitiateGeneralApplicationServiceHelper.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/InitiateGeneralApplicationServiceHelper.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; @@ -39,6 +40,7 @@ public class InitiateGeneralApplicationServiceHelper { private final AuthTokenGenerator authTokenGenerator; private final UserService userService; private final CrossAccessUserConfiguration crossAccessUserConfiguration; + public CaseAssignedUserRolesResource userRoles; public boolean isGAApplicantSameAsPCClaimant(CaseData caseData, String organisationIdentifier) { @@ -56,14 +58,12 @@ public GeneralApplication setRespondentDetailsIfPresent(CaseData.CaseDataBuilder || (YES.equals(caseData.getAddRespondent2()) && caseData.getRespondent2OrganisationPolicy() == null)) { throw new IllegalArgumentException("Solicitor Org details are not set correctly."); } - GeneralApplication.GeneralApplicationBuilder applicationBuilder = generalApplication.toBuilder(); String parentCaseId = caseData.getCcdCaseReference().toString(); - String applicant1OrgCaseRole = caseData.getApplicant1OrganisationPolicy().getOrgPolicyCaseAssignedRole(); String respondent1OrgCaseRole = caseData.getRespondent1OrganisationPolicy().getOrgPolicyCaseAssignedRole(); - CaseAssignedUserRolesResource userRoles = getUserRoles(parentCaseId); + userRoles = getUserRoles(parentCaseId); /*Filter the case users to collect solicitors whose ID doesn't match with GA Applicant Solicitor's ID*/ List respondentSolicitors = userRoles.getCaseAssignedUserRoles().stream() @@ -119,7 +119,7 @@ public GeneralApplication setRespondentDetailsIfPresent(CaseData.CaseDataBuilder } } } - + GeneralApplication.GeneralApplicationBuilder applicationBuilder = generalApplication.toBuilder(); applicationBuilder .generalAppApplnSolicitor(applicantBuilder.build()); String applicantPartyName = null; @@ -133,13 +133,13 @@ public GeneralApplication setRespondentDetailsIfPresent(CaseData.CaseDataBuilder GASolicitorDetailsGAspec.GASolicitorDetailsGAspecBuilder specBuilder = GASolicitorDetailsGAspec .builder(); - specBuilder.id(respSol.getUserId()); - if (respSol.getCaseRole() != null) { + log.info(respSol.getCaseRole(), "**", respSol.getUserId()); /*Populate the GA respondent solicitor details in accordance with civil case Applicant Solicitor 1 details if case role of collected user matches with case role of Applicant 1*/ if (respSol.getCaseRole().equals(applicant1OrgCaseRole)) { if (caseData.getApplicantSolicitor1UserDetails() != null) { + specBuilder.id(respSol.getUserId()); specBuilder.email(caseData.getApplicantSolicitor1UserDetails().getEmail()); specBuilder.organisationIdentifier(caseData.getApplicant1OrganisationPolicy() .getOrganisation().getOrganisationID()); @@ -147,14 +147,19 @@ public GeneralApplication setRespondentDetailsIfPresent(CaseData.CaseDataBuilder /*Populate the GA respondent solicitor details in accordance with civil case Respondent Solicitor 1 details if caserole of collected user matches with caserole Respondent Solicitor 1*/ } else if (respSol.getCaseRole().equals(respondent1OrgCaseRole)) { + specBuilder.id(respSol.getUserId()); specBuilder.email(caseData.getRespondentSolicitor1EmailAddress()); specBuilder.organisationIdentifier(getRespondent1SolicitorOrgId(caseData)); /*Populate the GA respondent solicitor details in accordance with civil case Respondent Solicitor 2 details if it's 1 V 2 Different Solicitor scenario*/ } else { - specBuilder.email(caseData.getRespondentSolicitor2EmailAddress()); - specBuilder.organisationIdentifier(getRespondent2SolicitorOrgId(caseData)); + if (Objects.nonNull(caseData.getAddRespondent2()) + && caseData.getAddRespondent2().equals(YES)) { + specBuilder.id(respSol.getUserId()); + specBuilder.email(caseData.getRespondentSolicitor2EmailAddress()); + specBuilder.organisationIdentifier(getRespondent2SolicitorOrgId(caseData)); + } } /*Set the GA Respondent solicitor details to Empty if above checks are failed*/ } else { @@ -167,7 +172,10 @@ public GeneralApplication setRespondentDetailsIfPresent(CaseData.CaseDataBuilder } GASolicitorDetailsGAspec gaSolicitorDetailsGAspec = specBuilder.build(); - respondentSols.add(element(gaSolicitorDetailsGAspec)); + if (Objects.nonNull(gaSolicitorDetailsGAspec.getId())) { + respondentSols.add(element(gaSolicitorDetailsGAspec)); + } + }); applicantPartyName = getApplicantPartyName(userRoles, userDetails, caseData); applicationBuilder.applicantPartyName(applicantPartyName); @@ -252,8 +260,12 @@ public boolean isGAApplicantSameAsParentCaseClaimant(CaseData caseData, String a } public CaseAssignedUserRolesResource getUserRoles(String parentCaseId) { - return caseAccessDataStoreApi.getUserRoles( - getCaaAccessToken(), authTokenGenerator.generate(), List.of(parentCaseId)); + if (Objects.isNull(userRoles)) { + userRoles = caseAccessDataStoreApi.getUserRoles( + getCaaAccessToken(), authTokenGenerator.generate(), List.of(parentCaseId)); + } + log.info("UserRoles from API :" + userRoles); + return userRoles; } public String getCaaAccessToken() { diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/citizenui/DashboardClaimInfoService.java b/src/main/java/uk/gov/hmcts/reform/civil/service/citizenui/DashboardClaimInfoService.java index 058ab6c0eb8..80c31e0759f 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/citizenui/DashboardClaimInfoService.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/citizenui/DashboardClaimInfoService.java @@ -7,8 +7,10 @@ import uk.gov.hmcts.reform.ccd.client.model.SearchResult; import uk.gov.hmcts.reform.civil.helpers.CaseDetailsConverter; import uk.gov.hmcts.reform.civil.model.CaseData; -import uk.gov.hmcts.reform.civil.model.citizenui.CcdDashboardClaimMatcher; +import uk.gov.hmcts.reform.civil.model.citizenui.CcdDashboardClaimantClaimMatcher; +import uk.gov.hmcts.reform.civil.model.citizenui.CcdDashboardDefendantClaimMatcher; import uk.gov.hmcts.reform.civil.model.citizenui.DashboardClaimInfo; +import uk.gov.hmcts.reform.civil.model.citizenui.DashboardClaimStatus; import uk.gov.hmcts.reform.civil.model.citizenui.DashboardClaimStatusFactory; import uk.gov.hmcts.reform.civil.model.citizenui.DashboardResponse; import uk.gov.hmcts.reform.civil.service.CoreCaseDataService; @@ -54,7 +56,7 @@ public DashboardResponse getDashboardDefendantResponse(String authorisation, Str var ccdData = coreCaseDataService.getCCDClaimsForLipDefendant(authorisation, startIndex); int totalPages = getTotalPagesToBeListed(ccdData.getTotal() + ocmcClaims.size()); List currentPageItems = currentPage <= totalPages - ? getDashboardItemsForCurrentPage(ocmcClaims, currentPage, ccdData) : + ? getDashboardItemsForCurrentPage(ocmcClaims, currentPage, ccdData, false) : Collections.emptyList(); return DashboardResponse.builder().totalPages(totalPages).claims(currentPageItems).build(); } @@ -71,7 +73,7 @@ public DashboardResponse getDashboardClaimantResponse(String authorisation, Stri int totalPages = getTotalPagesToBeListed(getCcdClaimsCount(ccdData) + ocmcClaims.size()); List currentPageItems = currentPage <= totalPages - ? getDashboardItemsForCurrentPage(ocmcClaims, currentPage, ccdData) : + ? getDashboardItemsForCurrentPage(ocmcClaims, currentPage, ccdData, true) : Collections.emptyList(); return DashboardResponse.builder().totalPages(totalPages).claims(currentPageItems).build(); } @@ -84,7 +86,8 @@ private List getClaimsForClaimant(String authorisation, Stri private List getDashboardItemsForCurrentPage(List ocmcClaims, int currentPage, - SearchResult ccdClaims) { + SearchResult ccdClaims, + boolean isClaimant) { int startIndex = (currentPage - 1) * CASES_PER_PAGE; int endIndex = startIndex + CASES_PER_PAGE; @@ -96,7 +99,7 @@ private List getDashboardItemsForCurrentPage(List ccdClaimsCount) { int remainingRecords = CASES_PER_PAGE - ccdData.size(); @@ -114,16 +117,19 @@ private List sortOcmcCases(List ocmcCase .collect(Collectors.toList()); } - private List translateSearchResultToDashboardItems(SearchResult claims) { + private List translateSearchResultToDashboardItems(SearchResult claims, boolean isClaimant) { if (claims == null) { return Collections.emptyList(); } - return claims.getCases().stream().map(caseDetails -> translateCaseDataToDashboardClaimInfo(caseDetails)) + return claims.getCases().stream().map(caseDetails -> translateCaseDataToDashboardClaimInfo( + caseDetails, + isClaimant + )) .collect(Collectors.toList()); } - private DashboardClaimInfo translateCaseDataToDashboardClaimInfo(CaseDetails caseDetails) { + private DashboardClaimInfo translateCaseDataToDashboardClaimInfo(CaseDetails caseDetails, boolean isClaimant) { CaseData caseData = caseDetailsConverter.toCaseData(caseDetails); DashboardClaimInfo item = DashboardClaimInfo.builder().claimId(String.valueOf(caseData.getCcdCaseReference())) .createdDate(submittedDateToCreatedDate(caseData)) @@ -133,7 +139,7 @@ private DashboardClaimInfo translateCaseDataToDashboardClaimInfo(CaseDetails cas .claimAmount(nonNull(caseData.getTotalClaimAmount()) ? caseData.getTotalClaimAmount() : null) .admittedAmount(caseData.getPartAdmitPaidValuePounds()) .responseDeadlineTime(caseData.getRespondent1ResponseDeadline()) - .status(dashboardClaimStatusFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher(caseData, featureToggleService))) + .status(getStatus(isClaimant, caseData)) .build(); if (caseData.getRespondent1ResponseDeadline() != null) { item.setResponseDeadline(caseData.getRespondent1ResponseDeadline().toLocalDate()); @@ -170,4 +176,16 @@ private int getCcdClaimsCount(final SearchResult ccdClaims) { return Optional.ofNullable(ccdClaims).map(SearchResult::getTotal).orElse(0); } + + private DashboardClaimStatus getStatus(boolean isClaimant, CaseData caseData) { + return isClaimant + ? dashboardClaimStatusFactory.getDashboardClaimStatus(new CcdDashboardClaimantClaimMatcher( + caseData, + featureToggleService + )) + : dashboardClaimStatusFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( + caseData, + featureToggleService + )); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/DocmosisTemplates.java b/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/DocmosisTemplates.java index 70238616c12..ef6dac12d29 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/DocmosisTemplates.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/DocmosisTemplates.java @@ -52,6 +52,10 @@ public enum DocmosisTemplates { DQ_LIP_RESPONSE("CV-SPC-HRN-ENG-LIP-01283.docx", "%s_directions_questionnaire_form_%s.pdf"), TRIAL_READY("CV-UNS-HRN-ENG-01247-10180.docx", "%s_%s_Trial_Arrangements.pdf"), HEARING_NOTICE_HMC("CV-UNS-HNO-ENG-01200.docx", "hearing_notice_%s.pdf"), + HEARING_SMALL_CLAIMS_AHN("CV-UNS-HNO-ENG-01202.docx", "hearing_small_claim_%s.pdf"), + HEARING_FAST_TRACK_AHN("CV-UNS-HNO-ENG-01203.docx", "hearing_fast_track_%s.pdf"), + HEARING_APPLICATION_AHN("CV-UNS-HNO-ENG-01204.docx", "hearing_application_%s.pdf"), + HEARING_OTHER_AHN("CV-UNS-HNO-ENG-01201.docx", "hearing_other_claim_%s.pdf"), // judge final Order FREE_FORM_ORDER_PDF("CV-UNS-DEC-ENG-01099.docx", "Order_%s.pdf"), ASSISTED_ORDER_PDF("CV-UNS-DEC-ENG-01283.docx", "Order_%s.pdf"); diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/caseprogression/JudgeFinalOrderGenerator.java b/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/caseprogression/JudgeFinalOrderGenerator.java index d39136c1ce4..3d281db4b71 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/caseprogression/JudgeFinalOrderGenerator.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/caseprogression/JudgeFinalOrderGenerator.java @@ -17,8 +17,10 @@ import uk.gov.hmcts.reform.civil.model.CaseData; import uk.gov.hmcts.reform.civil.model.docmosis.DocmosisDocument; import uk.gov.hmcts.reform.civil.model.docmosis.casepogression.JudgeFinalOrderForm; +import uk.gov.hmcts.reform.civil.referencedata.LocationRefDataException; import uk.gov.hmcts.reform.civil.referencedata.LocationRefDataService; import uk.gov.hmcts.reform.civil.referencedata.model.LocationRefData; +import uk.gov.hmcts.reform.civil.service.FeatureToggleService; import uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates; import uk.gov.hmcts.reform.civil.service.docmosis.DocumentGeneratorService; import uk.gov.hmcts.reform.civil.service.docmosis.DocumentHearingLocationHelper; @@ -29,8 +31,10 @@ import java.time.LocalDate; import java.time.format.DateTimeFormatter; +import java.util.List; import java.util.Locale; import java.util.Objects; +import java.util.stream.Collectors; import static java.lang.String.format; import static java.util.Objects.nonNull; @@ -43,6 +47,7 @@ import static uk.gov.hmcts.reform.civil.helpers.DateFormatHelper.formatLocalDate; import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.ASSISTED_ORDER_PDF; import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.FREE_FORM_ORDER_PDF; +import static uk.gov.hmcts.reform.civil.service.robotics.utils.RoboticsDataUtil.CIVIL_COURT_TYPE_ID; @Slf4j @Service @@ -54,6 +59,7 @@ public class JudgeFinalOrderGenerator implements TemplateDataGenerator matchingLocations = locationRefDataService.getCourtLocationsByEpimmsId( + authorisation, caseData.getCaseManagementLocation().getBaseLocation()) + .stream().filter(id -> id.getCourtTypeId().equals(CIVIL_COURT_TYPE_ID)) + .collect(Collectors.toList()); + + if (matchingLocations.size() != 1) { + throw new LocationRefDataException( + String.format( + "Unexpected amount of locations (%d) where matched against location epimms id: %s", + matchingLocations.size(), + locationEpimms + )); + } + + return LocationRefDataService.getDisplayEntry(matchingLocations.get(0)); + } + + private String getHearingLocationText(CaseData caseData, String authorisation) { + return caseData.getHearingLocationText() != null ? caseData.getHearingLocationText() + : getCaseManagementLocationText(caseData, authorisation); + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/hearing/HearingFormGenerator.java b/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/hearing/HearingFormGenerator.java index ea16e212bc2..29420287557 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/hearing/HearingFormGenerator.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/hearing/HearingFormGenerator.java @@ -11,11 +11,16 @@ import uk.gov.hmcts.reform.civil.documentmanagement.model.CaseDocument; import uk.gov.hmcts.reform.civil.documentmanagement.model.DocumentType; import uk.gov.hmcts.reform.civil.documentmanagement.model.PDF; + +import uk.gov.hmcts.reform.civil.referencedata.LocationRefDataService; +import uk.gov.hmcts.reform.civil.referencedata.model.LocationRefData; +import uk.gov.hmcts.reform.civil.service.FeatureToggleService; import uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates; import uk.gov.hmcts.reform.civil.service.docmosis.DocumentGeneratorService; import uk.gov.hmcts.reform.civil.service.docmosis.TemplateDataGenerator; import uk.gov.hmcts.reform.civil.documentmanagement.DocumentManagementService; import uk.gov.hmcts.reform.civil.utils.AssignCategoryId; +import uk.gov.hmcts.reform.civil.utils.CourtLocationUtils; import uk.gov.hmcts.reform.civil.utils.HearingUtils; import java.time.LocalDate; @@ -25,9 +30,13 @@ import static java.util.Objects.isNull; import static java.util.Objects.nonNull; import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.HEARING_APPLICATION; +import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.HEARING_APPLICATION_AHN; import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.HEARING_FAST_TRACK; +import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.HEARING_FAST_TRACK_AHN; import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.HEARING_OTHER; +import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.HEARING_OTHER_AHN; import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.HEARING_SMALL_CLAIMS; +import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.HEARING_SMALL_CLAIMS_AHN; import static uk.gov.hmcts.reform.civil.utils.HearingUtils.formatHearingDuration; import static uk.gov.hmcts.reform.civil.utils.HearingUtils.getHearingTimeFormatted; import static uk.gov.hmcts.reform.civil.utils.HearingUtils.getHearingType; @@ -39,11 +48,14 @@ public class HearingFormGenerator implements TemplateDataGenerator private final DocumentManagementService documentManagementService; private final DocumentGeneratorService documentGeneratorService; private final AssignCategoryId assignCategoryId; + private final FeatureToggleService featureToggleService; + private final LocationRefDataService locationRefDataService; + private final CourtLocationUtils courtLocationUtils; public List generate(CaseData caseData, String authorisation) { List caseDocuments = new ArrayList<>(); - HearingForm templateData = getTemplateData(caseData); + HearingForm templateData = getTemplateData(caseData, authorisation); DocmosisTemplates template = getTemplate(caseData); DocmosisDocument document = documentGeneratorService.generateDocmosisDocument(templateData, template); @@ -60,10 +72,11 @@ public List generate(CaseData caseData, String authorisation) { return caseDocuments; } - @Override - public HearingForm getTemplateData(CaseData caseData) { + public HearingForm getTemplateData(CaseData caseData, String authorisation) { + List locations = (locationRefDataService.getCourtLocationsForDefaultJudgments(authorisation)); return HearingForm.builder() + .courtName(courtLocationUtils.findPreferredLocationData(locations, caseData.getHearingLocation()).getSiteName()) .listingOrRelisting(caseData.getListingOrRelisting().toString()) .court(caseData.getHearingLocation().getValue().getLabel()) .caseNumber(caseData.getLegacyCaseReference()) @@ -115,15 +128,28 @@ private boolean checkReference(CaseData caseData) { } private DocmosisTemplates getTemplate(CaseData caseData) { - switch (caseData.getHearingNoticeList()) { - case SMALL_CLAIMS: - return HEARING_SMALL_CLAIMS; - case FAST_TRACK_TRIAL: - return HEARING_FAST_TRACK; - case HEARING_OF_APPLICATION: - return HEARING_APPLICATION; - default: - return HEARING_OTHER; + if (!featureToggleService.isAutomatedHearingNoticeEnabled()) { + switch (caseData.getHearingNoticeList()) { + case SMALL_CLAIMS: + return HEARING_SMALL_CLAIMS; + case FAST_TRACK_TRIAL: + return HEARING_FAST_TRACK; + case HEARING_OF_APPLICATION: + return HEARING_APPLICATION; + default: + return HEARING_OTHER; + } + } else { + switch (caseData.getHearingNoticeList()) { + case SMALL_CLAIMS: + return HEARING_SMALL_CLAIMS_AHN; + case FAST_TRACK_TRIAL: + return HEARING_FAST_TRACK_AHN; + case HEARING_OF_APPLICATION: + return HEARING_APPLICATION_AHN; + default: + return HEARING_OTHER_AHN; + } } } } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/hearing/HearingNoticeHmcGenerator.java b/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/hearing/HearingNoticeHmcGenerator.java index 9cbf7fc5e24..80113bc4d14 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/hearing/HearingNoticeHmcGenerator.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/hearing/HearingNoticeHmcGenerator.java @@ -1,7 +1,6 @@ package uk.gov.hmcts.reform.civil.service.docmosis.hearing; import lombok.RequiredArgsConstructor; -import org.jetbrains.annotations.Nullable; import org.springframework.stereotype.Service; import uk.gov.hmcts.reform.civil.documentmanagement.DocumentManagementService; import uk.gov.hmcts.reform.civil.documentmanagement.model.CaseDocument; @@ -31,6 +30,7 @@ import static java.util.Objects.nonNull; import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.HEARING_NOTICE_HMC; import static uk.gov.hmcts.reform.civil.utils.HmcDataUtils.getHearingDaysText; +import static uk.gov.hmcts.reform.civil.utils.HmcDataUtils.getLocationRefData; import static uk.gov.hmcts.reform.civil.utils.HmcDataUtils.getTotalHearingDurationText; @Service @@ -43,10 +43,10 @@ public class HearingNoticeHmcGenerator implements TemplateDataGenerator generate(CaseData caseData, HearingGetResponse hearing, String authorisation) { + public List generate(CaseData caseData, HearingGetResponse hearing, String authorisation, String hearingLocation, String hearingId) { List caseDocuments = new ArrayList<>(); - HearingNoticeHmc templateData = getHearingNoticeTemplateData(caseData, hearing, authorisation); + HearingNoticeHmc templateData = getHearingNoticeTemplateData(caseData, hearing, authorisation, hearingLocation, hearingId); DocmosisTemplates template = getTemplate(caseData); DocmosisDocument document = documentGeneratorService.generateDocmosisDocument(templateData, template); @@ -61,7 +61,8 @@ public List generate(CaseData caseData, HearingGetResponse hearing return caseDocuments; } - public HearingNoticeHmc getHearingNoticeTemplateData(CaseData caseData, HearingGetResponse hearing, String bearerToken) { + public HearingNoticeHmc getHearingNoticeTemplateData(CaseData caseData, HearingGetResponse hearing, String bearerToken, + String hearingLocation, String hearingId) { var paymentFailed = caseData.getHearingFeePaymentDetails() == null || caseData.getHearingFeePaymentDetails().getStatus().equals(PaymentStatus.FAILED); var feeAmount = paymentFailed @@ -69,15 +70,13 @@ public HearingNoticeHmc getHearingNoticeTemplateData(CaseData caseData, HearingG var hearingDueDate = paymentFailed ? HearingFeeUtils .calculateHearingDueDate(LocalDate.now(), HmcDataUtils.getHearingStartDay(hearing) .getHearingStartDateTime().toLocalDate()) : null; - LocationRefData hearingLocation = getLocationRefData( - HmcDataUtils.getHearingStartDay(hearing).getHearingVenueId(), - bearerToken); + LocationRefData caseManagementLocation = - getLocationRefData(caseData.getCaseManagementLocation().getBaseLocation(), bearerToken); + getLocationRefData(hearingId, caseData.getCaseManagementLocation().getBaseLocation(), bearerToken, locationRefDataService); return HearingNoticeHmc.builder() .hearingSiteName(nonNull(caseManagementLocation) ? caseManagementLocation.getSiteName() : null) - .hearingLocation(LocationRefDataService.getDisplayEntry(hearingLocation)) + .hearingLocation(hearingLocation) .caseNumber(caseData.getCcdCaseReference()) .creationDate(LocalDate.now()) .hearingType(getHearingType(hearing)) @@ -107,13 +106,6 @@ private DocmosisTemplates getTemplate(CaseData caseData) { return HEARING_NOTICE_HMC; } - @Nullable - private LocationRefData getLocationRefData(String venueId, String bearerToken) { - List locations = locationRefDataService.getCourtLocationsForDefaultJudgments(bearerToken); - var matchedLocations = locations.stream().filter(loc -> loc.getEpimmsId().equals(venueId)).toList(); - return matchedLocations.size() > 0 ? matchedLocations.get(0) : null; - } - private String getHearingType(HearingGetResponse hearing) { if (hearing.getHearingDetails().getHearingType().contains("TRI")) { return "trial"; diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowFlag.java b/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowFlag.java index 210de4df026..58964b34eed 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowFlag.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowFlag.java @@ -6,14 +6,12 @@ public enum FlowFlag { UNREPRESENTED_DEFENDANT_ONE, UNREPRESENTED_DEFENDANT_TWO, PIP_ENABLED, - NOTICE_OF_CHANGE, AGREED_TO_MEDIATION, IS_MULTI_TRACK, SDO_ENABLED, CONTACT_DETAILS_CHANGE, GENERAL_APPLICATION_ENABLED, BULK_CLAIM_ENABLED, - CERTIFICATE_OF_SERVICE, RESPONDENT_RESPONSE_LANGUAGE_IS_BILINGUAL, LR_V_LIP_ENABLED, LIP_CASE; diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowLipPredicate.java b/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowLipPredicate.java index a78a97571a0..f1d9c2bcd31 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowLipPredicate.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowLipPredicate.java @@ -24,4 +24,7 @@ private FlowLipPredicate() { public static final Predicate ccjRequestJudgmentByAdmission = CaseData::isCcjRequestJudgmentByAdmission; + public static final Predicate isRespondentSignSettlementAgreement = + CaseData::isRespondentSignSettlementAgreement; + } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowPredicate.java b/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowPredicate.java index f0bfc9f7825..c8c2b45c00e 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowPredicate.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowPredicate.java @@ -71,6 +71,12 @@ private FlowPredicate() { && ((caseData.getRespondent1OrgRegistered() == YES && caseData.getRespondent2OrgRegistered() == NO) || (caseData.getRespondent2OrgRegistered() == YES && caseData.getRespondent1OrgRegistered() == NO)); + public static final Predicate claimSubmitted1v1RespondentOneUnregistered = caseData -> + caseData.getSubmittedDate() != null + && caseData.getAddRespondent2() == NO + && caseData.getRespondent1Represented() == YES + && caseData.getRespondent1OrgRegistered() == NO; + // have to use this for now because cannot use featureToggleService.isNoticeOfChangeEnabled() as predicate public static final Predicate noticeOfChangeEnabled = caseData -> (caseData.getDefendant1LIPAtClaimIssued() != null diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowState.java b/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowState.java index dd643f7bc6e..e0d1d9c4f54 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowState.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowState.java @@ -84,7 +84,8 @@ enum Main implements FlowState { IN_HEARING_READINESS, MEDIATION_UNSUCCESSFUL_PROCEED, All_FINAL_ORDERS_ISSUED, - PREPARE_FOR_HEARING_CONDUCT_HEARING; + PREPARE_FOR_HEARING_CONDUCT_HEARING, + SIGN_SETTLEMENT_AGREEMENT; public static final String FLOW_NAME = "MAIN"; diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowStateAllowedEventService.java b/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowStateAllowedEventService.java index 85c31fb7330..6b3bca35ff1 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowStateAllowedEventService.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowStateAllowedEventService.java @@ -14,9 +14,6 @@ import static java.util.Collections.emptyList; import static java.util.Map.entry; -import static uk.gov.hmcts.reform.civil.callback.CaseEvent.LIFT_BREATHING_SPACE_LIP; -import static uk.gov.hmcts.reform.civil.callback.CaseEvent.asyncStitchingComplete; -import static uk.gov.hmcts.reform.civil.enums.CaseCategory.SPEC_CLAIM; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.ACKNOWLEDGEMENT_OF_SERVICE; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.ACKNOWLEDGE_CLAIM; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.ADD_CASE_NOTE; @@ -44,6 +41,7 @@ import static uk.gov.hmcts.reform.civil.callback.CaseEvent.DEFENDANT_RESPONSE; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.DEFENDANT_RESPONSE_CUI; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.DEFENDANT_RESPONSE_SPEC; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.DEFENDANT_SIGN_SETTLEMENT_AGREEMENT; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.DISCONTINUE_CLAIM; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.DISMISS_CLAIM; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.ENTER_BREATHING_SPACE_LIP; @@ -60,6 +58,7 @@ import static uk.gov.hmcts.reform.civil.callback.CaseEvent.INFORM_AGREED_EXTENSION_DATE_SPEC; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.INITIATE_GENERAL_APPLICATION; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.JUDGMENT_PAID_IN_FULL; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.LIFT_BREATHING_SPACE_LIP; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.LIFT_BREATHING_SPACE_SPEC; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.LIP_CLAIM_SETTLED; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.MANAGE_CONTACT_INFORMATION; @@ -86,11 +85,11 @@ import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIAL_READINESS; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIAL_READY_CHECK; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIAL_READY_NOTIFICATION; +import static uk.gov.hmcts.reform.civil.enums.CaseCategory.SPEC_CLAIM; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.UPLOAD_TRANSLATED_DOCUMENT; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.WITHDRAW_CLAIM; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.asyncStitchingComplete; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.migrateCase; -import static uk.gov.hmcts.reform.civil.enums.CaseCategory.SPEC_CLAIM; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.AWAITING_RESPONSES_FULL_DEFENCE_RECEIVED; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.AWAITING_RESPONSES_NOT_FULL_DEFENCE_RECEIVED; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.CLAIM_DETAILS_NOTIFIED; @@ -108,6 +107,7 @@ import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.DIVERGENT_RESPOND_GO_OFFLINE; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.DRAFT; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.FULL_ADMISSION; +import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.FULL_ADMIT_AGREE_REPAYMENT; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.FULL_DEFENCE; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.FULL_DEFENCE_NOT_PROCEED; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.FULL_DEFENCE_PROCEED; @@ -117,6 +117,7 @@ import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.NOTIFICATION_ACKNOWLEDGED; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.NOTIFICATION_ACKNOWLEDGED_TIME_EXTENSION; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.PART_ADMISSION; +import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.PART_ADMIT_AGREE_REPAYMENT; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.PART_ADMIT_NOT_SETTLED_NO_MEDIATION; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.PAST_APPLICANT_RESPONSE_DEADLINE_AWAITING_CAMUNDA; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.PAST_CLAIM_DETAILS_NOTIFICATION_DEADLINE_AWAITING_CAMUNDA; @@ -544,6 +545,7 @@ public class FlowStateAllowedEventService { JUDGMENT_PAID_IN_FULL, RECORD_JUDGMENT, TRANSFER_ONLINE_CASE, + CLAIMANT_RESPONSE_CUI, asyncStitchingComplete ) ), @@ -602,11 +604,11 @@ public class FlowStateAllowedEventService { PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT.fullName(), List.of( NOC_REQUEST, - APPLY_NOC_DECISION, - TAKE_CASE_OFFLINE, - NOTIFY_DEFENDANT_OF_CLAIM, - APPLICATION_OFFLINE_UPDATE_CLAIM, - migrateCase + APPLY_NOC_DECISION, + TAKE_CASE_OFFLINE, + NOTIFY_DEFENDANT_OF_CLAIM, + APPLICATION_OFFLINE_UPDATE_CLAIM, + migrateCase ) ), entry( @@ -1105,7 +1107,9 @@ public class FlowStateAllowedEventService { RECORD_JUDGMENT, LIP_CLAIM_SETTLED, TRANSFER_ONLINE_CASE, - asyncStitchingComplete + asyncStitchingComplete, + CLAIMANT_RESPONSE_CUI + ) ), @@ -1256,7 +1260,7 @@ public class FlowStateAllowedEventService { asyncStitchingComplete ) ), - entry( + entry( PART_ADMIT_NOT_SETTLED_NO_MEDIATION.fullName(), List.of( ADD_DEFENDANT_LITIGATION_FRIEND, @@ -1412,6 +1416,18 @@ public class FlowStateAllowedEventService { ADD_CASE_NOTE, AMEND_PARTY_DETAILS ) + ), + entry( + PART_ADMIT_AGREE_REPAYMENT.fullName(), + List.of( + DEFENDANT_SIGN_SETTLEMENT_AGREEMENT + ) + ), + entry( + FULL_ADMIT_AGREE_REPAYMENT.fullName(), + List.of( + DEFENDANT_SIGN_SETTLEMENT_AGREEMENT + ) ) ); diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/StateFlowEngine.java b/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/StateFlowEngine.java index 39f82bb7088..7c3887dda80 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/StateFlowEngine.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/flowstate/StateFlowEngine.java @@ -21,6 +21,7 @@ import static uk.gov.hmcts.reform.civil.service.flowstate.FlowLipPredicate.ccjRequestJudgmentByAdmission; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowLipPredicate.declinedMediation; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowLipPredicate.isLipCase; +import static uk.gov.hmcts.reform.civil.service.flowstate.FlowLipPredicate.isRespondentSignSettlementAgreement; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowLipPredicate.isTranslatedDocumentUploaded; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowLipPredicate.partAdmitPayImmediately; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.acceptRepaymentPlan; @@ -46,13 +47,12 @@ import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.claimDismissedByCamunda; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.claimIssued; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.claimNotified; -import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.claimSubmittedBothRespondentUnrepresented; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.claimSubmittedBothUnregisteredSolicitors; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.claimSubmittedOneRespondentRepresentative; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.claimSubmittedOneUnrepresentedDefendantOnly; -import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.claimSubmittedOnlyOneRespondentRepresented; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.claimSubmittedRespondent1Unrepresented; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.claimSubmittedRespondent2Unrepresented; +import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.claimSubmitted1v1RespondentOneUnregistered; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.claimSubmittedTwoRegisteredRespondentRepresentatives; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.claimSubmittedTwoRespondentRepresentativesOneUnregistered; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.contactDetailsChange; @@ -75,7 +75,6 @@ import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.isPayImmediately; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.isRespondentResponseLangIsBilingual; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.multipartyCase; -import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.noticeOfChangeEnabled; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.notificationAcknowledged; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.oneVsOneCase; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.partAdmission; @@ -168,6 +167,7 @@ import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT_ONE_V_ONE_SPEC; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.PENDING_CLAIM_ISSUED_UNREPRESENTED_UNREGISTERED_DEFENDANT; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.RESPONDENT_RESPONSE_LANGUAGE_IS_BILINGUAL; +import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.SIGN_SETTLEMENT_AGREEMENT; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.SPEC_DRAFT; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.TAKEN_OFFLINE_AFTER_CLAIM_DETAILS_NOTIFIED; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.TAKEN_OFFLINE_AFTER_CLAIM_NOTIFIED; @@ -190,98 +190,68 @@ public StateFlow build(FlowState.Main initialState) { return StateFlowBuilder.flow(FLOW_NAME) .initial(initialState) .transitionTo(CLAIM_SUBMITTED) - .onlyIf(claimSubmittedOneRespondentRepresentative) + .onlyIf(claimSubmittedOneRespondentRepresentative.or(claimSubmitted1v1RespondentOneUnregistered)) .set(flags -> flags.putAll( // Do not set UNREPRESENTED_DEFENDANT_ONE or UNREPRESENTED_DEFENDANT_TWO to false here unless // camunda diagram for TAKE_CASE_OFFLINE is changed Map.of( FlowFlag.ONE_RESPONDENT_REPRESENTATIVE.name(), true, - FlowFlag.NOTICE_OF_CHANGE.name(), featureToggleService.isNoticeOfChangeEnabled(), - FlowFlag.CERTIFICATE_OF_SERVICE.name(), featureToggleService.isCertificateOfServiceEnabled(), GENERAL_APPLICATION_ENABLED.name(), featureToggleService.isGeneralApplicationsEnabled(), BULK_CLAIM_ENABLED.name(), featureToggleService.isBulkClaimEnabled() ))) .transitionTo(CLAIM_SUBMITTED) .onlyIf(claimSubmittedTwoRegisteredRespondentRepresentatives - .or(claimSubmittedTwoRespondentRepresentativesOneUnregistered)) + .or(claimSubmittedTwoRespondentRepresentativesOneUnregistered) + .or(claimSubmittedBothUnregisteredSolicitors)) .set(flags -> flags.putAll( // Do not set UNREPRESENTED_DEFENDANT_ONE or UNREPRESENTED_DEFENDANT_TWO to false here unless // camunda diagram for TAKE_CASE_OFFLINE is changed Map.of( FlowFlag.ONE_RESPONDENT_REPRESENTATIVE.name(), false, FlowFlag.TWO_RESPONDENT_REPRESENTATIVES.name(), true, - FlowFlag.NOTICE_OF_CHANGE.name(), featureToggleService.isNoticeOfChangeEnabled(), - FlowFlag.CERTIFICATE_OF_SERVICE.name(), featureToggleService.isCertificateOfServiceEnabled(), - GENERAL_APPLICATION_ENABLED.name(), featureToggleService.isGeneralApplicationsEnabled(), - BULK_CLAIM_ENABLED.name(), featureToggleService.isBulkClaimEnabled() - ))) - // To be removed when NOC is released. Needed for cases with unregistered and unrepresented defendants - .transitionTo(CLAIM_SUBMITTED) - .onlyIf(noticeOfChangeEnabled.negate() - .and((claimSubmittedBothRespondentUnrepresented - .or(claimSubmittedOnlyOneRespondentRepresented) - .or(claimSubmittedBothUnregisteredSolicitors) - // this line MUST be removed when NOC toggle(noticeOfChangeEnabledAndLiP) is removed - .or(claimSubmittedOneUnrepresentedDefendantOnly)))) - .set(flags -> flags.putAll( - // Do not set UNREPRESENTED_DEFENDANT_ONE or UNREPRESENTED_DEFENDANT_TWO to false here unless - // camunda diagram for TAKE_CASE_OFFLINE is changed - Map.of( - FlowFlag.NOTICE_OF_CHANGE.name(), featureToggleService.isNoticeOfChangeEnabled(), - FlowFlag.CERTIFICATE_OF_SERVICE.name(), featureToggleService.isCertificateOfServiceEnabled(), GENERAL_APPLICATION_ENABLED.name(), featureToggleService.isGeneralApplicationsEnabled(), BULK_CLAIM_ENABLED.name(), featureToggleService.isBulkClaimEnabled() ))) // Only one unrepresented defendant .transitionTo(CLAIM_SUBMITTED) - .onlyIf(noticeOfChangeEnabled.and(claimSubmittedOneUnrepresentedDefendantOnly)) + .onlyIf(claimSubmittedOneUnrepresentedDefendantOnly) .set(flags -> flags.putAll( Map.of( FlowFlag.UNREPRESENTED_DEFENDANT_ONE.name(), true, - FlowFlag.NOTICE_OF_CHANGE.name(), featureToggleService.isNoticeOfChangeEnabled(), - FlowFlag.CERTIFICATE_OF_SERVICE.name(), featureToggleService.isCertificateOfServiceEnabled(), GENERAL_APPLICATION_ENABLED.name(), featureToggleService.isGeneralApplicationsEnabled(), BULK_CLAIM_ENABLED.name(), featureToggleService.isBulkClaimEnabled() ))) // Unrepresented defendant 1 .transitionTo(CLAIM_SUBMITTED) - .onlyIf(noticeOfChangeEnabled - .and(claimSubmittedRespondent1Unrepresented) + .onlyIf(claimSubmittedRespondent1Unrepresented .and(claimSubmittedOneUnrepresentedDefendantOnly.negate()) .and(claimSubmittedRespondent2Unrepresented.negate())) .set(flags -> flags.putAll( Map.of( FlowFlag.UNREPRESENTED_DEFENDANT_ONE.name(), true, FlowFlag.UNREPRESENTED_DEFENDANT_TWO.name(), false, - FlowFlag.NOTICE_OF_CHANGE.name(), featureToggleService.isNoticeOfChangeEnabled(), - FlowFlag.CERTIFICATE_OF_SERVICE.name(), featureToggleService.isCertificateOfServiceEnabled(), GENERAL_APPLICATION_ENABLED.name(), featureToggleService.isGeneralApplicationsEnabled(), BULK_CLAIM_ENABLED.name(), featureToggleService.isBulkClaimEnabled() ))) // Unrepresented defendant 2 .transitionTo(CLAIM_SUBMITTED) - .onlyIf(noticeOfChangeEnabled - .and(claimSubmittedRespondent2Unrepresented - .and(claimSubmittedRespondent1Unrepresented.negate()))) + .onlyIf(claimSubmittedRespondent2Unrepresented + .and(claimSubmittedRespondent1Unrepresented.negate())) .set(flags -> flags.putAll( Map.of( FlowFlag.UNREPRESENTED_DEFENDANT_ONE.name(), false, FlowFlag.UNREPRESENTED_DEFENDANT_TWO.name(), true, - FlowFlag.NOTICE_OF_CHANGE.name(), featureToggleService.isNoticeOfChangeEnabled(), - FlowFlag.CERTIFICATE_OF_SERVICE.name(), featureToggleService.isCertificateOfServiceEnabled(), GENERAL_APPLICATION_ENABLED.name(), featureToggleService.isGeneralApplicationsEnabled(), BULK_CLAIM_ENABLED.name(), featureToggleService.isBulkClaimEnabled() ))) // Unrepresented defendants .transitionTo(CLAIM_SUBMITTED) - .onlyIf(noticeOfChangeEnabled.and(claimSubmittedRespondent1Unrepresented.and( - claimSubmittedRespondent2Unrepresented))) + .onlyIf(claimSubmittedRespondent1Unrepresented.and( + claimSubmittedRespondent2Unrepresented)) .set(flags -> flags.putAll( Map.of( FlowFlag.UNREPRESENTED_DEFENDANT_ONE.name(), true, FlowFlag.UNREPRESENTED_DEFENDANT_TWO.name(), true, - FlowFlag.NOTICE_OF_CHANGE.name(), featureToggleService.isNoticeOfChangeEnabled(), - FlowFlag.CERTIFICATE_OF_SERVICE.name(), featureToggleService.isCertificateOfServiceEnabled(), GENERAL_APPLICATION_ENABLED.name(), featureToggleService.isGeneralApplicationsEnabled(), BULK_CLAIM_ENABLED.name(), featureToggleService.isBulkClaimEnabled() ))) @@ -355,7 +325,7 @@ public StateFlow build(FlowState.Main initialState) { .and(not(specClaim)) .and(certificateOfServiceEnabled)) .transitionTo(TAKEN_OFFLINE_UNREPRESENTED_DEFENDANT).onlyIf(takenOfflineBySystem - .and(noticeOfChangeEnabled.negate())) + .and(specClaim)) .state(PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT_ONE_V_ONE_SPEC) .transitionTo(CLAIM_ISSUED) .onlyIf(claimIssued.and(pinInPostEnabledAndLiP)) @@ -593,6 +563,7 @@ public StateFlow build(FlowState.Main initialState) { .state(TAKEN_OFFLINE_AFTER_SDO) .state(PART_ADMIT_AGREE_SETTLE) .state(PART_ADMIT_AGREE_REPAYMENT) + .transitionTo(SIGN_SETTLEMENT_AGREEMENT).onlyIf(isRespondentSignSettlementAgreement) .state(PART_ADMIT_REJECT_REPAYMENT) .state(PART_ADMIT_PROCEED) .state(PART_ADMIT_NOT_PROCEED) @@ -603,6 +574,7 @@ public StateFlow build(FlowState.Main initialState) { .transitionTo(TAKEN_OFFLINE_AFTER_SDO).onlyIf(takenOfflineAfterSDO) .transitionTo(TAKEN_OFFLINE_SDO_NOT_DRAWN).onlyIf(takenOfflineSDONotDrawn) .state(FULL_ADMIT_AGREE_REPAYMENT) + .transitionTo(SIGN_SETTLEMENT_AGREEMENT).onlyIf(isRespondentSignSettlementAgreement) .state(FULL_ADMIT_REJECT_REPAYMENT) .state(FULL_ADMIT_PROCEED) .state(FULL_ADMIT_NOT_PROCEED) @@ -620,6 +592,7 @@ public StateFlow build(FlowState.Main initialState) { .transitionTo(TAKEN_OFFLINE_SDO_NOT_DRAWN).onlyIf(takenOfflineSDONotDrawn) .state(IN_HEARING_READINESS) .state(FULL_ADMIT_JUDGMENT_ADMISSION) + .state(SIGN_SETTLEMENT_AGREEMENT) .build(); } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/robotics/mapper/EventHistoryMapper.java b/src/main/java/uk/gov/hmcts/reform/civil/service/robotics/mapper/EventHistoryMapper.java index f393162c526..6c9d71c1bcf 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/robotics/mapper/EventHistoryMapper.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/robotics/mapper/EventHistoryMapper.java @@ -68,7 +68,6 @@ import static uk.gov.hmcts.reform.civil.enums.PartyRole.RESPONDENT_ONE; import static uk.gov.hmcts.reform.civil.enums.RespondentResponseType.FULL_DEFENCE; import static uk.gov.hmcts.reform.civil.enums.UnrepresentedOrUnregisteredScenario.UNREGISTERED; -import static uk.gov.hmcts.reform.civil.enums.UnrepresentedOrUnregisteredScenario.UNREGISTERED_NOTICE_OF_CHANGE; import static uk.gov.hmcts.reform.civil.enums.UnrepresentedOrUnregisteredScenario.UNREPRESENTED; import static uk.gov.hmcts.reform.civil.enums.UnrepresentedOrUnregisteredScenario.getDefendantNames; import static uk.gov.hmcts.reform.civil.enums.YesOrNo.NO; @@ -1422,7 +1421,7 @@ private void buildRespondentFullDefence(EventHistory.EventHistoryBuilder builder Respondent1DQ respondent1DQ = caseData.getRespondent1DQ(); LocalDateTime respondent1ResponseDate = caseData.getRespondent1ResponseDate(); - if (caseData.isLRvLipOneVOne()) { + if (caseData.isLRvLipOneVOne() || caseData.isLipvLipOneVOne()) { buildLrVLipFullDefenceEvent(builder, caseData, defenceFiledEvents, statesPaidEvents); } else { if (isAllPaid(caseData.getTotalClaimAmount(), caseData.getRespondToClaim())) { @@ -1636,12 +1635,7 @@ private void buildOfflineAfterClaimsDetailsNotified(EventHistory.EventHistoryBui private void buildUnregisteredDefendant(EventHistory.EventHistoryBuilder builder, CaseData caseData) { List unregisteredDefendantsNames; - // NOC: Revert after NOC is live - if (featureToggleService.isNoticeOfChangeEnabled()) { - unregisteredDefendantsNames = getDefendantNames(UNREGISTERED_NOTICE_OF_CHANGE, caseData); - } else { - unregisteredDefendantsNames = getDefendantNames(UNREGISTERED, caseData); - } + unregisteredDefendantsNames = getDefendantNames(UNREGISTERED, caseData); List events = IntStream.range(0, unregisteredDefendantsNames.size()) .mapToObj(index -> { @@ -1675,13 +1669,7 @@ private void buildUnregisteredAndUnrepresentedDefendant(EventHistory.EventHistor CaseData caseData) { String localDateTime = time.now().toLocalDate().toString(); - // NOC: Revert after NOC is live - List unregisteredDefendantsNames; - if (featureToggleService.isNoticeOfChangeEnabled()) { - unregisteredDefendantsNames = getDefendantNames(UNREGISTERED_NOTICE_OF_CHANGE, caseData); - } else { - unregisteredDefendantsNames = getDefendantNames(UNREGISTERED, caseData); - } + List unregisteredDefendantsNames = getDefendantNames(UNREGISTERED, caseData); String unrepresentedEventText = format( "RPA Reason: [1 of 2 - %s] Unrepresented defendant and unregistered " diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/robotics/mapper/RoboticsDataMapper.java b/src/main/java/uk/gov/hmcts/reform/civil/service/robotics/mapper/RoboticsDataMapper.java index 40e0726dfc4..c98b7054f5c 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/robotics/mapper/RoboticsDataMapper.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/robotics/mapper/RoboticsDataMapper.java @@ -71,9 +71,8 @@ public RoboticsCaseData toRoboticsCaseData(CaseData caseData, String authToken) .claimDetails(buildClaimDetails(caseData)) .events(eventHistoryMapper.buildEvents(caseData)); - if (featureToggleService.isNoticeOfChangeEnabled() - && (caseData.getCcdState() == PROCEEDS_IN_HERITAGE_SYSTEM - || caseData.getCcdState() == CASE_DISMISSED)) { + if (caseData.getCcdState() == PROCEEDS_IN_HERITAGE_SYSTEM + || caseData.getCcdState() == CASE_DISMISSED) { roboticsBuilder.noticeOfChange(RoboticsDataUtil.buildNoticeOfChange(caseData)); } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/robotics/mapper/RoboticsDataMapperForSpec.java b/src/main/java/uk/gov/hmcts/reform/civil/service/robotics/mapper/RoboticsDataMapperForSpec.java index f3354fc706a..c6fcdf4f165 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/robotics/mapper/RoboticsDataMapperForSpec.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/robotics/mapper/RoboticsDataMapperForSpec.java @@ -69,9 +69,8 @@ public RoboticsCaseDataSpec toRoboticsCaseData(CaseData caseData) { .claimDetails(buildClaimDetails(caseData)) .events(eventHistoryMapper.buildEvents(caseData)); - if (featureToggleService.isNoticeOfChangeEnabled() - && (caseData.getCcdState() == PROCEEDS_IN_HERITAGE_SYSTEM - || caseData.getCcdState() == CASE_DISMISSED)) { + if (caseData.getCcdState() == PROCEEDS_IN_HERITAGE_SYSTEM + || caseData.getCcdState() == CASE_DISMISSED) { builder.noticeOfChange(RoboticsDataUtil.buildNoticeOfChange(caseData)); } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/tasklisteners/ResendNotifyRPAEventsTaskListener.java b/src/main/java/uk/gov/hmcts/reform/civil/service/tasklisteners/RetriggerCasesTaskListener.java similarity index 50% rename from src/main/java/uk/gov/hmcts/reform/civil/service/tasklisteners/ResendNotifyRPAEventsTaskListener.java rename to src/main/java/uk/gov/hmcts/reform/civil/service/tasklisteners/RetriggerCasesTaskListener.java index 8fe17b89291..3b62da4de96 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/tasklisteners/ResendNotifyRPAEventsTaskListener.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/tasklisteners/RetriggerCasesTaskListener.java @@ -4,16 +4,16 @@ import org.camunda.bpm.client.topic.TopicSubscriptionBuilder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import uk.gov.hmcts.reform.civil.handler.ResendNotifyRPAEventsHandler; +import uk.gov.hmcts.reform.civil.handler.RetriggerCasesEventHandler; @Component -public class ResendNotifyRPAEventsTaskListener { +public class RetriggerCasesTaskListener { - private static final String TOPIC = "RESEND_NOTIFY_RPA_EVENTS"; + private static final String TOPIC = "RETRIGGER_CASES_EVENTS"; @Autowired - private ResendNotifyRPAEventsTaskListener(ResendNotifyRPAEventsHandler resendNotifyRPAEventsHandler, ExternalTaskClient client) { + private RetriggerCasesTaskListener(RetriggerCasesEventHandler retriggerCasesEventHandler, ExternalTaskClient client) { TopicSubscriptionBuilder subscriptionBuilder = client.subscribe(TOPIC); - subscriptionBuilder.handler(resendNotifyRPAEventsHandler).open(); + subscriptionBuilder.handler(retriggerCasesEventHandler).open(); } } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/utils/CaseFlagUtils.java b/src/main/java/uk/gov/hmcts/reform/civil/utils/CaseFlagUtils.java index cfc0249f777..34ec802e60a 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/utils/CaseFlagUtils.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/utils/CaseFlagUtils.java @@ -24,21 +24,27 @@ import static uk.gov.hmcts.reform.civil.utils.ElementUtils.element; import static uk.gov.hmcts.reform.civil.utils.ElementUtils.unwrapElements; import static uk.gov.hmcts.reform.civil.utils.ElementUtils.wrapElements; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_ONE_EXPERTS_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_ONE_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_ONE_LEGAL_REP_INDIVIDUALS_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_ONE_LITIGATION_FRIEND_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_ONE_ORG_INDIVIDUALS_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_ONE_WITNESSES_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_TWO_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_TWO_LITIGATION_FRIEND_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_TWO_ORG_INDIVIDUALS_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_ONE_EXPERTS_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_ONE_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_ONE_LEGAL_REP_INDIVIDUALS_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_ONE_LITIGATION_FRIEND_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_ONE_ORG_INDIVIDUALS_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_ONE_WITNESSES_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_TWO_EXPERTS_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_TWO_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_TWO_LEGAL_REP_INDIVIDUALS_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_TWO_LITIGATION_FRIEND_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_TWO_ORG_INDIVIDUALS_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_TWO_WITNESSES_ID; import static uk.gov.hmcts.reform.civil.utils.PartyUtils.appendWithNewPartyId; import uk.gov.hmcts.reform.civil.model.LitigationFriend; @@ -48,20 +54,20 @@ public class CaseFlagUtils { - public static final String RESPONDENT_SOLICITOR_ONE_WITNESS = "Respondent solicitor 1 witness"; - public static final String RESPONDENT_SOLICITOR_ONE_EXPERT = "Respondent solicitor 1 expert"; - public static final String RESPONDENT_SOLICITOR_TWO_WITNESS = "Respondent solicitor 2 witness"; - public static final String RESPONDENT_SOLICITOR_TWO_EXPERT = "Respondent solicitor 2 expert"; - public static final String APPLICANT_SOLICITOR_WITNESS = "Applicant solicitor witness"; - public static final String APPLICANT_SOLICITOR_EXPERT = "Applicant solicitor expert"; - public static final String APPLICANT_ONE = "Applicant 1"; - public static final String APPLICANT_TWO = "Applicant 2"; - public static final String APPLICANT_ONE_LITIGATION_FRIEND = "Applicant 1 Litigation Friend"; - public static final String APPLICANT_TWO_LITIGATION_FRIEND = "Applicant 2 Litigation Friend"; - public static final String RESPONDENT_ONE = "Respondent 1"; - public static final String RESPONDENT_TWO = "Respondent 2"; - public static final String RESPONDENT_ONE_LITIGATION_FRIEND = "Respondent 1 Litigation Friend"; - public static final String RESPONDENT_TWO_LITIGATION_FRIEND = "Respondent 2 Litigation Friend"; + public static final String RESPONDENT_SOLICITOR_ONE_WITNESS = "Defendant solicitor 1 witness"; + public static final String RESPONDENT_SOLICITOR_ONE_EXPERT = "Defendant solicitor 1 expert"; + public static final String RESPONDENT_SOLICITOR_TWO_WITNESS = "Defendant solicitor 2 witness"; + public static final String RESPONDENT_SOLICITOR_TWO_EXPERT = "Defendant solicitor 2 expert"; + public static final String APPLICANT_SOLICITOR_WITNESS = "Claimant solicitor witness"; + public static final String APPLICANT_SOLICITOR_EXPERT = "Claimant solicitor expert"; + public static final String APPLICANT_ONE = "Claimant 1"; + public static final String APPLICANT_TWO = "Claimant 2"; + public static final String APPLICANT_ONE_LITIGATION_FRIEND = "Claimant 1 Litigation Friend"; + public static final String APPLICANT_TWO_LITIGATION_FRIEND = "Claimant 2 Litigation Friend"; + public static final String RESPONDENT_ONE = "Defendant 1"; + public static final String RESPONDENT_TWO = "Defendant 2"; + public static final String RESPONDENT_ONE_LITIGATION_FRIEND = "Defendant 1 Litigation Friend"; + public static final String RESPONDENT_TWO_LITIGATION_FRIEND = "Defendant 2 Litigation Friend"; private CaseFlagUtils() { //NO-OP @@ -209,6 +215,10 @@ public static void createOrUpdateFlags(CaseData.CaseDataBuilder builder, C updateOrgIndividualsFlags(builder, caseData, partyChosen); // attending for legal rep updateLRIndividualsFlags(builder, caseData, partyChosen, organisationService); + // experts + updateExpertFlags(builder, caseData, partyChosen); + // witnesses + updateWitnessFlags(builder, caseData, partyChosen); } private static void updateLRIndividualsFlags(CaseData.CaseDataBuilder builder, CaseData caseData, String partyChosen, OrganisationService organisationService) { @@ -265,6 +275,30 @@ private static void updateLitigationFriendFlags(CaseData.CaseDataBuilder b } } + private static void updateExpertFlags(CaseData.CaseDataBuilder builder, CaseData caseData, String partyChosen) { + if ((CLAIMANT_ONE_EXPERTS_ID).equals(partyChosen)) { + builder.applicantExperts(updatePartyNameForPartyFlagStructures(caseData.getApplicantExperts(), APPLICANT_SOLICITOR_EXPERT)); + } + if ((DEFENDANT_ONE_EXPERTS_ID).equals(partyChosen)) { + builder.respondent1Experts(updatePartyNameForPartyFlagStructures(caseData.getRespondent1Experts(), RESPONDENT_SOLICITOR_ONE_EXPERT)); + } + if ((DEFENDANT_TWO_EXPERTS_ID).equals(partyChosen)) { + builder.respondent2Experts(updatePartyNameForPartyFlagStructures(caseData.getRespondent2Experts(), RESPONDENT_SOLICITOR_TWO_EXPERT)); + } + } + + private static void updateWitnessFlags(CaseData.CaseDataBuilder builder, CaseData caseData, String partyChosen) { + if ((CLAIMANT_ONE_WITNESSES_ID).equals(partyChosen)) { + builder.applicantWitnesses(updatePartyNameForPartyFlagStructures(caseData.getApplicantWitnesses(), APPLICANT_SOLICITOR_WITNESS)); + } + if ((DEFENDANT_ONE_WITNESSES_ID).equals(partyChosen)) { + builder.respondent1Witnesses(updatePartyNameForPartyFlagStructures(caseData.getRespondent1Witnesses(), RESPONDENT_SOLICITOR_ONE_WITNESS)); + } + if ((DEFENDANT_TWO_WITNESSES_ID).equals(partyChosen)) { + builder.respondent2Witnesses(updatePartyNameForPartyFlagStructures(caseData.getRespondent2Witnesses(), RESPONDENT_SOLICITOR_TWO_WITNESS)); + } + } + private static void updatePartyFlags(CaseData.CaseDataBuilder builder, CaseData caseData, String partyChosen) { if ((CLAIMANT_ONE_ID).equals(partyChosen)) { builder.applicant1(updatePartyNameForFlags(caseData.getApplicant1())); diff --git a/src/main/java/uk/gov/hmcts/reform/civil/utils/CaseNameUtils.java b/src/main/java/uk/gov/hmcts/reform/civil/utils/CaseNameUtils.java index 2e06b1e26b4..0fbd650094f 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/utils/CaseNameUtils.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/utils/CaseNameUtils.java @@ -1,9 +1,12 @@ package uk.gov.hmcts.reform.civil.utils; +import uk.gov.hmcts.reform.civil.enums.MultiPartyScenario; import uk.gov.hmcts.reform.civil.model.CaseData; import uk.gov.hmcts.reform.civil.model.LitigationFriend; import uk.gov.hmcts.reform.civil.model.Party; +import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.getMultiPartyScenario; + public class CaseNameUtils { private CaseNameUtils() { @@ -38,4 +41,27 @@ public static String getFormattedLitigationFriendName(LitigationFriend litigatio litigationFriend.getLastName() ) : ""; } + + public static String buildCaseNameInternal(CaseData caseData) { + StringBuilder participantString = new StringBuilder(); + MultiPartyScenario multiPartyScenario = getMultiPartyScenario(caseData); + if (multiPartyScenario.equals(MultiPartyScenario.ONE_V_TWO_ONE_LEGAL_REP) + || multiPartyScenario.equals(MultiPartyScenario.ONE_V_TWO_TWO_LEGAL_REP)) { + participantString.append(caseData.getApplicant1().getPartyName()) + .append(" v ").append(caseData.getRespondent1().getPartyName()) + .append(" and ").append(caseData.getRespondent2().getPartyName()); + + } else if (multiPartyScenario.equals(MultiPartyScenario.TWO_V_ONE)) { + participantString.append(caseData.getApplicant1().getPartyName()) + .append(" and ").append(caseData.getApplicant2().getPartyName()).append(" v ") + .append(caseData.getRespondent1() + .getPartyName()); + + } else { + participantString.append(caseData.getApplicant1().getPartyName()).append(" v ") + .append(caseData.getRespondent1() + .getPartyName()); + } + return participantString.toString(); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/utils/HmcDataUtils.java b/src/main/java/uk/gov/hmcts/reform/civil/utils/HmcDataUtils.java index 20de01439ea..ab7cf85cf11 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/utils/HmcDataUtils.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/utils/HmcDataUtils.java @@ -1,5 +1,8 @@ package uk.gov.hmcts.reform.civil.utils; +import org.jetbrains.annotations.Nullable; +import uk.gov.hmcts.reform.civil.referencedata.LocationRefDataService; +import uk.gov.hmcts.reform.civil.referencedata.model.LocationRefData; import uk.gov.hmcts.reform.hmc.model.hearing.HearingDaySchedule; import uk.gov.hmcts.reform.hmc.model.hearing.HearingGetResponse; import uk.gov.hmcts.reform.hmc.model.hearings.CaseHearing; @@ -204,4 +207,16 @@ public static boolean includesVideoHearing(HearingsResponse hearings) { && hearings.getCaseHearings().stream() .filter(hearing -> includesVideoHearing(hearing)).count() > 0; } + + @Nullable + public static LocationRefData getLocationRefData(String hearingId, String venueId, + String bearerToken, LocationRefDataService locationRefDataService) { + List locations = locationRefDataService.getCourtLocationsForDefaultJudgments(bearerToken); + var matchedLocations = locations.stream().filter(loc -> loc.getEpimmsId().equals(venueId)).toList(); + if (matchedLocations.size() > 0) { + return matchedLocations.get(0); + } else { + throw new IllegalArgumentException("Hearing location data not available for hearing " + hearingId); + } + } } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/utils/ManageContactInformationUtils.java b/src/main/java/uk/gov/hmcts/reform/civil/utils/ManageContactInformationUtils.java index 83ff6136dd6..66b6ddde40e 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/utils/ManageContactInformationUtils.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/utils/ManageContactInformationUtils.java @@ -2,6 +2,7 @@ import uk.gov.hmcts.reform.civil.model.CaseData; import uk.gov.hmcts.reform.civil.model.Party; +import uk.gov.hmcts.reform.civil.model.PartyFlagStructure; import uk.gov.hmcts.reform.civil.model.UpdatePartyDetailsForm; import uk.gov.hmcts.reform.civil.model.common.DynamicListElement; import uk.gov.hmcts.reform.civil.model.common.Element; @@ -18,6 +19,7 @@ import static uk.gov.hmcts.reform.civil.model.common.DynamicListElement.dynamicElementFromCode; import static uk.gov.hmcts.reform.civil.utils.ElementUtils.unwrapElements; import static uk.gov.hmcts.reform.civil.utils.ElementUtils.wrapElements; +import static uk.gov.hmcts.reform.civil.utils.PartyUtils.createPartyId; public class ManageContactInformationUtils { @@ -180,18 +182,8 @@ public static List> mapUpdatePartyDetailsFormToDQExperts(List> mapUpdatePartyDetailsFormToDQWitnesses(List .phoneNumber(formWitness.getPhoneNumber()) .dateAdded(LocalDate.now()) .eventAdded("Manage Contact Information Event") - .partyID(null) //CIV-10382 + .partyID(createPartyId()) .build())); - // Replace above to this in CIV-10382 - // newWitnesses.addAll(wrapElements(appendWithNewPartyIds(Witness.builder() - // .firstName(formWitness.getFirstName()) - // .lastName(formWitness.getLastName()) - // .emailAddress(formWitness.getEmailAddress()) - // .phoneNumber(formWitness.getPhoneNumber()) - // .dateAdded(LocalDate.now()) - // .eventAdded("Manage Contact Information Event") - // .build()))); } } } @@ -265,6 +248,52 @@ public static List> mapUpdatePartyDetailsFormToDQWitnesses(List return newWitnesses; } + public static List> updatePartyDQWitnesses(List existingParties, List witnesses) { + List updatedPartyWitnesses = new ArrayList<>(); + if (witnesses == null || witnesses.isEmpty()) { + return null; + } + for (Witness witness : witnesses) { + updatedPartyWitnesses.add(updateTopLevelPartyInfo(witness.getPartyID(), + witness.getFirstName(), witness.getLastName(), + witness.getPhoneNumber(), witness.getEmailAddress(), + existingParties)); + } + return wrapElements(updatedPartyWitnesses); + } + + public static List> updatePartyDQExperts(List existingParties, List experts) { + List updatedPartyExperts = new ArrayList<>(); + if (experts == null || experts.isEmpty()) { + return null; + } + for (Expert expert : experts) { + updatedPartyExperts.add(updateTopLevelPartyInfo(expert.getPartyID(), + expert.getFirstName(), expert.getLastName(), + expert.getPhoneNumber(), expert.getEmailAddress(), + existingParties)); + } + return wrapElements(updatedPartyExperts); + } + + private static PartyFlagStructure updateTopLevelPartyInfo(String partyId, String firstName, String lastName, String phoneNumber, String email, + List existingParties) { + return existingParties.stream().filter(p -> p.getPartyID().equals(partyId)).findFirst() + .map(p -> (p.toBuilder() + .firstName(firstName) + .lastName(lastName) + .phone(phoneNumber) + .email(email) + .build())) + .orElse(PartyFlagStructure.builder() + .partyID(partyId) + .firstName(firstName) + .lastName(lastName) + .phone(phoneNumber) + .email(email) + .build()); + } + private static String formatId(String partyChosen, String isAdmin, Party party) { return String.format("%s_%s_%s", partyChosen, isAdmin, party.getType().toString()); } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/utils/PartyUtils.java b/src/main/java/uk/gov/hmcts/reform/civil/utils/PartyUtils.java index 2da2a2861dd..ccc6919e09c 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/utils/PartyUtils.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/utils/PartyUtils.java @@ -351,7 +351,7 @@ public static String getAllPartyNames(CaseData caseData) { ? ", " + caseData.getRespondent2().getPartyName() : ""); } - private static String createPartyId() { + public static String createPartyId() { return UUID.randomUUID().toString().substring(0, 16); } diff --git a/src/main/resources/airline_ePimsID_csv/airline_ePimsID.csv b/src/main/resources/airline_ePimsID_csv/airline_ePimsID.csv new file mode 100644 index 00000000000..49d7c177ec2 --- /dev/null +++ b/src/main/resources/airline_ePimsID_csv/airline_ePimsID.csv @@ -0,0 +1,100 @@ +Aegean,298828 +Aer Lingus,621184 +Aeroflot,298828 +Aeromexico,621184 +Air Algerie,268374 +Air Baltic,317442 +Air Canada,298828 +Air China,36791 +Air Europa,20262 +Air France,298828 +Air India,36791 +Air Malta,298828 +Air Moldova,365554 +Air New Zealand,268374 +Air Portugal,701411 +Air Transat,20262 +All Nippon Airways,268374 +American Airlines,621184 +Aurigny,317442 +Austrian Airways,621184 +Avianca,365554 +Azerbaijan Airlines,268374 +BA/Cityflyer,621184 +Biman Bangladesh,345663 +Blue Air,345663 +Brussels,621184 +Bulgaria Air,298828 +Cathay Pacific,268374 +China Airlines,20262 +China Eastern,20262 +China Southern,621184 +Condor,701411 +Croatia Airlines,298828 +Delta,268374 +Eastern,317442 +Easyjet,365554 +Egyptair,268374 +El Al,20262 +Emirates,701411 +Etihad,345663 +Eurowings,621184 +Eva Air,20262 +Finnair,345663 +Garuda,621184 +Gulf Air,36791 +Iberia/Express,621184 +Icelandair,20262 +Iran Air,268374 +ITA,298828 +Japan Airlines,20262 +Jet2.com,701411 +JetBlue,317442 +Kenya Airways,298828 +KLM,298828 +Korean,20262 +Kuwait Airways,621184 +LATAM/JJ,298828 +Loganair,701411 +LOT,20262 +Lufthansa,621184 +Luxair,20262 +Malaysian,268374 +Middle East,20262 +Norse,317442 +Norweigan,317442 +Oman,701411 +Pakistan,36791 +Pegasus,365554 +Phillipine Airlines,317442 +Play,345663 +Qatar,345663 +Quantas,268374 +Royal Air Maroc,20262 +Royal Brunei,268374 +Royal Jordanian,36791 +Ryanair,345663 +SAS,298828 +SAS,621184 +Saudi Arabian Airlines,20262 +Saudia,20262 +Singapore Airlines,36791 +Sky Express,298828 +Smartwings,365554 +South African Airways,268374 +Sri Lankan,36791 +Swiss International,621184 +Thai Airways,20262 +TUI / Thomson ,365554 +Tunisair,268374 +Turkish,36791 +Ukraine International,36791 +United,621184 +Vietnam Airlines,20262 +Virgin,317442 +Vistara,268374 +Vueling,345663 +WestJet,317442 +Wideroe,298828 +WizzAir,345663 +OTHER, diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 187c0e2b2f9..15754b2d272 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -129,6 +129,7 @@ idam: s2s-auth: microservice: civil_service + document_management: userRoles: "caseworker-civil,caseworker-civil-solicitor" secured: ${DOCUMENT_MANAGEMENT_SECURED:true} @@ -158,6 +159,7 @@ civil: test-user: username: ${TEST_USERNAME:test@example.com} password: ${TEST_PASSWORD:Password12!} + authorised-services: ${CIVIL_S2S_AUTHORISED_SERVICES:payment_app,ccd_data,civil_service,civil-citizen-ui} core_case_data: api: @@ -310,6 +312,7 @@ notifications: hearingNotificationLipDefendantTemplate: "9239a55e-fd08-4f03-9ba5-7d90ac35af41" notifyLiPClaimantClaimSubmittedAndPayClaimFeeTemplate: "3d302844-ecdc-47e6-8aed-971c3f42a059" + notifyLiPClaimantClaimSubmittedAndHelpWithFeeTemplate: "a9c1ccba-eb72-414d-8dc7-d75f33c79b28" notifyLiPClaimantDefendantResponded: "4b1325dd-51ed-4dc2-bcc6-d9afb01a3f29" notifyLiPClaimantDefendantChangedContactDetails: "72a14146-c897-4fc6-be4f-474266da7398" @@ -319,6 +322,9 @@ notifications: notifyLiPApplicantBreathingSpaceLifted: "b6dbc714-210e-475d-a1db-bf5ea28de98b" notifyLiPRespondentBreathingSpaceLifted: "4ca3017b-b2fa-4ac0-a867-9bfada50a80c" + notifyApplicantLipRequestJudgementByAdmissionNotificationTemplate: "d6625ee3-f794-4a87-b0a3-bef7dd0663b9" + notifyRespondentLipRequestJudgementByAdmissionNotificationTemplate: "6ced7f9c-b0fd-4fad-a76c-745873b9a3a2" + sendgrid: api-key: ${SENDGRID_API_KEY:false} diff --git a/src/main/resources/caseIdForRetrigger.txt b/src/main/resources/caseIdForRetrigger.txt new file mode 100644 index 00000000000..75a619adbf3 --- /dev/null +++ b/src/main/resources/caseIdForRetrigger.txt @@ -0,0 +1 @@ +1694435036274857 diff --git a/src/test/java/uk/gov/hmcts/reform/civil/enums/UnrepresentedOrUnregisteredScenarioTest.java b/src/test/java/uk/gov/hmcts/reform/civil/enums/UnrepresentedOrUnregisteredScenarioTest.java index d15008b02c4..8f4fd7698e1 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/enums/UnrepresentedOrUnregisteredScenarioTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/enums/UnrepresentedOrUnregisteredScenarioTest.java @@ -9,7 +9,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static uk.gov.hmcts.reform.civil.enums.UnrepresentedOrUnregisteredScenario.UNREGISTERED; -import static uk.gov.hmcts.reform.civil.enums.UnrepresentedOrUnregisteredScenario.UNREGISTERED_NOTICE_OF_CHANGE; import static uk.gov.hmcts.reform.civil.enums.UnrepresentedOrUnregisteredScenario.UNREPRESENTED; import static uk.gov.hmcts.reform.civil.enums.UnrepresentedOrUnregisteredScenario.getDefendantNames; @@ -84,7 +83,7 @@ void shouldReturnUnregisteredDefendantNames_WhenBothDefendantsUnregisteredScenar // To be changed to UNREGISTERED when NOC is merged // assertThat(getDefendantNames(UNREGISTERED, caseData)).isEqualTo( - assertThat(getDefendantNames(UNREGISTERED_NOTICE_OF_CHANGE, caseData)).isEqualTo( + assertThat(getDefendantNames(UNREGISTERED, caseData)).isEqualTo( List.of( caseData.getRespondent1().getPartyName(), caseData.getRespondent2().getPartyName() @@ -98,7 +97,7 @@ void shouldReturnUnregisteredDefendantNames_WhenUnregisteredDefendant1Scenario() // To be changed to UNREGISTERED when NOC is merged // assertThat(getDefendantNames(UNREGISTERED, caseData)).isEqualTo( - assertThat(getDefendantNames(UNREGISTERED_NOTICE_OF_CHANGE, caseData)).isEqualTo( + assertThat(getDefendantNames(UNREGISTERED, caseData)).isEqualTo( List.of( caseData.getRespondent1().getPartyName() ) @@ -111,7 +110,7 @@ void shouldReturnUnregisteredDefendantNames_WhenUnregisteredDefendant2Scenario() // To be changed to UNREGISTERED when NOC is merged // assertThat(getDefendantNames(UNREGISTERED, caseData)).isEqualTo( - assertThat(getDefendantNames(UNREGISTERED_NOTICE_OF_CHANGE, caseData)).isEqualTo( + assertThat(getDefendantNames(UNREGISTERED, caseData)).isEqualTo( List.of( caseData.getRespondent2().getPartyName() ) @@ -125,7 +124,7 @@ void shouldReturnUnregisteredDefendantNames_WhenUnrepresentedDefendant1Unregiste // To be changed to UNREGISTERED when NOC is merged // assertThat(getDefendantNames(UNREGISTERED, caseData)).isEqualTo( - assertThat(getDefendantNames(UNREGISTERED_NOTICE_OF_CHANGE, caseData)).isEqualTo( + assertThat(getDefendantNames(UNREGISTERED, caseData)).isEqualTo( List.of( caseData.getRespondent2().getPartyName() ) @@ -139,85 +138,6 @@ void shouldReturnUnregisteredDefendantNames_WhenUnregisteredDefendant1Unrepresen // To be changed to UNREGISTERED when NOC is merged // assertThat(getDefendantNames(UNREGISTERED, caseData)).isEqualTo( - assertThat(getDefendantNames(UNREGISTERED_NOTICE_OF_CHANGE, caseData)).isEqualTo( - List.of( - caseData.getRespondent1().getPartyName() - ) - ); - } - } - - @Nested - class ToBeRemovedAfterNocUnregistered { - @Test - void shouldReturnUnregisteredDefendantNames_WhenBothDefendantsUnregisteredScenario() { - CaseData caseData = CaseDataBuilder.builder() - .atStateProceedsOfflineUnregisteredDefendants() - .respondent1OrganisationPolicy(null) - .respondent2OrganisationPolicy(null) - .build(); - - assertThat(getDefendantNames(UNREGISTERED, caseData)).isEqualTo( - List.of( - caseData.getRespondent1().getPartyName(), - caseData.getRespondent2().getPartyName() - ) - ); - } - - @Test - void shouldReturnUnregisteredDefendantNames_WhenUnregisteredDefendant1Scenario() { - CaseData caseData = CaseDataBuilder.builder() - .atStateProceedsOfflineUnregisteredDefendant1() - .respondent1OrganisationPolicy(null) - .respondent2OrganisationPolicy(null) - .build(); - - assertThat(getDefendantNames(UNREGISTERED, caseData)).isEqualTo( - List.of( - caseData.getRespondent1().getPartyName() - ) - ); - } - - @Test - void shouldReturnUnregisteredDefendantNames_WhenUnregisteredDefendant2Scenario() { - CaseData caseData = CaseDataBuilder.builder() - .atStateProceedsOfflineUnregisteredDefendant2() - .respondent1OrganisationPolicy(null) - .respondent2OrganisationPolicy(null) - .build(); - - assertThat(getDefendantNames(UNREGISTERED, caseData)).isEqualTo( - List.of( - caseData.getRespondent2().getPartyName() - ) - ); - } - - @Test - void shouldReturnUnregisteredDefendantNames_WhenUnrepresentedDefendant1UnregisteredDefendant2Scenario() { - CaseData caseData = CaseDataBuilder.builder() - .atStateProceedsOfflineUnrepresentedDefendant1UnregisteredDefendant2() - .respondent1OrganisationPolicy(null) - .respondent2OrganisationPolicy(null) - .build(); - - assertThat(getDefendantNames(UNREGISTERED, caseData)).isEqualTo( - List.of( - caseData.getRespondent2().getPartyName() - ) - ); - } - - @Test - void shouldReturnUnregisteredDefendantNames_WhenUnregisteredDefendant1UnrepresentedDefendant2Scenario() { - CaseData caseData = CaseDataBuilder.builder() - .atStateProceedsOfflineUnregisteredDefendant1UnrepresentedDefendant2() - .respondent1OrganisationPolicy(null) - .respondent2OrganisationPolicy(null) - .build(); - assertThat(getDefendantNames(UNREGISTERED, caseData)).isEqualTo( List.of( caseData.getRespondent1().getPartyName() @@ -225,5 +145,4 @@ void shouldReturnUnregisteredDefendantNames_WhenUnregisteredDefendant1Unrepresen ); } } - } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/RetriggerCasesEventHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/RetriggerCasesEventHandlerTest.java new file mode 100644 index 00000000000..ac0c133583e --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/RetriggerCasesEventHandlerTest.java @@ -0,0 +1,86 @@ +package uk.gov.hmcts.reform.civil.handler; + +import feign.FeignException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import uk.gov.hmcts.reform.civil.callback.CaseEvent; +import uk.gov.hmcts.reform.civil.service.CoreCaseDataService; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +class RetriggerCasesEventHandlerTest { + + @Mock + private CoreCaseDataService coreCaseDataService; + + @InjectMocks + private RetriggerCasesEventHandler retriggerCasesEventHandler; + + @BeforeEach + void setUp() { + MockitoAnnotations.openMocks(this); + } + + @Test + void testUpdateCaseByEvent() { + List caseIdList = Arrays.asList("1", "2", "3"); + + retriggerCasesEventHandler.updateCaseByEvent(caseIdList, CaseEvent.RETRIGGER_CASES); + + // Assertions + verify(coreCaseDataService, times(caseIdList.size())).triggerEvent(anyLong(), eq(CaseEvent.RETRIGGER_CASES)); + } + + @Test + void testUpdateCaseByEventWithFeignException() { + List caseIdList = Arrays.asList("1", "2", "3"); + + // Simulate FeignException + doThrow(FeignException.class).when(coreCaseDataService).triggerEvent(anyLong(), eq(CaseEvent.RETRIGGER_CASES)); + + // Assertions + FeignException exception = assertThrows(FeignException.class, () -> + retriggerCasesEventHandler.updateCaseByEvent(caseIdList, CaseEvent.RETRIGGER_CASES) + ); + } + + @Test + void testUpdateCaseByEventWithGenericException() { + List caseIdList = Arrays.asList("1", "2", "3"); + + doThrow(new RuntimeException("Simulated RuntimeException")).when(coreCaseDataService) + .triggerEvent(anyLong(), eq(CaseEvent.RETRIGGER_CASES)); + + RuntimeException exception = assertThrows(RuntimeException.class, () -> + retriggerCasesEventHandler.updateCaseByEvent(caseIdList, CaseEvent.RETRIGGER_CASES) + ); + + assertEquals("Simulated RuntimeException", exception.getMessage()); + } + + @Test + void testUpdateCaseByEventWithEmptyList() { + List emptyCaseIdList = Collections.emptyList(); + + retriggerCasesEventHandler.updateCaseByEvent(emptyCaseIdList, CaseEvent.RETRIGGER_CASES); + + // Assertions + verify(coreCaseDataService, never()).triggerEvent(anyLong(), eq(CaseEvent.RETRIGGER_CASES)); + } +} + + diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/caseevents/TriggerGenAppLocationUpdateCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/caseevents/TriggerGenAppLocationUpdateCallbackHandlerTest.java index 53cd99df257..b2a913e47bc 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/caseevents/TriggerGenAppLocationUpdateCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/caseevents/TriggerGenAppLocationUpdateCallbackHandlerTest.java @@ -8,9 +8,11 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; +import uk.gov.hmcts.reform.ccd.client.model.CallbackRequest; import uk.gov.hmcts.reform.civil.callback.CallbackParams; import uk.gov.hmcts.reform.civil.handler.callback.BaseCallbackHandlerTest; import uk.gov.hmcts.reform.civil.model.CaseData; +import uk.gov.hmcts.reform.civil.sampledata.CallbackParamsBuilder; import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; import uk.gov.hmcts.reform.civil.sampledata.GeneralApplicationDetailsBuilder; import uk.gov.hmcts.reform.civil.service.GenAppStateHelperService; @@ -28,8 +30,10 @@ import static org.mockito.Mockito.when; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; -import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIGGER_LOCATION_UPDATE; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIGGER_UPDATE_GA_LOCATION; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIGGER_TASK_RECONFIG_GA; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIGGER_LOCATION_UPDATE; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIGGER_TASK_RECONFIG; @ExtendWith(SpringExtension.class) @SpringBootTest(classes = { @@ -51,6 +55,7 @@ class TriggerGenAppLocationUpdateCallbackHandlerTest extends BaseCallbackHandler @Test void handleEventsReturnsTheExpectedCallbackEvent() { assertThat(handler.handledEvents()).contains(TRIGGER_UPDATE_GA_LOCATION); + assertThat(handler.handledEvents()).contains(TRIGGER_TASK_RECONFIG_GA); } @Test @@ -63,7 +68,12 @@ void shouldTriggerGeneralApplicationEvent_whenCaseHasGeneralApplication() { getOriginalStatusOfGeneralApplication() ); when(helperService.updateApplicationLocationDetailsInClaim(any(), any())).thenReturn(caseData); - CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + CallbackParams params = CallbackParamsBuilder.builder() + .of(ABOUT_TO_SUBMIT, caseData) + .request(CallbackRequest.builder() + .eventId(TRIGGER_UPDATE_GA_LOCATION.name()) + .build()) + .build(); var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); assertThat(response.getErrors()).isNull(); @@ -106,6 +116,27 @@ void triggerGeneralApplicationEventThrowsException_HandleFailure() { assertThat(response.getErrors()).contains(expectedErrorMessage); } + @Test + void shouldTriggerReconfigureWhenCallbackEventIsReconfigGA() { + CaseData caseData = GeneralApplicationDetailsBuilder.builder() + .getTestCaseDataWithDetails(CaseData.builder().build(), + true, + true, + true, true, + getOriginalStatusOfGeneralApplication() + ); + when(helperService.updateApplicationLocationDetailsInClaim(any(), any())).thenReturn(caseData); + CallbackParams callbackParams = CallbackParamsBuilder.builder() + .of(ABOUT_TO_SUBMIT, caseData) + .request(CallbackRequest.builder() + .eventId(TRIGGER_TASK_RECONFIG_GA.name()) + .build()) + .build(); + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(callbackParams); + assertThat(response.getErrors()).isNull(); + verify(helperService, times(1)).triggerEvent(caseData, TRIGGER_TASK_RECONFIG); + } + private Map getOriginalStatusOfGeneralApplication() { Map latestStatus = new HashMap<>(); latestStatus.put("1234", "Application Submitted - Awaiting Judicial Decision"); diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateClaimFormCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateClaimFormCallbackHandlerTest.java index 68b11d63c29..6333b075840 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateClaimFormCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateClaimFormCallbackHandlerTest.java @@ -136,7 +136,6 @@ class GenerateClaimFormCallbackHandlerTest extends BaseCallbackHandlerTest { @BeforeEach void setup() { - when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(true); when(sealedClaimFormGenerator.generate(any(CaseData.class), anyString())).thenReturn(CLAIM_FORM); when(litigantInPersonFormGenerator.generate(any(CaseData.class), anyString())).thenReturn(LIP_FORM); when(civilDocumentStitchingService.bundle(ArgumentMatchers.anyList(), anyString(), anyString(), anyString(), @@ -329,39 +328,4 @@ void testSingleSealedClaimGeneratedWhenStitchingDisabled() { } } - - @Nested - @ExtendWith(SpringExtension.class) - @SpringBootTest(classes = { - GenerateClaimFormCallbackHandler.class, - JacksonAutoConfiguration.class, - CaseDetailsConverter.class, - AssignCategoryId.class - }) - class GenerateSealedClaimNoNoC { - - @Autowired - private GenerateClaimFormCallbackHandler handler; - @Autowired - private AssignCategoryId assignCategoryId; - - @BeforeEach - void setup() { - when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(false); - when(sealedClaimFormGenerator.generate(any(CaseData.class), anyString())).thenReturn(CLAIM_FORM); - when(time.now()).thenReturn(issueDate.atStartOfDay()); - } - - @Test - void testSingleSealedClaimGeneratedWhenNoCDisabled() { - CaseData caseData = CaseDataBuilder.builder().atStatePendingClaimIssuedUnrepresentedDefendant().build(); - CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); - - var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); - CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); - - assertThat(updatedData.getSystemGeneratedCaseDocuments().get(0).getValue()).isEqualTo(CLAIM_FORM); - verify(sealedClaimFormGenerator).generate(any(CaseData.class), eq(BEARER_TOKEN)); - } - } } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateClaimFormForSpecHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateClaimFormForSpecHandlerTest.java index 36217026471..4946909fab0 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateClaimFormForSpecHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateClaimFormForSpecHandlerTest.java @@ -229,23 +229,6 @@ void shouldGenerateClaimFormWithClaimTimeLineDocs_whenUploadedByRespondent() { verify(civilDocumentStitchingService).bundle(eq(specClaimTimelineDocuments), anyString(), anyString(), anyString(), eq(caseData)); } - - @Test - void shouldNotStitchClaimFormWithLipForm_whenOneVsOne_withLitigantInPersonSpecClaim_whenToggleIsOff() { - when(toggleService.isNoticeOfChangeEnabled()).thenReturn(false); - - CaseData caseData = CaseDataBuilder.builder() - .atStatePendingClaimIssuedUnrepresentedDefendant().build().toBuilder() - .specRespondent1Represented(NO) - .build(); - CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); - - var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); - CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); - - assertThat(updatedData.getSystemGeneratedCaseDocuments().get(0).getValue()).isEqualTo(CLAIM_FORM); - } - } @Test @@ -358,11 +341,6 @@ void shouldNullDocuments_whenInvokedAndCaseFileEnabled() { @Nested class GenerateAndStitchLitigantInPersonFormSpec { - @BeforeEach - void setup() { - when(toggleService.isNoticeOfChangeEnabled()).thenReturn(true); - } - @Test void shouldStitchClaimFormWithLipForm_whenOneVsOne_withLitigantInPersonSpecClaim() { CaseData caseData = CaseDataBuilder.builder() diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateHearingNoticeHmcHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateHearingNoticeHmcHandlerTest.java index d67db158add..17b08b9e12b 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateHearingNoticeHmcHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/docmosis/GenerateHearingNoticeHmcHandlerTest.java @@ -16,6 +16,8 @@ import uk.gov.hmcts.reform.civil.helpers.CaseDetailsConverter; import uk.gov.hmcts.reform.civil.model.BusinessProcess; import uk.gov.hmcts.reform.civil.model.CaseData; +import uk.gov.hmcts.reform.civil.referencedata.LocationRefDataService; +import uk.gov.hmcts.reform.civil.referencedata.model.LocationRefData; import uk.gov.hmcts.reform.civil.sampledata.CaseDocumentBuilder; import uk.gov.hmcts.reform.civil.service.docmosis.hearing.HearingNoticeHmcGenerator; import uk.gov.hmcts.reform.civil.service.hearingnotice.HearingNoticeCamundaService; @@ -62,6 +64,8 @@ public class GenerateHearingNoticeHmcHandlerTest extends BaseCallbackHandlerTest private HearingNoticeCamundaService camundaService; @MockBean private HearingNoticeHmcGenerator hearingNoticeHmcGenerator; + @MockBean + private LocationRefDataService locationRefDataService; private static Long CASE_ID = 1L; private static String HEARING_ID = "1234"; @@ -108,9 +112,13 @@ public void shouldPopulateCamundaProcessVariables_andReturnExpectedCaseData() { .caseId(CASE_ID) .build(); + List locations = List.of(LocationRefData.builder() + .epimmsId(EPIMS).build()); + when(locationRefDataService.getCourtLocationsForDefaultJudgments(anyString())) + .thenReturn(locations); when(camundaService.getProcessVariables(PROCESS_INSTANCE_ID)).thenReturn(inputVariables); when(hearingsService.getHearingResponse(anyString(), anyString())).thenReturn(hearing); - when(hearingNoticeHmcGenerator.generate(eq(caseData), eq(hearing), anyString())).thenReturn(List.of(CASE_DOCUMENT)); + when(hearingNoticeHmcGenerator.generate(eq(caseData), eq(hearing), anyString(), anyString(), anyString())).thenReturn(List.of(CASE_DOCUMENT)); CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); params.getRequest().setEventId(GENERATE_HEARING_NOTICE_HMC.name()); @@ -168,9 +176,13 @@ public void shouldPopulateCamundaProcessVariables_andReturnExpectedCaseData_BstH .caseId(CASE_ID) .build(); + List locations = List.of(LocationRefData.builder() + .epimmsId(EPIMS).build()); + when(locationRefDataService.getCourtLocationsForDefaultJudgments(anyString())) + .thenReturn(locations); when(camundaService.getProcessVariables(PROCESS_INSTANCE_ID)).thenReturn(inputVariables); when(hearingsService.getHearingResponse(anyString(), anyString())).thenReturn(hearing); - when(hearingNoticeHmcGenerator.generate(eq(caseData), eq(hearing), anyString())).thenReturn(List.of(CASE_DOCUMENT)); + when(hearingNoticeHmcGenerator.generate(eq(caseData), eq(hearing), anyString(), anyString(), anyString())).thenReturn(List.of(CASE_DOCUMENT)); CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); params.getRequest().setEventId(GENERATE_HEARING_NOTICE_HMC.name()); diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimContinuingOnlineApplicantNotificationHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimContinuingOnlineApplicantNotificationHandlerTest.java index 1e92ae2974d..32c12ff81cb 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimContinuingOnlineApplicantNotificationHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimContinuingOnlineApplicantNotificationHandlerTest.java @@ -52,25 +52,9 @@ class AboutToSubmitCallback { @BeforeEach void setup() { - when(notificationsProperties.getClaimantSolicitorClaimContinuingOnline()).thenReturn("template-id"); when(notificationsProperties.getClaimantSolicitorClaimContinuingOnlineCos()).thenReturn("template-id-cos"); } - @Test - void shouldNotifyApplicantSolicitor_whenInvoked() { - CaseData caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified().build(); - CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).build(); - - handler.handle(params); - - verify(notificationService).sendMail( - "applicantsolicitor@example.com", - "template-id", - getNotificationDataMap(caseData), - "claim-continuing-online-notification-000DC001" - ); - } - @NotNull private Map getNotificationDataMap(CaseData caseData) { return Map.of( @@ -82,11 +66,10 @@ PARTY_REFERENCES, buildClaimantReference(caseData) } @Test - void shouldNotifyApplicantSolicitor_whenCosEnabled() { + void shouldNotifyApplicantSolicitor_whenInvoked() { CaseData caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified().build(); CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).build(); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); handler.handle(params); verify(notificationService).sendMail( @@ -96,22 +79,5 @@ void shouldNotifyApplicantSolicitor_whenCosEnabled() { "claim-continuing-online-notification-000DC001" ); } - - @Test - void shouldNotifyApplicantSolicitorWithOldTemplate_whenCosDisabled() { - CaseData caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified().build(); - CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).build(); - - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(false); - handler.handle(params); - - verify(notificationService).sendMail( - "applicantsolicitor@example.com", - "template-id", - getNotificationDataMap(caseData), - "claim-continuing-online-notification-000DC001" - ); - } - } } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimantLipRequestJudgementByAdmissionApplicantNotificationHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimantLipRequestJudgementByAdmissionApplicantNotificationHandlerTest.java new file mode 100644 index 00000000000..227cfcb1707 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimantLipRequestJudgementByAdmissionApplicantNotificationHandlerTest.java @@ -0,0 +1,96 @@ +package uk.gov.hmcts.reform.civil.handler.callback.camunda.notification; + +import org.jetbrains.annotations.NotNull; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import uk.gov.hmcts.reform.ccd.client.model.CallbackRequest; +import uk.gov.hmcts.reform.civil.callback.CallbackParams; +import uk.gov.hmcts.reform.civil.config.PinInPostConfiguration; +import uk.gov.hmcts.reform.civil.handler.callback.BaseCallbackHandlerTest; +import uk.gov.hmcts.reform.civil.model.CaseData; +import uk.gov.hmcts.reform.civil.notify.NotificationService; +import uk.gov.hmcts.reform.civil.notify.NotificationsProperties; +import uk.gov.hmcts.reform.civil.sampledata.CallbackParamsBuilder; +import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; + +import java.util.Map; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; +import static uk.gov.hmcts.reform.civil.enums.YesOrNo.NO; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.notification.ClaimantLipRequestJudgementByAdmissionApplicantNotificationHandler.TASK_ID; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.notification.NotificationData.CLAIMANT_NAME; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.notification.NotificationData.CLAIM_REFERENCE_NUMBER; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.notification.NotificationData.FRONTEND_URL; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.notification.NotificationData.RESPONDENT_NAME; +import static uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder.LEGACY_CASE_REFERENCE; + +@SpringBootTest(classes = { + ClaimantLipRequestJudgementByAdmissionApplicantNotificationHandler.class, + JacksonAutoConfiguration.class +}) + +class ClaimantLipRequestJudgementByAdmissionApplicantNotificationHandlerTest extends BaseCallbackHandlerTest { + + @MockBean + private NotificationService notificationService; + @MockBean + private NotificationsProperties notificationsProperties; + @MockBean + private PinInPostConfiguration pinInPostConfiguration; + @Autowired + private ClaimantLipRequestJudgementByAdmissionApplicantNotificationHandler handler; + + @Nested + class AboutToSubmitCallback { + + @BeforeEach + void setup() { + when(notificationsProperties.getNotifyApplicantLipRequestJudgementByAdmissionNotificationTemplate()).thenReturn("template-id"); + when(pinInPostConfiguration.getRespondToClaimUrl()).thenReturn("dummy_respond_to_claim_url"); + when(pinInPostConfiguration.getCuiFrontEndUrl()).thenReturn("dummy_cui_front_end_url"); + } + + @Test + void shouldNotifyLipApplicant_whenInvoked() { + CaseData caseData = CaseDataBuilder.builder().atStateClaimIssued1v1LiP() + .applicant1Represented(NO) + .build(); + CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).request( + CallbackRequest.builder().eventId("NOTIFY_APPLICANT1_FOR_REQUEST_JUDGEMENT_BY_ADMISSION_LIP_CLAIMANT") + .build()).build(); + + handler.handle(params); + + verify(notificationService).sendMail( + "rambo@email.com", + "template-id", + getNotificationDataMap(caseData), + "request-judgement-by-admission-applicant-notification-000DC001" + ); + } + + @Test + void shouldReturnCorrectCamundaActivityId_whenInvoked() { + assertThat(handler.camundaActivityId(CallbackParamsBuilder.builder().request(CallbackRequest.builder().eventId( + "NOTIFY_APPLICANT1_FOR_REQUEST_JUDGEMENT_BY_ADMISSION_LIP_CLAIMANT").build()).build())).isEqualTo(TASK_ID); + } + + @NotNull + private Map getNotificationDataMap(CaseData caseData) { + return Map.of( + RESPONDENT_NAME, "Mr. Sole Trader", + CLAIMANT_NAME, "Mr. John Rambo", + CLAIM_REFERENCE_NUMBER, LEGACY_CASE_REFERENCE, + FRONTEND_URL, "dummy_cui_front_end_url" + ); + } + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimantLipRequestJudgementByAdmissionRespondentNotificationHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimantLipRequestJudgementByAdmissionRespondentNotificationHandlerTest.java new file mode 100644 index 00000000000..9cc9ff4aad7 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/ClaimantLipRequestJudgementByAdmissionRespondentNotificationHandlerTest.java @@ -0,0 +1,96 @@ +package uk.gov.hmcts.reform.civil.handler.callback.camunda.notification; + +import org.jetbrains.annotations.NotNull; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import uk.gov.hmcts.reform.ccd.client.model.CallbackRequest; +import uk.gov.hmcts.reform.civil.callback.CallbackParams; +import uk.gov.hmcts.reform.civil.config.PinInPostConfiguration; +import uk.gov.hmcts.reform.civil.handler.callback.BaseCallbackHandlerTest; +import uk.gov.hmcts.reform.civil.model.CaseData; +import uk.gov.hmcts.reform.civil.notify.NotificationService; +import uk.gov.hmcts.reform.civil.notify.NotificationsProperties; +import uk.gov.hmcts.reform.civil.sampledata.CallbackParamsBuilder; +import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; + +import java.util.Map; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; +import static uk.gov.hmcts.reform.civil.enums.YesOrNo.NO; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.notification.ClaimantLipRequestJudgementByAdmissionRespondentNotificationHandler.TASK_ID; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.notification.NotificationData.CLAIMANT_NAME; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.notification.NotificationData.CLAIM_REFERENCE_NUMBER; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.notification.NotificationData.FRONTEND_URL; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.notification.NotificationData.RESPONDENT_NAME; +import static uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder.LEGACY_CASE_REFERENCE; + +@SpringBootTest(classes = { + ClaimantLipRequestJudgementByAdmissionRespondentNotificationHandler.class, + JacksonAutoConfiguration.class +}) + +class ClaimantLipRequestJudgementByAdmissionRespondentNotificationHandlerTest extends BaseCallbackHandlerTest { + + @MockBean + private NotificationService notificationService; + @MockBean + private NotificationsProperties notificationsProperties; + @MockBean + private PinInPostConfiguration pinInPostConfiguration; + @Autowired + private ClaimantLipRequestJudgementByAdmissionRespondentNotificationHandler handler; + + @Nested + class AboutToSubmitCallback { + + @BeforeEach + void setup() { + when(notificationsProperties.getNotifyRespondentLipRequestJudgementByAdmissionNotificationTemplate()).thenReturn("template-id"); + when(pinInPostConfiguration.getRespondToClaimUrl()).thenReturn("dummy_respond_to_claim_url"); + when(pinInPostConfiguration.getCuiFrontEndUrl()).thenReturn("dummy_cui_front_end_url"); + } + + @Test + void shouldNotifyLipRespondent_whenInvoked() { + CaseData caseData = CaseDataBuilder.builder().atStateClaimIssued1v1LiP() + .applicant1Represented(NO) + .build(); + CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).request( + CallbackRequest.builder().eventId("NOTIFY_RESPONDENT1_FOR_REQUEST_JUDGEMENT_BY_ADMISSION_LIP_CLAIMANT") + .build()).build(); + + handler.handle(params); + + verify(notificationService).sendMail( + "sole.trader@email.com", + "template-id", + getNotificationDataMap(caseData), + "request-judgement-by-admission-respondent-notification-000DC001" + ); + } + + @Test + void shouldReturnCorrectCamundaActivityId_whenInvoked() { + assertThat(handler.camundaActivityId(CallbackParamsBuilder.builder().request(CallbackRequest.builder().eventId( + "NOTIFY_RESPONDENT1_FOR_REQUEST_JUDGEMENT_BY_ADMISSION_LIP_CLAIMANT").build()).build())).isEqualTo(TASK_ID); + } + + @NotNull + private Map getNotificationDataMap(CaseData caseData) { + return Map.of( + RESPONDENT_NAME, "Mr. Sole Trader", + CLAIMANT_NAME, "Mr. John Rambo", + CLAIM_REFERENCE_NUMBER, LEGACY_CASE_REFERENCE, + FRONTEND_URL, "dummy_cui_front_end_url" + ); + } + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/CreateSDOApplicantsNotificationHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/CreateSDOApplicantsNotificationHandlerTest.java index c5bb04f3f96..c67eaaf0d3f 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/CreateSDOApplicantsNotificationHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/CreateSDOApplicantsNotificationHandlerTest.java @@ -9,7 +9,12 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import uk.gov.hmcts.reform.ccd.client.model.CallbackRequest; +import uk.gov.hmcts.reform.ccd.model.OrganisationPolicy; import uk.gov.hmcts.reform.civil.callback.CallbackParams; +import uk.gov.hmcts.reform.civil.enums.CaseCategory; +import uk.gov.hmcts.reform.civil.enums.YesOrNo; +import uk.gov.hmcts.reform.civil.model.IdamUserDetails; +import uk.gov.hmcts.reform.civil.model.StatementOfTruth; import uk.gov.hmcts.reform.civil.notify.NotificationsProperties; import uk.gov.hmcts.reform.civil.handler.callback.BaseCallbackHandlerTest; import uk.gov.hmcts.reform.civil.model.CaseData; @@ -29,6 +34,7 @@ import static org.mockito.Mockito.when; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; import static uk.gov.hmcts.reform.civil.handler.callback.camunda.notification.CreateSDOApplicantsNotificationHandler.TASK_ID; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.notification.NotificationData.CLAIMANT_NAME; import static uk.gov.hmcts.reform.civil.handler.callback.camunda.notification.NotificationData.CLAIM_LEGAL_ORG_NAME_SPEC; import static uk.gov.hmcts.reform.civil.handler.callback.camunda.notification.NotificationData.CLAIM_REFERENCE_NUMBER; import static uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder.LEGACY_CASE_REFERENCE; @@ -57,32 +63,94 @@ class AboutToSubmitCallback { @BeforeEach void setup() { when(notificationsProperties.getSdoOrdered()).thenReturn("template-id"); + when(notificationsProperties.getSdoOrderedSpec()).thenReturn("template-id-spec"); + when(notificationsProperties.getClaimantLipClaimUpdatedTemplate()).thenReturn("template-id-lip"); when(organisationService.findOrganisationById(anyString())) .thenReturn(Optional.of(Organisation.builder().name("Signer Name").build())); } @Test void shouldNotifyApplicantSolicitor_whenInvoked() { + // Given CaseData caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified().build(); CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).build(); + // When + handler.handle(params); + // Then + verify(notificationService).sendMail( + "applicantsolicitor@example.com", + "template-id", + getNotificationDataMap(), + "create-sdo-applicants-notification-000DC001" + ); + } + @Test + void shouldNotifyApplicantLip_whenInvoked() { + // Given + CaseData caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified().build() + .toBuilder().claimantUserDetails(IdamUserDetails.builder().email("applicantLip@example.com").build()) + .applicant1Represented(YesOrNo.NO) + .build(); + CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).build(); + // When handler.handle(params); + // Then + verify(notificationService).sendMail( + "applicantLip@example.com", + "template-id-lip", + getNotificationDataMapLip(), + "create-sdo-applicants-notification-000DC001" + ); + } + @Test + void shouldNotifyApplicantSolicitorStatement_whenInvoked() { + // Given + CaseData caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified().build() + .toBuilder() + .applicant1Represented(YesOrNo.YES) + .applicant1OrganisationPolicy(OrganisationPolicy.builder().organisation( + uk.gov.hmcts.reform.ccd.model.Organisation.builder().organisationID("abc1").build()).build()) + .caseAccessCategory(CaseCategory.SPEC_CLAIM) + .applicantSolicitor1ClaimStatementOfTruth(StatementOfTruth.builder().name("test name").build()) + .build(); + CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).build(); + // When + when(organisationService.findOrganisationById(anyString())).thenReturn(Optional.empty()); + handler.handle(params); + // Then verify(notificationService).sendMail( "applicantsolicitor@example.com", - "template-id", - getNotificationDataMap(caseData), + "template-id-spec", + getNotificationDataMapStatement(), "create-sdo-applicants-notification-000DC001" ); } @NotNull - private Map getNotificationDataMap(CaseData caseData) { + private Map getNotificationDataMap() { return Map.of( CLAIM_REFERENCE_NUMBER, LEGACY_CASE_REFERENCE, CLAIM_LEGAL_ORG_NAME_SPEC, "Signer Name" ); } + + @NotNull + private Map getNotificationDataMapLip() { + return Map.of( + CLAIM_REFERENCE_NUMBER, LEGACY_CASE_REFERENCE, + CLAIMANT_NAME, "Mr. John Rambo" + ); + } + + @NotNull + private Map getNotificationDataMapStatement() { + return Map.of( + CLAIM_REFERENCE_NUMBER, LEGACY_CASE_REFERENCE, + CLAIM_LEGAL_ORG_NAME_SPEC, "test name" + ); + } } @Nested diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/NotifyClaimantClaimSubmittedTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/NotifyClaimantClaimSubmittedTest.java index e7eacfc0f36..5d836ab236f 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/NotifyClaimantClaimSubmittedTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/NotifyClaimantClaimSubmittedTest.java @@ -8,6 +8,8 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import uk.gov.hmcts.reform.civil.callback.CallbackParams; +import uk.gov.hmcts.reform.civil.config.PinInPostConfiguration; +import uk.gov.hmcts.reform.civil.enums.YesOrNo; import uk.gov.hmcts.reform.civil.handler.callback.BaseCallbackHandlerTest; import uk.gov.hmcts.reform.civil.model.CaseData; import uk.gov.hmcts.reform.civil.model.citizenui.CaseDataLiP; @@ -17,6 +19,7 @@ import uk.gov.hmcts.reform.civil.sampledata.CallbackParamsBuilder; import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; import uk.gov.hmcts.reform.civil.sampledata.PartyBuilder; +import uk.gov.hmcts.reform.civil.service.FeatureToggleService; import java.util.Map; @@ -25,6 +28,8 @@ import static org.mockito.Mockito.when; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; import static uk.gov.hmcts.reform.civil.handler.callback.camunda.notification.NotificationData.CLAIMANT_NAME; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.notification.NotificationData.FRONTEND_URL; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.notification.NotificationData.DEFENDANT_NAME; @SpringBootTest(classes = { NotifyClaimantClaimSubmitted.class, @@ -36,21 +41,33 @@ public class NotifyClaimantClaimSubmittedTest extends BaseCallbackHandlerTest { private NotificationService notificationService; @MockBean private NotificationsProperties notificationsProperties; + @MockBean + private FeatureToggleService toggleService; + @MockBean + private PinInPostConfiguration pinInPostConfiguration; @Autowired private NotifyClaimantClaimSubmitted handler; @Nested class AboutToSubmitCallback { - private static final String EMAIL_TEMPLATE = "test-notification-id"; + private static final String EMAIL_TEMPLATE_HWF = "test-notification-id"; + private static final String EMAIL_TEMPLATE_NO_HWF = "test-notification-no-hwf-id"; private static final String CLAIMANT_EMAIL_ID = "testorg@email.com"; + private static final String CLAIMANT_EMAIL_ID_INDIVIDUAL = "rambo@email.com"; private static final String REFERENCE_NUMBER = "claim-submitted-notification-000DC001"; private static final String CLAIMANT = "Mr. John Rambo"; + private static final String RESPONDENT_NAME = "Mr. Sole Trader"; + public static final String FRONTEND_CUI_URL = "dummy_cui_front_end_url"; @BeforeEach void setup() { when(notificationsProperties.getNotifyLiPClaimantClaimSubmittedAndPayClaimFeeTemplate()).thenReturn( - EMAIL_TEMPLATE); + EMAIL_TEMPLATE_NO_HWF); + when(notificationsProperties.getNotifyLiPClaimantClaimSubmittedAndHelpWithFeeTemplate()).thenReturn( + EMAIL_TEMPLATE_HWF); + when(pinInPostConfiguration.getCuiFrontEndUrl()).thenReturn("dummy_cui_front_end_url"); + when(toggleService.isLipVLipEnabled()).thenReturn(true); } @Test @@ -62,6 +79,9 @@ void shouldNotifyApplicant1_ClaimIsSubmittedButNotIssued() { .build()) .respondent1(PartyBuilder.builder().soleTrader().build().toBuilder() .build()) + .respondent1Represented(YesOrNo.NO) + .specRespondent1Represented(YesOrNo.NO) + .applicant1Represented(YesOrNo.NO) .build(); CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).build(); @@ -72,20 +92,23 @@ void shouldNotifyApplicant1_ClaimIsSubmittedButNotIssued() { // Then verify(notificationService, times(1)).sendMail( CLAIMANT_EMAIL_ID, - EMAIL_TEMPLATE, - getNotificationDataMap(caseData), + EMAIL_TEMPLATE_NO_HWF, + getNotificationDataMap(), REFERENCE_NUMBER ); } @Test - void shouldNotSendEmail_whenEventIsCalledAndDefendantHasNoEmail() { + void shouldNotSendEmail_whenEventIsCalledAndApplicantHasNoEmail() { //Given CaseData caseData = CaseDataBuilder.builder().atStateClaimSubmitted().build().toBuilder() .applicant1(PartyBuilder.builder().individual().build().toBuilder() .build()) .respondent1(PartyBuilder.builder().soleTrader().build().toBuilder() .build()) + .respondent1Represented(YesOrNo.NO) + .specRespondent1Represented(YesOrNo.NO) + .applicant1Represented(YesOrNo.NO) .build(); CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).build(); @@ -96,14 +119,14 @@ void shouldNotSendEmail_whenEventIsCalledAndDefendantHasNoEmail() { // Then verify(notificationService, times(0)).sendMail( CLAIMANT_EMAIL_ID, - EMAIL_TEMPLATE, - getNotificationDataMap(caseData), + EMAIL_TEMPLATE_NO_HWF, + getNotificationDataMap(), REFERENCE_NUMBER ); } @Test - void shouldNotSendEmail_whenHFWReferanceNumberPresent() { + void shouldSendEmail_whenHFWReferenceNumberPresent() { //Given CaseData caseData = CaseDataBuilder.builder().atStateClaimSubmitted().build().toBuilder() .applicant1(PartyBuilder.builder().individual().build().toBuilder() @@ -111,6 +134,9 @@ void shouldNotSendEmail_whenHFWReferanceNumberPresent() { .respondent1(PartyBuilder.builder().soleTrader().build().toBuilder() .build()) .caseDataLiP(CaseDataLiP.builder().helpWithFees(HelpWithFees.builder().helpWithFeesReferenceNumber("1111").build()).build()) + .respondent1Represented(YesOrNo.NO) + .specRespondent1Represented(YesOrNo.NO) + .applicant1Represented(YesOrNo.NO) .build(); CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).build(); @@ -119,17 +145,46 @@ void shouldNotSendEmail_whenHFWReferanceNumberPresent() { handler.handle(params); // Then - verify(notificationService, times(0)).sendMail( - CLAIMANT_EMAIL_ID, - EMAIL_TEMPLATE, - getNotificationDataMap(caseData), + verify(notificationService, times(1)).sendMail( + CLAIMANT_EMAIL_ID_INDIVIDUAL, + EMAIL_TEMPLATE_HWF, + getNotificationDataMap(), + REFERENCE_NUMBER + ); + } + + @Test + void shouldSendEmail_whenHFWReferanceNumberNotPresent() { + //Given + CaseData caseData = CaseDataBuilder.builder().atStateClaimSubmitted().build().toBuilder() + .applicant1(PartyBuilder.builder().individual().build().toBuilder() + .build()) + .respondent1(PartyBuilder.builder().soleTrader().build().toBuilder() + .build()) + .respondent1Represented(YesOrNo.NO) + .specRespondent1Represented(YesOrNo.NO) + .applicant1Represented(YesOrNo.NO) + .build(); + + CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).build(); + + // When + handler.handle(params); + + // Then + verify(notificationService, times(1)).sendMail( + CLAIMANT_EMAIL_ID_INDIVIDUAL, + EMAIL_TEMPLATE_NO_HWF, + getNotificationDataMap(), REFERENCE_NUMBER ); } - private Map getNotificationDataMap(CaseData caseData) { + private Map getNotificationDataMap() { return Map.of( - CLAIMANT_NAME, CLAIMANT + CLAIMANT_NAME, CLAIMANT, + DEFENDANT_NAME, RESPONDENT_NAME, + FRONTEND_URL, FRONTEND_CUI_URL ); } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/ClaimantResponseCuiCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/ClaimantResponseCuiCallbackHandlerTest.java index 8c889304389..f1b054d05e7 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/ClaimantResponseCuiCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/ClaimantResponseCuiCallbackHandlerTest.java @@ -14,11 +14,13 @@ import uk.gov.hmcts.reform.civil.callback.CallbackParams; import uk.gov.hmcts.reform.civil.enums.CaseState; import uk.gov.hmcts.reform.civil.enums.MediationDecision; +import uk.gov.hmcts.reform.civil.enums.YesOrNo; import uk.gov.hmcts.reform.civil.handler.callback.BaseCallbackHandlerTest; import uk.gov.hmcts.reform.civil.helpers.LocationHelper; import uk.gov.hmcts.reform.civil.model.CaseData; import uk.gov.hmcts.reform.civil.model.Party; import uk.gov.hmcts.reform.civil.model.citizenui.CaseDataLiP; +import uk.gov.hmcts.reform.civil.model.citizenui.ClaimantLiPResponse; import uk.gov.hmcts.reform.civil.model.citizenui.ClaimantMediationLip; import uk.gov.hmcts.reform.civil.model.defaultjudgment.CaseLocationCivil; import uk.gov.hmcts.reform.civil.model.dq.Applicant1DQ; @@ -27,10 +29,12 @@ import uk.gov.hmcts.reform.civil.referencedata.LocationRefDataService; import uk.gov.hmcts.reform.civil.referencedata.model.LocationRefData; import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; +import uk.gov.hmcts.reform.civil.service.Time; import uk.gov.hmcts.reform.civil.service.citizen.UpdateCaseManagementDetailsService; import uk.gov.hmcts.reform.civil.service.citizenui.ResponseOneVOneShowTagService; import uk.gov.hmcts.reform.civil.utils.CourtLocationUtils; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -38,10 +42,12 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; +import static org.junit.jupiter.api.Assertions.assertEquals; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_START; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CLAIMANT_RESPONSE_CUI; import static uk.gov.hmcts.reform.civil.enums.YesOrNo.NO; +import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES; import static uk.gov.hmcts.reform.civil.model.Party.Type.COMPANY; import static uk.gov.hmcts.reform.civil.model.Party.Type.ORGANISATION; @@ -73,6 +79,8 @@ class ClaimantResponseCuiCallbackHandlerTest extends BaseCallbackHandlerTest { @MockBean private ResponseOneVOneShowTagService responseOneVOneShowTagService; + @MockBean + private Time time; @Nested class AboutToStartCallback { @@ -91,6 +99,8 @@ void shouldReturnNoError_WhenAboutToStartIsInvoked() { @Nested class AboutToSubmitCallback { + private final LocalDateTime submittedDate = LocalDateTime.now(); + @BeforeEach void before() { LocationRefData locationRefData = LocationRefData.builder().siteName("Site 1").courtAddress("Adr 1").postcode("AAA 111") @@ -99,13 +109,13 @@ void before() { .epimmsId("111").build(); given(locationRefDataService.getCourtLocationsForDefaultJudgments(any())) .willReturn(getSampleCourLocationsRefObject()); + given(time.now()).willReturn(submittedDate); given(locationHelper.updateCaseManagementLocation(any(), any(), any())).willReturn(Optional.ofNullable(locationRefData)); } @Test void shouldUpdateBusinessProcess() { CaseData caseData = CaseDataBuilder.builder() - .atStateClaimIssued1v1LiP() .caseDataLip( CaseDataLiP.builder() .applicant1ClaimMediationSpecRequiredLip( @@ -113,6 +123,7 @@ void shouldUpdateBusinessProcess() { .hasAgreedFreeMediation(MediationDecision.Yes) .build()) .build()) + .atStateClaimIssued() .build(); CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); @@ -148,6 +159,7 @@ void shouldOnlyUpdateClaimStatus_whenPartAdmitNotSettled_NoMediation() { .build()).build(); CaseData caseData = CaseDataBuilder.builder() .atStateClaimIssued() + .applicant1ProceedWithClaim(YES) .applicant1PartAdmitConfirmAmountPaidSpec(NO) .applicant1PartAdmitIntentionToSettleClaimSpec(NO) .applicant1DQ(applicant1DQ) @@ -176,6 +188,76 @@ void shouldOnlyUpdateClaimStatus_whenPartAdmitNotSettled_NoMediation() { assertThat(data.getCaseNameHmctsInternal()).isEqualTo(data.getApplicant1().getPartyName() + " v " + data.getRespondent1().getPartyName()); } + @Test + void shouldUpdateCaseStateToJudicialReferral_WhenPartAdmitNoSettle_NoMediation() { + CaseDataLiP caseDataLiP = CaseDataLiP.builder() + .applicant1ClaimMediationSpecRequiredLip(ClaimantMediationLip.builder() + .hasAgreedFreeMediation(MediationDecision.No).build()) + .build(); + CaseData caseData = CaseDataBuilder.builder() + .caseDataLip(caseDataLiP) + .applicant1AcceptAdmitAmountPaidSpec(NO) + .applicant1ProceedWithClaim(YES) + .atStateClaimIssued().build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + assertEquals(CaseState.JUDICIAL_REFERRAL.name(), response.getState()); + + } + + @Test + void shouldUpdateCaseStateToJudicialReferral_WhenNotReceivedPayment_NoMediation_ForPartAdmit() { + CaseDataLiP caseDataLiP = CaseDataLiP.builder() + .applicant1ClaimMediationSpecRequiredLip(ClaimantMediationLip.builder() + .hasAgreedFreeMediation(MediationDecision.No).build()) + .build(); + CaseData caseData = CaseDataBuilder.builder() + .caseDataLip(caseDataLiP) + .applicant1ProceedWithClaim(YES) + .applicant1PartAdmitConfirmAmountPaidSpec(NO) + .atStateClaimIssued().build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + assertEquals(CaseState.JUDICIAL_REFERRAL.name(), response.getState()); + + } + + @Test + void shouldUpdateCaseStateToJudicialReferral_WhenFullDefence_NotPaid_NoMediation() { + CaseDataLiP caseDataLiP = CaseDataLiP.builder() + .applicant1ClaimMediationSpecRequiredLip(ClaimantMediationLip.builder() + .hasAgreedFreeMediation(MediationDecision.No).build()) + .build(); + CaseData caseData = + CaseDataBuilder.builder().caseDataLip(caseDataLiP).applicant1PartAdmitIntentionToSettleClaimSpec(NO) + .atStateClaimIssued() + .applicant1ProceedWithClaim(YES) + .build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + assertEquals(CaseState.JUDICIAL_REFERRAL.name(), response.getState()); + + } + + @Test + void shouldUpdateCaseStateToJudicialReferral_WhenFullDefence() { + CaseDataLiP caseDataLiP = CaseDataLiP.builder() + .applicant1ClaimMediationSpecRequiredLip(ClaimantMediationLip.builder() + .hasAgreedFreeMediation(MediationDecision.No).build()) + .build(); + CaseData caseData = + CaseDataBuilder.builder().caseDataLip(caseDataLiP).applicant1ProceedWithClaim(YES) + .atStateClaimIssued() + .build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + assertEquals(CaseState.JUDICIAL_REFERRAL.name(), response.getState()); + } + @Test void shouldChangeCaseState_whenApplicantRejectClaimSettlementAndAgreeToMediation() { CaseData caseData = CaseDataBuilder.builder() @@ -184,7 +266,8 @@ void shouldChangeCaseState_whenApplicantRejectClaimSettlementAndAgreeToMediation .caseDataLip(CaseDataLiP.builder().applicant1ClaimMediationSpecRequiredLip(ClaimantMediationLip.builder().hasAgreedFreeMediation( MediationDecision.Yes).build()) .build()) - .build(); + .build().toBuilder() + .responseClaimMediationSpecRequired(YES).build(); CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); @@ -209,12 +292,15 @@ protected List getSampleCourLocationsRefObject() { @Test void shouldChangeCaseState_whenApplicantRejectRepaymentPlanAndIsCompany_toAllFinalOrdersIssued() { CaseData caseData = CaseDataBuilder.builder() - .atStateClaimIssued() .applicant1AcceptPartAdmitPaymentPlanSpec(NO) + .caseDataLip(CaseDataLiP.builder().applicant1ClaimMediationSpecRequiredLip(ClaimantMediationLip.builder().hasAgreedFreeMediation( + MediationDecision.No).build()).build()) + .applicant1ProceedWithClaim(YES) + .applicant1(Party.builder().type(Party.Type.COMPANY).companyName("CLAIMANT_ORG_NAME").build()) .respondent1(Party.builder() - .type(COMPANY) - .companyName("Test Inc") - .build()) + .type(COMPANY) + .companyName("Test Inc") + .build()) .build(); CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); @@ -226,7 +312,8 @@ void shouldChangeCaseState_whenApplicantRejectRepaymentPlanAndIsCompany_toAllFin @Test void shouldChangeCaseState_whenApplicantRejectRepaymentPlanAndIsOrganisation_toAllFinalOrdersIssued() { CaseData caseData = CaseDataBuilder.builder() - .atStateClaimIssued() + .applicant1(Party.builder().type(Party.Type.COMPANY).companyName("CLAIMANT_ORG_NAME").build()) + .applicant1ProceedWithClaim(YES) .applicant1AcceptPartAdmitPaymentPlanSpec(NO) .respondent1(Party.builder() .type(ORGANISATION) @@ -239,6 +326,22 @@ void shouldChangeCaseState_whenApplicantRejectRepaymentPlanAndIsOrganisation_toA assertThat(response.getState()).isEqualTo(CaseState.PROCEEDS_IN_HERITAGE_SYSTEM.name()); } + + @Test + void shouldChangeCaseState_whenApplicantAcceptRepaymentPlanAndChooseSettlementAgreement() { + CaseData caseData = CaseDataBuilder.builder() + .atStateClaimIssued() + .applicant1AcceptPartAdmitPaymentPlanSpec(YesOrNo.YES) + .caseDataLip(CaseDataLiP.builder().applicant1LiPResponse(ClaimantLiPResponse.builder().applicant1SignedSettlementAgreement( + YesOrNo.YES).build()) + .build()) + .build(); + + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + + assertThat(response.getState()).isEqualTo(CaseState.All_FINAL_ORDERS_ISSUED.name()); + } } @Test diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/CreateClaimCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/CreateClaimCallbackHandlerTest.java index 71b10419903..9580191589f 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/CreateClaimCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/CreateClaimCallbackHandlerTest.java @@ -7,7 +7,6 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; @@ -91,7 +90,6 @@ import static uk.gov.hmcts.reform.civil.enums.YesOrNo.NO; import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES; import static uk.gov.hmcts.reform.civil.handler.callback.user.CreateClaimCallbackHandler.CONFIRMATION_SUMMARY; -import static uk.gov.hmcts.reform.civil.handler.callback.user.CreateClaimCallbackHandler.CONFIRMATION_BODY_COS; import static uk.gov.hmcts.reform.civil.handler.callback.user.CreateClaimCallbackHandler.CONFIRMATION_BODY_LIP_COS; import static uk.gov.hmcts.reform.civil.model.common.DynamicList.fromList; import static uk.gov.hmcts.reform.civil.utils.ElementUtils.element; @@ -1293,7 +1291,6 @@ void shouldSetCaseCategoryToUnspec_whenInvoked() { class DefendantLipAtClaimIssued { @Test void shouldSetDefend1LipAtClaimIssued_when_defendant1LitigantParty() { - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); caseData = CaseDataBuilder.builder().atStateClaimSubmitted1v1AndNoRespondentRepresented().build(); var response = (AboutToStartOrSubmitCallbackResponse) handler.handle( callbackParamsOf(caseData, ABOUT_TO_SUBMIT)); @@ -1305,7 +1302,6 @@ void shouldSetDefend1LipAtClaimIssued_when_defendant1LitigantParty() { @Test void shouldSetDefend1LipAtClaimIssued_1v2_defendant2LitigantParty_whenInvoked() { - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); caseData = CaseDataBuilder.builder() .atStateClaimSubmitted1v2AndOnlyFirstRespondentIsRepresented() .build(); @@ -1321,7 +1317,6 @@ void shouldSetDefend1LipAtClaimIssued_1v2_defendant2LitigantParty_whenInvoked() @Test void shouldSetDefend1LipAtClaimIssued_1v2_defendant1LitigantParty_whenInvoked() { - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); caseData = CaseDataBuilder.builder() .atStateClaimSubmitted1v2AndOnlySecondRespondentIsRepresented() .build(); @@ -1337,7 +1332,6 @@ void shouldSetDefend1LipAtClaimIssued_1v2_defendant1LitigantParty_whenInvoked() @Test void shouldSetDefendantLIPAtClaim_1v2_BothDefendantLitigantParty_whenInvoked() { - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); caseData = CaseDataBuilder.builder().atStateClaimSubmittedNoRespondentRepresented().build(); var response = (AboutToStartOrSubmitCallbackResponse) handler.handle( @@ -1630,10 +1624,6 @@ void shouldReturnExpectedErrorMessagesInResponse_whenInvokedWithNullApplicantPre @Nested class PopulateBlankOrgPolicies { - @BeforeEach - public void setup() { - when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(true); - } @Test void oneVOne() { @@ -1788,33 +1778,10 @@ class SubmittedCallback { @Nested class RespondentsDoNotHaveLegalRepresentation { - @Test - void shouldReturnExpectedSubmittedCallbackResponse_whenRespondentsDoesNotHaveRepresentation() { - CaseData caseData = CaseDataBuilder.builder().atStateClaimIssuedUnrepresentedDefendants().build(); - CallbackParams params = callbackParamsOf(caseData, SUBMITTED); - SubmittedCallbackResponse response = (SubmittedCallbackResponse) handler.handle(params); - - LocalDateTime serviceDeadline = now().plusDays(112).atTime(23, 59); - - String body = format( - CONFIRMATION_BODY_COS, - format("/cases/case-details/%s#Service%%20Request", CASE_ID), - format("/cases/case-details/%s#CaseDocuments", CASE_ID), - responsePackLink - ) + exitSurveyContentService.applicantSurvey(); - - assertThat(response).usingRecursiveComparison().isEqualTo( - SubmittedCallbackResponse.builder() - .confirmationHeader(format("# Please now pay your claim fee%n# using the link below")) - .confirmationBody(body) - .build()); - } - @Test void certificateOfService_shouldReturnExpectedResponse_whenRespondentsDoesNotHaveRepresentation() { CaseData caseData = CaseDataBuilder.builder().atStateClaimIssuedUnrepresentedDefendants().build(); CallbackParams params = callbackParamsOf(caseData, SUBMITTED); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); SubmittedCallbackResponse response = (SubmittedCallbackResponse) handler.handle(params); @@ -1880,7 +1847,6 @@ void shouldReturnExpectedSubmittedCallbackResponse_whenRespondent1HasRepresentat @Test void shouldReturnExpectedSubmittedCallbackResponse_whenRespondent1HasRepresentationAndPBAv3AndCOSIsOn() { - Mockito.when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); CaseData caseData = CaseDataBuilder.builder() .atStateClaimDetailsNotified() .multiPartyClaimOneDefendantSolicitor().build(); @@ -1903,35 +1869,11 @@ void shouldReturnExpectedSubmittedCallbackResponse_whenRespondent1HasRepresentat @Nested class Respondent1DoesNotHaveLegalRepresentation { - @Test - void shouldReturnExpectedSubmittedCallbackResponse_whenRespondentsDoesNotHaveRepresentation() { - CaseData caseData = CaseDataBuilder.builder().atStateClaimIssuedUnrepresentedDefendant1().build(); - CallbackParams params = callbackParamsOf(caseData, SUBMITTED); - SubmittedCallbackResponse response = (SubmittedCallbackResponse) handler.handle(params); - - LocalDateTime serviceDeadline = now().plusDays(112).atTime(23, 59); - - String body = format( - CONFIRMATION_BODY_COS, - format("/cases/case-details/%s#Service%%20Request", CASE_ID), - format("/cases/case-details/%s#CaseDocuments", CASE_ID), - responsePackLink - ) + exitSurveyContentService.applicantSurvey(); - - assertThat(response).usingRecursiveComparison().isEqualTo( - SubmittedCallbackResponse.builder() - .confirmationHeader(format("# Please now pay your claim fee%n# using the link below")) - .confirmationBody(body) - .build()); - } - @Test void certificateOfService_shouldReturnExpectedResponse_whenRespondentsDoesNotHaveRepresentation() { CaseData caseData = CaseDataBuilder.builder().atStateClaimIssuedUnrepresentedDefendant1().build(); CallbackParams params = callbackParamsOf(caseData, SUBMITTED); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); - SubmittedCallbackResponse response = (SubmittedCallbackResponse) handler.handle(params); String body = format( @@ -1952,35 +1894,12 @@ void certificateOfService_shouldReturnExpectedResponse_whenRespondentsDoesNotHav @Nested class Respondent1SolicitorOrgNotRegisteredInMyHmcts { - @Test - void shouldReturnExpectedSubmittedCallbackResponse_whenRespondent1SolicitorNotRegisteredInMyHmcts() { - CaseData caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified() - .respondent1Represented(YES) - .respondent1OrgRegistered(NO) - .build(); - CallbackParams params = callbackParamsOf(caseData, SUBMITTED); - SubmittedCallbackResponse response = (SubmittedCallbackResponse) handler.handle(params); - - assertThat(response).usingRecursiveComparison().isEqualTo( - SubmittedCallbackResponse.builder() - .confirmationHeader(format("# Please now pay your claim fee%n# using the link below")) - .confirmationBody(format( - CONFIRMATION_BODY_COS, - format("/cases/case-details/%s#Service%%20Request", CASE_ID), - format("/cases/case-details/%s#CaseDocuments", CASE_ID), - responsePackLink - ) + exitSurveyContentService.applicantSurvey()) - .build()); - } - @Test void certificateOfService_shouldReturnExpectedResponse_whenRespondent1SolicitorNotRegisteredInMyHmcts() { CaseData caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified() .respondent1Represented(YES) .respondent1OrgRegistered(NO) .build(); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); - CallbackParams params = callbackParamsOf(caseData, SUBMITTED); SubmittedCallbackResponse response = (SubmittedCallbackResponse) handler.handle(params); @@ -2000,31 +1919,10 @@ void certificateOfService_shouldReturnExpectedResponse_whenRespondent1SolicitorN @Nested class Respondent2DoesNotHaveLegalRepresentation { - @Test - void shouldReturnExpectedSubmittedCallbackResponse_whenRespondent2DoesNotHaveRepresentation() { - CaseData caseData = CaseDataBuilder.builder().atStateClaimIssuedUnrepresentedDefendants().build(); - CallbackParams params = callbackParamsOf(caseData, SUBMITTED); - SubmittedCallbackResponse response = (SubmittedCallbackResponse) handler.handle(params); - - String body = format( - CONFIRMATION_BODY_COS, - format("/cases/case-details/%s#Service%%20Request", CASE_ID), - format("/cases/case-details/%s#CaseDocuments", CASE_ID), - responsePackLink - ) + exitSurveyContentService.applicantSurvey(); - - assertThat(response).usingRecursiveComparison().isEqualTo( - SubmittedCallbackResponse.builder() - .confirmationHeader(format("# Please now pay your claim fee%n# using the link below")) - .confirmationBody(body) - .build()); - } - @Test void certificateOfService_shouldReturnExpectedResponse_whenRespondent2DoesNotHaveRepresentation() { CaseData caseData = CaseDataBuilder.builder().atStateClaimIssuedUnrepresentedDefendants().build(); CallbackParams params = callbackParamsOf(caseData, SUBMITTED); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); SubmittedCallbackResponse response = (SubmittedCallbackResponse) handler.handle(params); String body = format( @@ -2042,76 +1940,6 @@ void certificateOfService_shouldReturnExpectedResponse_whenRespondent2DoesNotHav } } - @Nested - class Respondent2SolicitorOrgNotRegisteredInMyHmcts { - - @Test - void shouldReturnExpectedSubmittedCallbackResponse_whenRespondent2SolicitorNotRegisteredInMyHmcts() { - CaseData caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified() - .respondent2Represented(YES) - .respondent2OrgRegistered(NO) - .build(); - CallbackParams params = callbackParamsOf(caseData, SUBMITTED); - SubmittedCallbackResponse response = (SubmittedCallbackResponse) handler.handle(params); - - assertThat(response).usingRecursiveComparison().isEqualTo( - SubmittedCallbackResponse.builder() - .confirmationHeader(format("# Please now pay your claim fee%n# using the link below")) - .confirmationBody(format( - CONFIRMATION_BODY_COS, - format("/cases/case-details/%s#Service%%20Request", CASE_ID), - format("/cases/case-details/%s#CaseDocuments", CASE_ID), - responsePackLink - ) + exitSurveyContentService.applicantSurvey()) - .build()); - } - - @Test - void shouldReturnExpectedSubmittedCallbackResponse_whenRespondent2SolicitorNotRegisteredInMyHmcts_PBAV3() { - CaseData caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified() - .respondent2Represented(YES) - .respondent2OrgRegistered(NO) - .build(); - - CallbackParams params = callbackParamsOf(caseData, SUBMITTED); - SubmittedCallbackResponse response = (SubmittedCallbackResponse) handler.handle(params); - - assertThat(response).usingRecursiveComparison().isEqualTo( - SubmittedCallbackResponse.builder() - .confirmationHeader(format("# Please now pay your claim fee%n# using the link below")) - .confirmationBody(format( - CONFIRMATION_BODY_COS, - format("/cases/case-details/%s#Service%%20Request", CASE_ID), - format("/cases/case-details/%s#CaseDocuments", CASE_ID), - responsePackLink - ) + exitSurveyContentService.applicantSurvey()) - .build()); - } - - @Test - void certificateOfService_shouldReturnExpectedResponse_whenRespondent2SolicitorNotRegisteredInMyHmcts() { - CaseData caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified() - .respondent2Represented(YES) - .respondent2OrgRegistered(NO) - .build(); - CallbackParams params = callbackParamsOf(caseData, SUBMITTED); - - SubmittedCallbackResponse response = (SubmittedCallbackResponse) handler.handle(params); - - assertThat(response).usingRecursiveComparison().isEqualTo( - SubmittedCallbackResponse.builder() - .confirmationHeader(format("# Please now pay your claim fee%n# using the link below")) - .confirmationBody(format( - CONFIRMATION_BODY_COS, - format("/cases/case-details/%s#Service%%20Request", CASE_ID), - format("/cases/case-details/%s#CaseDocuments", CASE_ID), - responsePackLink - ) + exitSurveyContentService.applicantSurvey()) - .build()); - } - - } - @Nested class RespondentHasLegalRepresentation1v1 { diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/CreateClaimSpecCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/CreateClaimSpecCallbackHandlerTest.java index 72f96b705a7..a8f216dcd76 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/CreateClaimSpecCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/CreateClaimSpecCallbackHandlerTest.java @@ -29,6 +29,13 @@ import uk.gov.hmcts.reform.civil.enums.YesOrNo; import uk.gov.hmcts.reform.civil.handler.callback.BaseCallbackHandlerTest; import uk.gov.hmcts.reform.civil.helpers.CaseDetailsConverter; +import uk.gov.hmcts.reform.civil.model.AirlineEpimsId; +import uk.gov.hmcts.reform.civil.service.AirlineEpimsDataLoader; +import uk.gov.hmcts.reform.civil.model.FlightDelayDetails; +import uk.gov.hmcts.reform.civil.referencedata.LocationRefDataService; +import uk.gov.hmcts.reform.civil.referencedata.model.LocationRefData; +import uk.gov.hmcts.reform.civil.sampledata.LocationRefSampleDataBuilder; +import uk.gov.hmcts.reform.civil.service.AirlineEpimsService; import uk.gov.hmcts.reform.civil.service.FeatureToggleService; import uk.gov.hmcts.reform.civil.model.Address; import uk.gov.hmcts.reform.civil.model.CaseData; @@ -207,6 +214,15 @@ class CreateClaimSpecCallbackHandlerTest extends BaseCallbackHandlerTest { @MockBean private ToggleConfiguration toggleConfiguration; + @MockBean + protected LocationRefDataService locationRefDataService; + + @MockBean + private AirlineEpimsDataLoader airlineEpimsDataLoader; + + @MockBean + private AirlineEpimsService airlineEpimsService; + @Nested class AboutToStartCallback { @@ -1623,7 +1639,7 @@ void shouldReturnErrors_whenRequiredAddressIsYesAndNotValid() { } @Nested - class IsFlightDelayClaimMidCallback { + class FlightDelayDetailsMidCallbacks { @ParameterizedTest @ValueSource(booleans = {true, false}) void shouldSetIsFlightDelayClaim_whenPopulatedAndSdoR2Enabled(Boolean toggleStat) { @@ -1661,6 +1677,61 @@ void shouldSetIsFlightDelayClaim_whenPopulatedAndSdoR2Disabled() { assertThat(response.getData()).doesNotHaveToString("isFlightDelayClaim"); assertThat(response.getData()).doesNotHaveToString("claimType"); } + + @Test + void shouldGetAirlineList_whenRequired() { + // Given + List airlineEpimsIDList = new ArrayList<>(); + airlineEpimsIDList.add(AirlineEpimsId.builder().airline("BA/Cityflyer").epimsID("111000").build()); + airlineEpimsIDList.add(AirlineEpimsId.builder().airline("OTHER").epimsID("111111").build()); + + given(airlineEpimsDataLoader.getAirlineEpimsIDList()) + .willReturn(airlineEpimsIDList); + + CaseData caseData = CaseData.builder().build(); + CallbackParams params = callbackParamsOf(caseData, MID, "get-airline-list"); + + // When + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + + // Then + assertThat(response.getData()).extracting("flightDelayDetails").extracting("airlineList") + .extracting("list_items").asList().extracting("label") + .contains("BA/Cityflyer"); + + assertThat(response.getData()).extracting("flightDelayDetails").extracting("airlineList") + .extracting("list_items").asList().extracting("label") + .contains("OTHER"); + } + + @Test + void shouldReturnErrorWhenDateOfFlightIsInTheFuture() { + // Given + CaseData caseData = CaseData.builder() + .flightDelayDetails(FlightDelayDetails.builder().scheduledDate(now().plusDays(1)).build()).build(); + + CallbackParams params = callbackParamsOf(caseData, MID, "validate-date-of-flight"); + // When + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + + // Then + assertThat(response.getErrors()).contains("Scheduled date of flight must be today or in the past"); + } + + @ParameterizedTest + @ValueSource(ints = {0, 1}) + void shouldNotReturnErrorWhenDateOfFlightIsTodayOrInThePast(Integer days) { + // Given + CaseData caseData = CaseData.builder() + .flightDelayDetails(FlightDelayDetails.builder().scheduledDate(now().minusDays(days)).build()).build(); + + CallbackParams params = callbackParamsOf(caseData, MID, "validate-date-of-flight"); + // When + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + + // Then + assertThat(response.getErrors()).isEmpty(); + } } @Nested @@ -1965,7 +2036,6 @@ void shouldAddMissingRespondent1OrgPolicyWithCaseRole_whenInvoked() { .respondent1OrganisationPolicy(null) .build()) .build(); - when(toggleService.isNoticeOfChangeEnabled()).thenReturn(true); // When var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(callbackParams); @@ -1982,7 +2052,6 @@ void shouldAddMissingRespondent2OrgPolicyWithCaseRole_whenInvoked() { var callbackParams = params.toBuilder() .caseData(params.getCaseData().toBuilder().build()) .build(); - when(toggleService.isNoticeOfChangeEnabled()).thenReturn(true); // When var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(callbackParams); @@ -2101,6 +2170,63 @@ void shouldMoveStatementOfTruthToCorrectFieldAndResetUIField_whenInvoked() { .doesNotHaveToString("role"); } } + + @Nested + class GetAirlineCourtLocation extends LocationRefSampleDataBuilder { + + @BeforeEach + void mockAirlineEpimsData() { + given(airlineEpimsService.getEpimsIdForAirline("GULF_AIR")) + .willReturn("36791"); + + List locations = new ArrayList<>(); + locations.add(LocationRefData.builder().regionId("Site Name").epimmsId("36791") + .build()); + given(locationRefDataService.getCourtLocationsForDefaultJudgments(any())) + .willReturn(locations); + + when(toggleService.isSdoR2Enabled()).thenReturn(true); + } + + @Test + void shouldReturnExpectedCourtLocation_whenAirlineExists() { + // Given + CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft() + .flightDelay(FlightDelayDetails.builder() + .airlineList( + DynamicList.builder() + .value(DynamicListElement.builder().code("GULF_AIR").label("Gulf Air") + .build()).build()).build()).build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + + // When + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + + // Then + assertThat(response.getData()).extracting("flightDelayDetails").extracting("flightCourtLocation").extracting("region").isEqualTo("Site Name"); + } + + @Test + void shouldReturnExpectedCourtLocation_whenOtherAirlineSelected() { + // Given + CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft() + .flightDelay(FlightDelayDetails.builder() + .airlineList( + DynamicList.builder() + .value(DynamicListElement.builder().code("OTHER").label("OTHER") + .build()).build()).build()).build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + + given(locationRefDataService.getCourtLocationsForDefaultJudgments(any())) + .willReturn(getSampleCourLocationsRefObject()); + + // When + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + + // Then + assertThat(response.getData()).extracting("flightDelayDetails").extracting("flightCourtLocation").isNull(); + } + } } @Nested diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/DefendantSignSettlementAgreementCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/DefendantSignSettlementAgreementCallbackHandlerTest.java new file mode 100644 index 00000000000..9b17a6b87d6 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/DefendantSignSettlementAgreementCallbackHandlerTest.java @@ -0,0 +1,80 @@ +package uk.gov.hmcts.reform.civil.handler.callback.user; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; +import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; +import uk.gov.hmcts.reform.civil.callback.CallbackParams; +import uk.gov.hmcts.reform.civil.enums.YesOrNo; +import uk.gov.hmcts.reform.civil.handler.callback.BaseCallbackHandlerTest; +import uk.gov.hmcts.reform.civil.model.CaseData; +import uk.gov.hmcts.reform.civil.model.citizenui.CaseDataLiP; +import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; + +import static org.assertj.core.api.Assertions.assertThat; +import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_START; +import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.DEFENDANT_SIGN_SETTLEMENT_AGREEMENT; + +@ExtendWith(MockitoExtension.class) +public class DefendantSignSettlementAgreementCallbackHandlerTest extends BaseCallbackHandlerTest { + + private DefendantSignSettlementAgreementCallbackHandler handler; + + @BeforeEach + void setUp() { + handler = new DefendantSignSettlementAgreementCallbackHandler(new ObjectMapper()); + } + + @Test + void handleEventsReturnsTheExpectedCallbackEvent() { + assertThat(handler.handledEvents()).contains(DEFENDANT_SIGN_SETTLEMENT_AGREEMENT); + } + + @Nested + class AboutToStartCallback { + + @Test + void shouldReturnNoError_WhenAboutToStartIsInvoked() { + CaseData caseData = CaseDataBuilder.builder() + .caseDataLip(CaseDataLiP.builder() + .respondentSignSettlementAgreement(YesOrNo.NO) + .build()) + .build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_START); + + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + + assertThat(response.getErrors()).isNull(); + } + } + + @Nested + class AboutToSubmitCallback { + + @Test + void shouldUpdateBusinessProcess() { + CaseData caseData = CaseDataBuilder.builder() + .caseDataLip(CaseDataLiP.builder() + .respondentSignSettlementAgreement(YesOrNo.NO) + .build()) + .build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + + assertThat(response.getData()) + .extracting("businessProcess") + .extracting("camundaEvent") + .isEqualTo(DEFENDANT_SIGN_SETTLEMENT_AGREEMENT.name()); + assertThat(response.getData()) + .extracting("businessProcess") + .extracting("status") + .isEqualTo("READY"); + } + } + +} diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadApplicantHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadApplicantHandlerTest.java index 3704297d425..25b666d5e08 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadApplicantHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadApplicantHandlerTest.java @@ -725,14 +725,14 @@ void should_do_naming_convention(String selected) { .documentJointStatement(createExpertDocs("expertsName", witnessDate, null, "expertises", null, null, null)) .documentQuestions(createExpertDocs("expertName", witnessDate, null, null, "other", "question", null)) .documentAnswers(createExpertDocs("expertName", witnessDate, null, null, "other", null, "answer")) - .documentForDisclosure(createEvidenceDocs("typeDisclosure", witnessDate)) - .documentReferredInStatement(createEvidenceDocs("typeReferred", witnessDate)) - .documentEvidenceForTrial(createEvidenceDocs("typeForTrial", witnessDate)) - .documentDisclosureList(createEvidenceDocs(null, null)) - .documentCaseSummary(createEvidenceDocs(null, null)) - .documentSkeletonArgument(createEvidenceDocs(null, null)) - .documentAuthorities(createEvidenceDocs(null, null)) - .documentCosts(createEvidenceDocs(null, null)) + .documentForDisclosure(createEvidenceDocs(null, "typeDisclosure", witnessDate)) + .documentReferredInStatement(createEvidenceDocs("witness", "typeReferred", witnessDate)) + .documentEvidenceForTrial(createEvidenceDocs(null, "typeForTrial", witnessDate)) + .documentDisclosureList(createEvidenceDocs(null, null, null)) + .documentCaseSummary(createEvidenceDocs(null, null, null)) + .documentSkeletonArgument(createEvidenceDocs(null, null, null)) + .documentAuthorities(createEvidenceDocs(null, null, null)) + .documentCosts(createEvidenceDocs(null, null, null)) .build(); CaseData caseDataBefore = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() .addApplicant2(YES) @@ -768,7 +768,7 @@ void should_do_naming_convention(String selected) { assertThat(updatedData.getDocumentForDisclosure().get(0).getValue() .getDocumentUpload().getDocumentFileName()).isEqualTo("Document for disclosure typeDisclosure 10-02-2023.pdf"); assertThat(updatedData.getDocumentReferredInStatement().get(0).getValue() - .getDocumentUpload().getDocumentFileName()).isEqualTo("Referred Document typeReferred 10-02-2023.pdf"); + .getDocumentUpload().getDocumentFileName()).isEqualTo("typeReferred referred to in the statement of witness 10-02-2023.pdf"); assertThat(updatedData.getDocumentEvidenceForTrial().get(0).getValue() .getDocumentUpload().getDocumentFileName()).isEqualTo("Documentary Evidence typeForTrial 10-02-2023.pdf"); assertThat(updatedData.getDocumentDisclosureList().get(0).getValue() @@ -817,7 +817,7 @@ void should_do_naming_convention(String selected) { assertThat(updatedData.getDocumentForDisclosureApp2().get(0).getValue() .getDocumentUpload().getCategoryID()).isEqualTo(EvidenceUploadHandlerBase.APPLICANT_TWO_DISCLOSURE); assertThat(updatedData.getDocumentReferredInStatementApp2().get(0).getValue() - .getDocumentUpload().getDocumentFileName()).isEqualTo("Referred Document typeReferred 10-02-2023.pdf"); + .getDocumentUpload().getDocumentFileName()).isEqualTo("typeReferred referred to in the statement of witness 10-02-2023.pdf"); assertThat(updatedData.getDocumentReferredInStatementApp2().get(0).getValue() .getDocumentUpload().getCategoryID()).isEqualTo(EvidenceUploadHandlerBase.APPLICANT_TWO_WITNESS_REFERRED); assertThat(updatedData.getDocumentEvidenceForTrialApp2().get(0).getValue() @@ -869,14 +869,14 @@ void should_do_naming_convention_app2() { .documentJointStatementApp2(createExpertDocs("expertsName", witnessDate, null, "expertises", null, null, null)) .documentQuestionsApp2(createExpertDocs("expertName", witnessDate, null, null, "other", "question", null)) .documentAnswersApp2(createExpertDocs("expertName", witnessDate, null, null, "other", null, "answer")) - .documentForDisclosureApp2(createEvidenceDocs("typeDisclosure", witnessDate)) - .documentReferredInStatementApp2(createEvidenceDocs("typeReferred", witnessDate)) - .documentEvidenceForTrialApp2(createEvidenceDocs("typeForTrial", witnessDate)) - .documentDisclosureListApp2(createEvidenceDocs(null, null)) - .documentCaseSummaryApp2(createEvidenceDocs(null, null)) - .documentSkeletonArgumentApp2(createEvidenceDocs(null, null)) - .documentAuthoritiesApp2(createEvidenceDocs(null, null)) - .documentCostsApp2(createEvidenceDocs(null, null)) + .documentForDisclosureApp2(createEvidenceDocs(null, "typeDisclosure", witnessDate)) + .documentReferredInStatementApp2(createEvidenceDocs("witness", "typeReferred", witnessDate)) + .documentEvidenceForTrialApp2(createEvidenceDocs(null, "typeForTrial", witnessDate)) + .documentDisclosureListApp2(createEvidenceDocs(null, null, null)) + .documentCaseSummaryApp2(createEvidenceDocs(null, null, null)) + .documentSkeletonArgumentApp2(createEvidenceDocs(null, null, null)) + .documentAuthoritiesApp2(createEvidenceDocs(null, null, null)) + .documentCostsApp2(createEvidenceDocs(null, null, null)) .build(); CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); given(userService.getUserInfo(anyString())).willReturn(UserInfo.builder().uid("uid").build()); @@ -906,7 +906,7 @@ void should_do_naming_convention_app2() { assertThat(updatedData.getDocumentForDisclosureApp2().get(0).getValue() .getDocumentUpload().getDocumentFileName()).isEqualTo("Document for disclosure typeDisclosure 10-02-2023.pdf"); assertThat(updatedData.getDocumentReferredInStatementApp2().get(0).getValue() - .getDocumentUpload().getDocumentFileName()).isEqualTo("Referred Document typeReferred 10-02-2023.pdf"); + .getDocumentUpload().getDocumentFileName()).isEqualTo("typeReferred referred to in the statement of witness 10-02-2023.pdf"); assertThat(updatedData.getDocumentEvidenceForTrialApp2().get(0).getValue() .getDocumentUpload().getDocumentFileName()).isEqualTo("Documentary Evidence typeForTrial 10-02-2023.pdf"); assertThat(updatedData.getDocumentDisclosureListApp2().get(0).getValue() @@ -974,13 +974,14 @@ void shouldNotPopulateNotificationWithOldDocument_whenNewDocumentUploadAdded() { assertThat(updatedData.getNotificationText()).isEqualTo("\nClaimant 1 - Witness summary"); } - private List> createEvidenceDocs(String type, LocalDate issuedDate) { + private List> createEvidenceDocs(String name, String type, LocalDate issuedDate) { Document document = Document.builder().documentBinaryUrl( TEST_URL) .documentFileName(TEST_FILE_NAME).build(); List> evidenceDocs = new ArrayList<>(); evidenceDocs.add(ElementUtils.element(UploadEvidenceDocumentType .builder() + .witnessOptionName(name) .typeOfDocument(type) .documentIssuedDate(issuedDate) .documentUpload(document) diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadJudgeHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadJudgeHandlerTest.java index d37c56db259..93698b7e222 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadJudgeHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadJudgeHandlerTest.java @@ -31,6 +31,7 @@ import java.util.List; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; import static uk.gov.hmcts.reform.civil.callback.CallbackParams.Params.BEARER_TOKEN; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_START; @@ -104,109 +105,83 @@ void shouldPopulateNoteDateTime_whenNoteIsAddedToCase() { @Test void shouldCopyDocumentAndNameToAdd_whenDocumentWithNameIsNull() { Document document = Document.builder().documentFileName("fileName").build(); - DocumentWithName testDocument = DocumentWithName.builder() - .documentName("testDocument") - .document(document) - .build(); + DocumentWithName testDocument = DocumentWithName.builder().documentName("testDocument").document(document).createdBy("bill bob").build(); List> documentWithNameToAdd = wrapElements(testDocument); - CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() .caseNoteType(CaseNoteType.DOCUMENT_ONLY) .documentAndNameToAdd(documentWithNameToAdd) - .caseNoteTA(null) .build(); + when(caseNoteService.buildJudgeCaseNoteDocumentAndName(any(), any())).thenReturn(documentWithNameToAdd); CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); - - assertThat(response.getData()).extracting("documentAndName") - .isEqualTo(objectMapper.convertValue(documentWithNameToAdd, new TypeReference<>() {})); + assertThat(response.getData()).extracting("documentAndName").isEqualTo(objectMapper.convertValue(documentWithNameToAdd, new TypeReference<>() {})); assertThat(response.getData()).extracting("caseNotesTA").isNull(); assertThat(response.getData()).extracting("documentAndNote").isNull(); - } @Test void shouldAddDocument_whenDocumentWithNameIsNotNull() { Document document = Document.builder().documentFileName("fileName").build(); - DocumentWithName testDocument = DocumentWithName.builder() - .documentName("testDocument") - .document(document) - .build(); - List> documentWithNameToAdd = wrapElements(testDocument); + DocumentWithName testDocument = DocumentWithName.builder().documentName("testDocument").document(document).createdBy("John Doe").build(); List> documentWithNameStart = wrapElements(testDocument); + List> documentWithNameToAdd = wrapElements(testDocument); List> documentWithNameEnd = wrapElements(testDocument, testDocument); - CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() .caseNoteType(CaseNoteType.DOCUMENT_ONLY) .documentAndNameToAdd(documentWithNameToAdd) .documentAndName(documentWithNameStart) - .caseNoteTA(null) .build(); + when(caseNoteService.buildJudgeCaseNoteDocumentAndName(any(), any())).thenReturn(documentWithNameToAdd); CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); - - assertThat(response.getData()).extracting("documentAndName") - .isEqualTo(objectMapper.convertValue(documentWithNameEnd, new TypeReference<>() {})); + assertThat(response.getData()).extracting("documentAndName").isEqualTo(objectMapper.convertValue(documentWithNameEnd, new TypeReference<>() {})); assertThat(response.getData()).extracting("caseNotesTA").isNull(); assertThat(response.getData()).extracting("documentAndNote").isNull(); - } @Test void shouldAddNote_whenDocumentWithNoteIsNotNull() { Document document = Document.builder().documentFileName("fileName").build(); - DocumentAndNote testDocument = DocumentAndNote.builder() - .documentName("testDocument") - .document(document) - .documentNote("Note") - .build(); + DocumentAndNote testDocument = DocumentAndNote.builder().documentName("testDocument").document(document).documentNote("Note").createdBy("john smith").build(); List> documentAndNoteToAdd = wrapElements(testDocument); List> documentAndNoteStart = wrapElements(testDocument); List> documentAndNoteEnd = wrapElements(testDocument, testDocument); - CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() .caseNoteType(CaseNoteType.DOCUMENT_AND_NOTE) .documentAndNoteToAdd(documentAndNoteToAdd) .documentAndNote(documentAndNoteStart) .build(); + when(caseNoteService.buildJudgeCaseNoteAndDocument(any(), any())).thenReturn(documentAndNoteToAdd); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); - - assertThat(response.getData()).extracting("documentAndNote") - .isEqualTo(objectMapper.convertValue(documentAndNoteEnd, new TypeReference<>() {})); + assertThat(response.getData()).extracting("documentAndNote").isEqualTo(objectMapper.convertValue(documentAndNoteEnd, new TypeReference<>() {})); assertThat(response.getData()).extracting("caseNotesTA").isNull(); assertThat(response.getData()).extracting("documentAndName").isNull(); - } @Test void shouldCopyDocumentAndNoteToAdd_whenDocumentWithNoteIsNull() { Document document = Document.builder().documentFileName("fileName").build(); - DocumentAndNote testDocument = DocumentAndNote.builder() - .documentName("testDocument") - .document(document) - .documentNote("Note") - .build(); + DocumentAndNote testDocument = DocumentAndNote.builder().documentName("testDocument").document(document).documentNote("Note").createdBy("Jason Bourne").build(); List> documentAndNoteToAdd = wrapElements(testDocument); - CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() .caseNoteType(CaseNoteType.DOCUMENT_AND_NOTE) .documentAndNoteToAdd(documentAndNoteToAdd) .build(); CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + when(caseNoteService.buildJudgeCaseNoteAndDocument(any(), any())).thenReturn(documentAndNoteToAdd); var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); - assertThat(response.getData()).extracting("documentAndNote") - .isEqualTo(objectMapper.convertValue(documentAndNoteToAdd, new TypeReference<>() {})); + assertThat(response.getData()).extracting("documentAndNote").isEqualTo(objectMapper.convertValue(documentAndNoteToAdd, new TypeReference<>() {})); assertThat(response.getData()).extracting("caseNotesTA").isNull(); assertThat(response.getData()).extracting("documentAndName").isNull(); - } } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadRespondentHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadRespondentHandlerTest.java index d5c32eeac09..b1ab3690b13 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadRespondentHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/EvidenceUploadRespondentHandlerTest.java @@ -1332,14 +1332,14 @@ void should_do_naming_convention_resp1(String selected) { .documentJointStatementRes(createExpertDocs("expertsName", witnessDate, null, "expertises", null, null, null)) .documentQuestionsRes(createExpertDocs("expertName", witnessDate, null, null, "other", "question", null)) .documentAnswersRes(createExpertDocs("expertName", witnessDate, null, null, "other", null, "answer")) - .documentForDisclosureRes(createEvidenceDocs("typeDisclosure", witnessDate)) - .documentReferredInStatementRes(createEvidenceDocs("typeReferred", witnessDate)) - .documentEvidenceForTrialRes(createEvidenceDocs("typeForTrial", witnessDate)) - .documentDisclosureListRes(createEvidenceDocs(null, null)) - .documentCaseSummaryRes(createEvidenceDocs(null, null)) - .documentSkeletonArgumentRes(createEvidenceDocs(null, null)) - .documentAuthoritiesRes(createEvidenceDocs(null, null)) - .documentCostsRes(createEvidenceDocs(null, null)) + .documentForDisclosureRes(createEvidenceDocs(null, "typeDisclosure", witnessDate)) + .documentReferredInStatementRes(createEvidenceDocs("witness", "typeReferred", witnessDate)) + .documentEvidenceForTrialRes(createEvidenceDocs(null, "typeForTrial", witnessDate)) + .documentDisclosureListRes(createEvidenceDocs(null, null, null)) + .documentCaseSummaryRes(createEvidenceDocs(null, null, null)) + .documentSkeletonArgumentRes(createEvidenceDocs(null, null, null)) + .documentAuthoritiesRes(createEvidenceDocs(null, null, null)) + .documentCostsRes(createEvidenceDocs(null, null, null)) .build(); CaseData caseDataBefore = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() .addRespondent2(YES) @@ -1376,7 +1376,7 @@ void should_do_naming_convention_resp1(String selected) { assertThat(updatedData.getDocumentForDisclosureRes().get(0).getValue() .getDocumentUpload().getDocumentFileName()).isEqualTo("Document for disclosure typeDisclosure 10-02-2023.pdf"); assertThat(updatedData.getDocumentReferredInStatementRes().get(0).getValue() - .getDocumentUpload().getDocumentFileName()).isEqualTo("Referred Document typeReferred 10-02-2023.pdf"); + .getDocumentUpload().getDocumentFileName()).isEqualTo("typeReferred referred to in the statement of witness 10-02-2023.pdf"); assertThat(updatedData.getDocumentEvidenceForTrialRes().get(0).getValue() .getDocumentUpload().getDocumentFileName()).isEqualTo("Documentary Evidence typeForTrial 10-02-2023.pdf"); assertThat(updatedData.getDocumentDisclosureListRes().get(0).getValue() @@ -1425,7 +1425,7 @@ void should_do_naming_convention_resp1(String selected) { assertThat(updatedData.getDocumentForDisclosureRes2().get(0).getValue() .getDocumentUpload().getCategoryID()).isEqualTo(EvidenceUploadHandlerBase.RESPONDENT_TWO_DISCLOSURE); assertThat(updatedData.getDocumentReferredInStatementRes2().get(0).getValue() - .getDocumentUpload().getDocumentFileName()).isEqualTo("Referred Document typeReferred 10-02-2023.pdf"); + .getDocumentUpload().getDocumentFileName()).isEqualTo("typeReferred referred to in the statement of witness 10-02-2023.pdf"); assertThat(updatedData.getDocumentReferredInStatementRes2().get(0).getValue() .getDocumentUpload().getCategoryID()).isEqualTo(EvidenceUploadHandlerBase.RESPONDENT_TWO_WITNESS_REFERRED); assertThat(updatedData.getDocumentEvidenceForTrialRes2().get(0).getValue() @@ -1473,14 +1473,14 @@ void should_do_naming_convention_resp2() { .documentJointStatementRes2(createExpertDocs("expertsName", witnessDate, null, "expertises", null, null, null)) .documentQuestionsRes2(createExpertDocs("expertName", witnessDate, null, null, "other", "question", null)) .documentAnswersRes2(createExpertDocs("expertName", witnessDate, null, null, "other", null, "answer")) - .documentForDisclosureRes2(createEvidenceDocs("typeDisclosure", witnessDate)) - .documentReferredInStatementRes2(createEvidenceDocs("typeReferred", witnessDate)) - .documentEvidenceForTrialRes2(createEvidenceDocs("typeForTrial", witnessDate)) - .documentDisclosureListRes2(createEvidenceDocs(null, null)) - .documentCaseSummaryRes2(createEvidenceDocs(null, null)) - .documentSkeletonArgumentRes2(createEvidenceDocs(null, null)) - .documentAuthoritiesRes2(createEvidenceDocs(null, null)) - .documentCostsRes2(createEvidenceDocs(null, null)) + .documentForDisclosureRes2(createEvidenceDocs(null, "typeDisclosure", witnessDate)) + .documentReferredInStatementRes2(createEvidenceDocs("witness", "typeReferred", witnessDate)) + .documentEvidenceForTrialRes2(createEvidenceDocs(null, "typeForTrial", witnessDate)) + .documentDisclosureListRes2(createEvidenceDocs(null, null, null)) + .documentCaseSummaryRes2(createEvidenceDocs(null, null, null)) + .documentSkeletonArgumentRes2(createEvidenceDocs(null, null, null)) + .documentAuthoritiesRes2(createEvidenceDocs(null, null, null)) + .documentCostsRes2(createEvidenceDocs(null, null, null)) .build(); CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); given(userService.getUserInfo(anyString())).willReturn(UserInfo.builder().uid("uid").build()); @@ -1510,7 +1510,7 @@ void should_do_naming_convention_resp2() { assertThat(updatedData.getDocumentForDisclosureRes2().get(0).getValue() .getDocumentUpload().getDocumentFileName()).isEqualTo("Document for disclosure typeDisclosure 10-02-2023.pdf"); assertThat(updatedData.getDocumentReferredInStatementRes2().get(0).getValue() - .getDocumentUpload().getDocumentFileName()).isEqualTo("Referred Document typeReferred 10-02-2023.pdf"); + .getDocumentUpload().getDocumentFileName()).isEqualTo("typeReferred referred to in the statement of witness 10-02-2023.pdf"); assertThat(updatedData.getDocumentEvidenceForTrialRes2().get(0).getValue() .getDocumentUpload().getDocumentFileName()).isEqualTo("Documentary Evidence typeForTrial 10-02-2023.pdf"); assertThat(updatedData.getDocumentDisclosureListRes2().get(0).getValue() @@ -1594,13 +1594,14 @@ void should_compareAndCopy() { assertThat(handler.compareAndCopy(before, after, target)).hasSize(1); } - private List> createEvidenceDocs(String type, LocalDate issuedDate) { + private List> createEvidenceDocs(String name, String type, LocalDate issuedDate) { Document document = Document.builder().documentBinaryUrl( TEST_URL) .documentFileName(TEST_FILE_NAME).build(); List> evidenceDocs = new ArrayList<>(); evidenceDocs.add(ElementUtils.element(UploadEvidenceDocumentType .builder() + .witnessOptionName(name) .typeOfDocument(type) .documentIssuedDate(issuedDate) .documentUpload(document) diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/InitiateGeneralApplicationServiceHelperTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/InitiateGeneralApplicationServiceHelperTest.java index 9f2c10dcfc0..a7d8476c88f 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/InitiateGeneralApplicationServiceHelperTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/InitiateGeneralApplicationServiceHelperTest.java @@ -1,5 +1,6 @@ package uk.gov.hmcts.reform.civil.handler.callback.user; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -95,6 +96,11 @@ void setup() { .caseAssignedUserRoles(getCaseAssignedApplicantUserRoles()).build()); } + @AfterEach + void setUserRolesAsNull() { + helper.userRoles = null; + } + public List getCaseAssignedApplicantUserRoles() { return List.of( CaseAssignedUserRole.builder().caseDataId("1").userId(STRING_NUM_CONSTANT) @@ -268,6 +274,7 @@ void shouldSetApplicantSolicitorOrgIDTo200() { .respondentSolicitor1EmailAddress(RESPONDENT_EMAIL_ID_CONSTANT) .applicant1(Party.builder().type(COMPANY).companyName("Applicant1").build()) .respondent2(Party.builder().type(COMPANY).companyName("Respondent1").build()) + .addRespondent2(YesOrNo.YES) .applicant1OrganisationPolicy(OrganisationPolicy.builder() .organisation(Organisation.builder().organisationID("200").build()) .orgPolicyCaseAssignedRole(APPLICANTSOLICITORONE.getFormattedName()) @@ -309,6 +316,7 @@ void shouldSetApplicantSolicitorOrgIDTo100() { .applicant2(Party.builder().type(COMPANY).companyName("Applicant2").build()) .respondent1(Party.builder().type(COMPANY).companyName("Respondent1").build()) .respondent2(Party.builder().type(COMPANY).companyName("Respondent2").build()) + .addRespondent2(YesOrNo.YES) .applicant1OrganisationPolicy(OrganisationPolicy.builder() .organisation(Organisation.builder().organisationID("200").build()) .orgPolicyCaseAssignedRole(APPLICANTSOLICITORONE.getFormattedName()) diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/ManageContactInformationCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/ManageContactInformationCallbackHandlerTest.java index 8ff9b667be7..0cdec436412 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/ManageContactInformationCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/ManageContactInformationCallbackHandlerTest.java @@ -1,11 +1,16 @@ package uk.gov.hmcts.reform.civil.handler.callback.user; import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; import org.junit.jupiter.params.provider.ValueSource; +import org.mockito.MockedStatic; +import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; @@ -22,6 +27,7 @@ import uk.gov.hmcts.reform.civil.model.Address; import uk.gov.hmcts.reform.civil.model.CaseData; import uk.gov.hmcts.reform.civil.model.Party; +import uk.gov.hmcts.reform.civil.model.PartyFlagStructure; import uk.gov.hmcts.reform.civil.model.UpdateDetailsForm; import uk.gov.hmcts.reform.civil.model.UpdatePartyDetailsForm; import uk.gov.hmcts.reform.civil.model.common.DynamicList; @@ -37,6 +43,7 @@ import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; import uk.gov.hmcts.reform.civil.service.CoreCaseUserService; import uk.gov.hmcts.reform.civil.utils.CaseFlagsInitialiser; +import uk.gov.hmcts.reform.civil.utils.PartyUtils; import uk.gov.hmcts.reform.civil.validation.PostcodeValidator; import uk.gov.hmcts.reform.idam.client.models.UserInfo; import java.time.LocalDate; @@ -48,6 +55,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mockStatic; import static org.mockito.Mockito.when; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; import static uk.gov.hmcts.reform.civil.callback.CallbackType.MID; @@ -79,6 +87,7 @@ CaseDetailsConverter.class, PostcodeValidator.class }) +@SuppressWarnings("unchecked") class ManageContactInformationCallbackHandlerTest extends BaseCallbackHandlerTest { @Autowired @@ -139,10 +148,11 @@ void shouldNotReturnReturnErrors_WhenAboutToStartIsInvokedByAdminUserWhileCaseIn assertNull(response.getErrors()); } - @Test - void shouldReturnErrors_WhenAboutToStartIsInvokedByNonAdminUserWhileCaseInAwaitingApplicantIntentionState() { + @ParameterizedTest + @EnumSource(value = CaseState.class, names = {"AWAITING_RESPONDENT_ACKNOWLEDGEMENT", "AWAITING_APPLICANT_INTENTION"}) + void shouldReturnErrors_WhenAboutToStartIsInvokedByNonAdminUserWhileCaseInAwaitingRespondentAcknowledgementState(CaseState states) { when(userService.getUserInfo(anyString())).thenReturn(LEGAL_REP_USER); - CaseData caseData = CaseData.builder().ccdState(CaseState.AWAITING_APPLICANT_INTENTION) + CaseData caseData = CaseData.builder().ccdState(states) .ccdCaseReference(123L) .build(); CallbackParams params = callbackParamsOf(caseData, CallbackType.ABOUT_TO_START); @@ -718,6 +728,23 @@ class AboutToSubmit { Expert expectedExpert1; Witness dqWitness; Witness expectedWitness1; + PartyFlagStructure expectedExpertFlags; + PartyFlagStructure expectedWitnessFlags; + + private static final String PARTY_ID = "party-id"; + private static MockedStatic partyIdMock; + + @BeforeAll + static void setupSuite() { + partyIdMock = mockStatic(PartyUtils.class, Mockito.CALLS_REAL_METHODS); + partyIdMock.when(PartyUtils::createPartyId).thenReturn(PARTY_ID); + } + + @AfterAll + static void tearDown() { + partyIdMock.reset(); + partyIdMock.close(); + } @BeforeEach void setup() { @@ -725,12 +752,22 @@ void setup() { dqExpert = Expert.builder().partyID("id").firstName("dq").lastName("dq").build(); expectedExpert1 = dqExpert.builder().firstName("First").lastName("Name") .eventAdded("Manage Contact Information Event").dateAdded(LocalDate.now()) - .partyID(null) //change this for CIV-10382 + .partyID(PARTY_ID) + .build(); + expectedExpertFlags = PartyFlagStructure.builder() + .partyID(PARTY_ID) + .firstName("First") + .lastName("Name") .build(); dqWitness = Witness.builder().firstName("dq").lastName("dq").partyID("id").build(); expectedWitness1 = Witness.builder().firstName("First").lastName("Name") .eventAdded("Manage Contact Information Event").dateAdded(LocalDate.now()) - .partyID(null).build(); // CIV-10382 + .partyID(PARTY_ID).build(); + expectedWitnessFlags = PartyFlagStructure.builder() + .partyID(PARTY_ID) + .firstName("First") + .lastName("Name") + .build(); } @Test @@ -757,6 +794,7 @@ void shouldUpdateApplicantOneExperts() { CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); assertThat(unwrapElements(updatedData.getApplicant1DQ().getApplicant1DQExperts().getDetails()).get(0)).isEqualTo(expectedExpert1); + assertThat(unwrapElements(updatedData.getApplicantExperts()).get(0)).isEqualTo(expectedExpertFlags); } @Test @@ -783,6 +821,7 @@ void shouldUpdateDefendantOneExperts() { CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); assertThat(unwrapElements(updatedData.getRespondent1DQ().getRespondent1DQExperts().getDetails()).get(0)).isEqualTo(expectedExpert1); + assertThat(unwrapElements(updatedData.getRespondent1Experts()).get(0)).isEqualTo(expectedExpertFlags); } @Test @@ -809,6 +848,7 @@ void shouldUpdateDefendantTwoExperts() { CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); assertThat(unwrapElements(updatedData.getRespondent2DQ().getRespondent2DQExperts().getDetails()).get(0)).isEqualTo(expectedExpert1); + assertThat(unwrapElements(updatedData.getRespondent2Experts()).get(0)).isEqualTo(expectedExpertFlags); } @Test @@ -835,6 +875,7 @@ void shouldUpdateApplicantOneWitnesses() { CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); assertThat(unwrapElements(updatedData.getApplicant1DQ().getApplicant1DQWitnesses().getDetails()).get(0)).isEqualTo(expectedWitness1); + assertThat(unwrapElements(updatedData.getApplicantWitnesses()).get(0)).isEqualTo(expectedWitnessFlags); } @Test @@ -861,6 +902,7 @@ void shouldUpdateDefendantOneWitnesses() { CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); assertThat(unwrapElements(updatedData.getRespondent1DQ().getRespondent1DQWitnesses().getDetails()).get(0)).isEqualTo(expectedWitness1); + assertThat(unwrapElements(updatedData.getRespondent1Witnesses()).get(0)).isEqualTo(expectedWitnessFlags); } @Test @@ -887,6 +929,7 @@ void shouldUpdateDefendantTwoWitnesses() { CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); assertThat(unwrapElements(updatedData.getRespondent2DQ().getRespondent2DQWitnesses().getDetails()).get(0)).isEqualTo(expectedWitness1); + assertThat(unwrapElements(updatedData.getRespondent2Witnesses()).get(0)).isEqualTo(expectedWitnessFlags); } @Test diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimCallbackHandlerTest.java index ff03f28aeb7..90222fc7112 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimCallbackHandlerTest.java @@ -36,7 +36,6 @@ import static java.time.format.DateTimeFormatter.ISO_DATE; import static java.time.format.DateTimeFormatter.ISO_DATE_TIME; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; @@ -98,75 +97,12 @@ void shouldPrepopulateDynamicListWithOptions_whenInvoked() { CaseData caseData = CaseDataBuilder.builder() .atStateClaimNotified_1v2_andNotifyBothSolicitors() .build(); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_START); AboutToStartOrSubmitCallbackResponse response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); assertTrue(response.getData().containsKey("defendantSolicitorNotifyClaimOptions")); } - - @Test - void aboutToStart_ShouldReturnErrorMessageCallbackResponse_1v1_WhenDefendant1LiP_CosDisabled() { - CaseData caseData = CaseDataBuilder.builder() - .atStateClaimIssued1v1LiP() - .build(); - - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(false); - - CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_START); - AboutToStartOrSubmitCallbackResponse response = - (AboutToStartOrSubmitCallbackResponse) handler.handle(params); - - assertThat(response.getErrors()).contains(ERROR_PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT); - } - - @Test - void aboutToStart_ShouldReturnErrorMessageCallbackResponse_1v2WhenDefendant2LiP_CosDisabled() { - CaseData caseData = CaseDataBuilder.builder() - .atStateClaimIssued1v2Respondent2LiP() - .addRespondent2(YesOrNo.YES) - .build(); - - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(false); - - CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_START); - AboutToStartOrSubmitCallbackResponse response = - (AboutToStartOrSubmitCallbackResponse) handler.handle(params); - - assertThat(response.getErrors()).contains(ERROR_PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT); - } - - @Test - void aboutToStart_Should_Not_ReturnErrorMessageCallbackResponse_1v1_WhenDefendant1Represented_CosDisabled() { - CaseData caseData = CaseDataBuilder.builder() - .atStateClaimIssued() - .addRespondent2(YesOrNo.NO) - .build(); - - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(false); - - CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_START); - AboutToStartOrSubmitCallbackResponse response = - (AboutToStartOrSubmitCallbackResponse) handler.handle(params); - - assertNull(response.getErrors()); - } - - @Test - void aboutToStart_ShouldNotReturnErrorMessageCallbackResponse_1v2_BothDefendant1Represented_CosDisabled() { - CaseData caseData = CaseDataBuilder.builder() - .atStateClaimSubmittedTwoRespondentRepresentatives() - .build(); - - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(false); - - CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_START); - AboutToStartOrSubmitCallbackResponse response = - (AboutToStartOrSubmitCallbackResponse) handler.handle(params); - - assertNull(response.getErrors()); - } } @Nested @@ -296,7 +232,6 @@ void should_ThrowError_whenCosServiceDate_is14thDay_afterBusinessDayEndTime() { .build(); when(time.now()).thenReturn(LocalDateTime.of(2021, 5, 15, 16, 05)); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); when(deadlinesCalculator.plus14DaysAt4pmDeadline(cosNotifyDate.atTime(16, 05))) .thenReturn(claimDetailsNotificationDeadline); @@ -341,8 +276,6 @@ void shouldNot_ThrowError_whenCosServiceDate_notOlderThan14Days() { when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(cosNotifyDate.atTime(15, 05))) .thenReturn(cosNotifyDate.plusDays(14).atTime(END_OF_BUSINESS_DAY)); @@ -366,7 +299,6 @@ void shouldNot_ThrowError_whenCosServiceDate_is14thDay_beforeBusinessDayEndTime( .build(); when(time.now()).thenReturn(LocalDateTime.of(2021, 5, 15, 15, 05)); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); when(deadlinesCalculator.plus14DaysAt4pmDeadline(cosNotifyDate.atTime(15, 05))) .thenReturn(claimDetailsNotificationDeadline); @@ -506,7 +438,6 @@ void shouldSetDetailsNotificationDeadline_Cos_1v2_whenLipDefendant1() { LocalDate cosNotifyDate = LocalDate.of(2021, 4, 2); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); when(time.now()).thenReturn(LocalDateTime.of(2021, 5, 3, 15, 05)); when(deadlinesCalculator.plus14DaysAt4pmDeadline(cosNotifyDate.atTime(15, 05))) .thenReturn(claimDetailsNotificationDeadline); @@ -538,7 +469,6 @@ void shouldSetDetailsNotificationDeadline_Cos_1v2_whenLipDefendant1() { void shouldSetDetailsNotificationDeadline_Cos_1v2_whenLipDefendant2() { LocalDate cosNotifyDate = LocalDate.of(2021, 4, 2); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); when(time.now()).thenReturn(LocalDateTime.of(2021, 5, 3, 15, 05)); when(deadlinesCalculator.plus14DaysAt4pmDeadline(cosNotifyDate.atTime(15, 05))) .thenReturn(claimDetailsNotificationDeadline); @@ -573,7 +503,6 @@ void shouldSetDetailsNotificationDeadline_Cos_1v2_bothDefendantsLip_def1Notified LocalDate cosDef2NotifyDate = LocalDate.of(2021, 5, 2); when(time.now()).thenReturn(LocalDateTime.of(2021, 5, 3, 15, 05)); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); when(deadlinesCalculator.plus14DaysAt4pmDeadline(cosDef1NotifyDate.atTime(15, 05))) .thenReturn(claimDetailsNotificationDeadline); @@ -606,7 +535,6 @@ void shouldSetDetailsNotificationDeadline_Cos_1v2_bothDefendantsLip_def2Notified LocalDate cosDef2NotifyDate = LocalDate.of(2021, 4, 28); when(time.now()).thenReturn(LocalDateTime.of(2021, 5, 3, 15, 05)); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); when(deadlinesCalculator.plus14DaysAt4pmDeadline(cosDef2NotifyDate.atTime(15, 05))) .thenReturn(claimDetailsNotificationDeadline); @@ -639,7 +567,6 @@ void shouldSetDetailsNotificationDeadline_Cos_1v2_bothDefendantsLip_sameDates() LocalDate cosDef2NotifyDate = LocalDate.of(2021, 4, 2); when(time.now()).thenReturn(LocalDateTime.of(2021, 5, 3, 15, 05)); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); when(deadlinesCalculator.plus14DaysAt4pmDeadline(cosDef1NotifyDate.atTime(15, 05))) .thenReturn(claimDetailsNotificationDeadline); @@ -670,7 +597,6 @@ void shouldSetDetailsNotificationDeadline_Cos_1v1_whenLipDefendant() { LocalDate cosNotifyDate = LocalDate.of(2021, 4, 26); when(time.now()).thenReturn(LocalDateTime.of(2021, 5, 3, 15, 05)); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); when(deadlinesCalculator.plus14DaysAt4pmDeadline(cosNotifyDate.atTime(15, 05))) .thenReturn(claimDetailsNotificationDeadline); @@ -690,32 +616,6 @@ void shouldSetDetailsNotificationDeadline_Cos_1v1_whenLipDefendant() { assertThat(response.getData()) .containsEntry("claimDetailsNotificationDeadline", expectedDeadline.format(ISO_DATE_TIME)); } - - @Test - void shouldSetDetailsNotificationDeadline_Cos_disabled_1v1_whenLipDefendant() { - - LocalDate cosNotifyDate = LocalDate.of(2021, 4, 2); - - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(false); - - when(deadlinesCalculator.plus14DaysAt4pmDeadline(notifyClaimDateTime)) - .thenReturn(claimDetailsNotificationDeadline); - - CaseData caseData = CaseDataBuilder.builder() - .atStateClaimNotified1v1LiP(CertificateOfService.builder() - .cosDateOfServiceForDefendant(cosNotifyDate) - .build()) - .claimNotificationDeadline(claimNotificationDeadline) - .build(); - CallbackParams params = CallbackParamsBuilder.builder().of( - CallbackType.ABOUT_TO_SUBMIT, - caseData - ).build(); - var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); - - assertThat(response.getData()) - .containsEntry("claimDetailsNotificationDeadline", expectedDeadline.format(ISO_DATE_TIME)); - } } @Nested @@ -899,7 +799,6 @@ void shouldReturnExpectedSubmittedCallbackResponse_Defendant1Lip_whenInvoked() { .builder().cosDateOfServiceForDefendant(LocalDate.now()) .build()) .build(); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); CallbackParams params = callbackParamsOf(caseData, SUBMITTED); SubmittedCallbackResponse response = (SubmittedCallbackResponse) handler.handle(params); @@ -922,7 +821,6 @@ void shouldReturnExpectedSubmittedCallbackResponse_Defendant2Lip_whenInvoked() { .cosDateOfServiceForDefendant(LocalDate.now()) .build()) .build(); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); CallbackParams params = callbackParamsOf(caseData, SUBMITTED); SubmittedCallbackResponse response = (SubmittedCallbackResponse) handler.handle(params); diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java index b9ac78d66d1..56cefd08ece 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java @@ -254,7 +254,6 @@ void shouldUpdateBusinessProcess_whenInvoked1v2DifferentSolicitor() { @Test void shouldUpdateCertificateOfService_and_documents_cos1_whenSubmitted() { - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); LocalDate cosDate = localDateTime.minusDays(2).toLocalDate(); when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); when(deadlinesCalculator.plus14DaysAt4pmDeadline(cosDate.atTime(15, 05))) @@ -278,7 +277,6 @@ void shouldUpdateCertificateOfService_and_documents_cos1_whenSubmitted() { @Test void shouldUpdateCertificateOfService_and_documents_cos2_whenSubmitted() { - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); LocalDate cosDate = localDateTime.minusDays(2).toLocalDate(); when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); when(deadlinesCalculator.plus14DaysAt4pmDeadline(cosDate.atTime(15, 05))) @@ -302,7 +300,6 @@ void shouldUpdateCertificateOfService_and_documents_cos2_whenSubmitted() { @Test void shouldUpdate_to_earliest_day_cos2_is_earliest_whenSubmitted() { - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); LocalDate cos1Date = localDateTime.minusDays(2).toLocalDate(); LocalDate cos2Date = localDateTime.minusDays(3).toLocalDate(); when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); @@ -328,7 +325,6 @@ void shouldUpdate_to_earliest_day_cos2_is_earliest_whenSubmitted() { @Test void shouldUpdate_to_earliest_day_cos1_is_earliest_whenSubmitted() { - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); LocalDate cos1Date = localDateTime.minusDays(3).toLocalDate(); LocalDate cos2Date = localDateTime.minusDays(2).toLocalDate(); when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); @@ -436,7 +432,6 @@ void shouldReturnExpectedSubmittedCallbackResponse_whenInvoked() { @Test void shouldReturnExpectedSubmittedCallbackResponse_with_cos_whenInvoked() { - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); CaseData caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified().build(); CallbackParams params = callbackParamsOf(caseData, SUBMITTED); SubmittedCallbackResponse response = (SubmittedCallbackResponse) handler.handle(params); @@ -499,7 +494,6 @@ void shouldReturnExpectedSubmittedCallbackResponse_whenNotifyingOneParty_whenInv @Test void shouldReturnCoSConfirmation_whenCosNotifyDetailsSuccess() { LocalDate past = LocalDate.now().minusDays(1); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); when(time.now()).thenReturn(LocalDateTime.now()); when(deadlinesCalculator.plus14DaysAt4pmDeadline(any())) .thenReturn(past.plusDays(14).atTime(16, 0)); @@ -515,7 +509,6 @@ void shouldReturnCoSConfirmation_whenCosNotifyDetailsSuccess() { @Test void shouldReturnCoSConfirmation_1Lip1Lr_whenCosNotifyDetailsSuccess() { LocalDate past = LocalDate.now().minusDays(1); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); when(time.now()).thenReturn(LocalDateTime.now()); when(deadlinesCalculator.plus14DaysAt4pmDeadline(any())) .thenReturn(past.plusDays(14).atTime(16, 0)); @@ -535,7 +528,6 @@ class MidEventValidateCos { void shouldPassValidateCertificateOfService_whenDateIsPast() { LocalDate past = LocalDate.now().minusDays(1); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); when(deadlinesCalculator.plus14DaysAt4pmDeadline(any())) .thenReturn(past.plusDays(14).atTime(16, 0)); @@ -556,7 +548,6 @@ void shouldPassValidateCertificateOfService_whenDateIsPast() { void shouldPassValidateCertificateOfService_1Lip1Lr_whenDateIsPast() { LocalDate past = LocalDate.now().minusDays(1); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); when(time.now()).thenReturn(LocalDate.now().atTime(16, 05)); when(deadlinesCalculator.plus14DaysAt4pmDeadline(any())) .thenReturn(past.plusDays(14).atTime(16, 0)); @@ -577,7 +568,6 @@ void shouldPassValidateCertificateOfService_1Lip1Lr_whenDateIsPast() { void shouldPassValidateCertificateOfService_1Lr1Lip_whenServiceDateIsPast_notOlderThan14Days() { LocalDate past = LocalDate.now().minusDays(1); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); when(deadlinesCalculator.plus14DaysAt4pmDeadline(past.atTime(15, 05))) .thenReturn(past.plusDays(14).atTime(16, 0)); @@ -597,7 +587,6 @@ void shouldPassValidateCertificateOfService_1Lr1Lip_whenServiceDateIsPast_notOld void shouldNotPassValidateCertificateOfService_1Lr1Lip_whenServiceDateIsPast_OlderThan14Days() { LocalDate past = LocalDate.now().minusDays(15); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); when(deadlinesCalculator.plus14DaysAt4pmDeadline(past.atTime(15, 05))) .thenReturn(past.plusDays(14).atTime(16, 0)); @@ -617,7 +606,6 @@ void shouldNotPassValidateCertificateOfService_1Lr1Lip_whenServiceDateIsPast_Old void shouldNotPassValidateCertificateOfService_1Lr1Lip_whenServiceDateIsPast_deadlineTodayDate_After16hrs() { LocalDate past = LocalDate.now().minusDays(14); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); when(time.now()).thenReturn(LocalDate.now().atTime(16, 05)); when(deadlinesCalculator.plus14DaysAt4pmDeadline(any())) .thenReturn(past.plusDays(14).atTime(16, 0)); @@ -633,45 +621,11 @@ void shouldNotPassValidateCertificateOfService_1Lr1Lip_whenServiceDateIsPast_dea assertThat(params.getCaseData().getCosNotifyClaimDetails1().getCosDocSaved()).isEqualTo(NO); } - @Test - void shouldIgnoreValidateCertificateOfService_whenDisabled() { - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(false); - when(time.now()).thenReturn(LocalDateTime.now()); - LocalDate past = LocalDate.now().minusDays(1); - LocalDate future = LocalDate.now().plusDays(1); - CaseData caseData = CaseDataBuilder.builder() - .atStateClaimDetailsNotified_1v2_andNotifyBothCoS() - .setCoSClaimDetailsWithDate(true, true, past, future, true, true) - .build(); - CallbackParams params = callbackParamsOf(caseData, MID, "validateCosNotifyClaimDetails2"); - AboutToStartOrSubmitCallbackResponse successResponse = - (AboutToStartOrSubmitCallbackResponse) handler.handle(params); - assertThat(successResponse.getErrors().size()).isEqualTo(0); - } - - @Test - void shouldFailValidateCertificateOfService_whenDateIsFuture() { - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); - when(time.now()).thenReturn(LocalDateTime.now()); - - LocalDate past = LocalDate.now().minusDays(1); - LocalDate future = LocalDate.now().plusDays(1); - CaseData caseData = CaseDataBuilder.builder() - .atStateClaimDetailsNotified_1v2_andNotifyBothCoS() - .setCoSClaimDetailsWithDate(true, true, past, future, true, true) - .build(); - CallbackParams params = callbackParamsOf(caseData, MID, "validateCosNotifyClaimDetails2"); - AboutToStartOrSubmitCallbackResponse successResponse = - (AboutToStartOrSubmitCallbackResponse) handler.handle(params); - assertThat(successResponse.getErrors().size()).isEqualTo(2); - } - @Test void shouldFailValidateCertificateOfService_When1v2LIP_BothDefendant_DifferentDateOfService() { LocalDate def1pastDate = LocalDate.now().minusDays(1); LocalDate def2pastDate = LocalDate.now().minusDays(2); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); when(time.now()).thenReturn(LocalDateTime.now()); when(deadlinesCalculator.plus14DaysAt4pmDeadline(any())) .thenReturn(def2pastDate.plusDays(14).atTime(16, 0)); @@ -688,7 +642,6 @@ void shouldFailValidateCertificateOfService_When1v2LIP_BothDefendant_DifferentDa @Test void shouldNotFailValidateCertificateOfService_When1v2LIP_BothDefendant_SameDateOfService() { - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); when(time.now()).thenReturn(LocalDateTime.now()); LocalDate def1pastDate = LocalDate.now().minusDays(1); @@ -710,7 +663,6 @@ void shouldNotFailValidateCertificateOfService_When1v2LIP_BothDefendant_SameDate @Test void shouldPassValidateCertificateOfService_whenHasFile() { LocalDate past = LocalDate.now().minusDays(1); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); when(time.now()).thenReturn(LocalDateTime.now()); when(deadlinesCalculator.plus14DaysAt4pmDeadline(any())) .thenReturn(past.plusDays(14).atTime(16, 0)); @@ -728,7 +680,6 @@ void shouldPassValidateCertificateOfService_whenHasFile() { @Test void shouldFailValidateCertificateOfService_whenHasNoFile() { LocalDate past = LocalDate.now().minusDays(1); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); when(time.now()).thenReturn(LocalDateTime.now()); when(deadlinesCalculator.plus14DaysAt4pmDeadline(any())) .thenReturn(past.plusDays(14).atTime(16, 0)); diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TransferOnlineCaseCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TransferOnlineCaseCallbackHandlerTest.java index b68d54ff9e8..19f87d67765 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TransferOnlineCaseCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/TransferOnlineCaseCallbackHandlerTest.java @@ -228,4 +228,4 @@ void shouldReturnExpectedSubmittedCallbackResponse() { void handleEventsReturnsTheExpectedCallbackEvent() { assertThat(handler.handledEvents()).contains(CaseEvent.TRANSFER_ONLINE_CASE); } -} +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/event/BundleCreationTriggerEventHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/event/BundleCreationTriggerEventHandlerTest.java index e16bed27992..e413a24bb18 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/event/BundleCreationTriggerEventHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/event/BundleCreationTriggerEventHandlerTest.java @@ -191,8 +191,9 @@ void testSendBundleCreationTriggerDoesNotThrowExceptionWhenItsAllGood() { // Given: Case details with all type of documents require for bundles BundleCreationTriggerEvent event = new BundleCreationTriggerEvent(1L); when(coreCaseDataService.getCase(1L)).thenReturn(caseDetails); - when(coreCaseDataService.startUpdate(event.getCaseId().toString(), CREATE_BUNDLE)) - .thenReturn(StartEventResponse.builder().caseDetails(CaseDetailsBuilder.builder().data(caseData).build()).eventId("event1").token("test").build()); + StartEventResponse response = StartEventResponse.builder() + .caseDetails(CaseDetailsBuilder.builder().data(caseData).build()).eventId("event1").token("test").build(); + when(coreCaseDataService.startUpdate(event.getCaseId().toString(), CREATE_BUNDLE)).thenReturn(response); when(bundleCreationService.createBundle(event)).thenReturn(bundleCreateResponse); when(caseDetailsConverter.toCaseData(anyMap())).thenReturn(caseData); @@ -279,8 +280,9 @@ void verifyBundleNotificationEventTriggeredWhenBundleCreated() { // Given: Case details with all type of documents require for bundles BundleCreationTriggerEvent event = new BundleCreationTriggerEvent(1L); when(coreCaseDataService.getCase(1L)).thenReturn(caseDetails); - when(coreCaseDataService.startUpdate(event.getCaseId().toString(), CREATE_BUNDLE)) - .thenReturn(StartEventResponse.builder().caseDetails(CaseDetailsBuilder.builder().data(caseData).build()).eventId("event1").token("test").build()); + StartEventResponse response = StartEventResponse.builder() + .caseDetails(CaseDetailsBuilder.builder().data(caseData).build()).eventId("event1").token("test").build(); + when(coreCaseDataService.startUpdate(event.getCaseId().toString(), CREATE_BUNDLE)).thenReturn(response); when(bundleCreationService.createBundle(event)).thenReturn(bundleCreateResponse); when(caseDetailsConverter.toCaseData(anyMap())).thenReturn(caseData); @@ -296,8 +298,9 @@ void verifyNoBundleNotificationEventTriggeredWhenBundleNotCreated() { // createBundle service BundleCreationTriggerEvent event = new BundleCreationTriggerEvent(1L); when(coreCaseDataService.getCase(1L)).thenReturn(caseDetails); - when(coreCaseDataService.startUpdate(event.getCaseId().toString(), CREATE_BUNDLE)) - .thenReturn(StartEventResponse.builder().caseDetails(CaseDetailsBuilder.builder().data(caseData).build()).eventId("event1").token("test").build()); + StartEventResponse response = StartEventResponse.builder() + .caseDetails(CaseDetailsBuilder.builder().data(caseData).build()).eventId("event1").token("test").build(); + when(coreCaseDataService.startUpdate(event.getCaseId().toString(), CREATE_BUNDLE)).thenReturn(response); when(bundleCreationService.createBundle(event)).thenThrow(new RuntimeException("Runtime Exception")); when(caseDetailsConverter.toCaseData(anyMap())).thenReturn(caseData); diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/tasks/CaseEventTaskHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/tasks/CaseEventTaskHandlerTest.java index 9be08ccdca7..5fddf8c0714 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/tasks/CaseEventTaskHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/tasks/CaseEventTaskHandlerTest.java @@ -248,8 +248,6 @@ void init() { ); when(mockTask.getAllVariables()).thenReturn(variables); - when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(true); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); } @ParameterizedTest @@ -428,86 +426,6 @@ void shouldHaveCorrectDescription_whenInUnrepresentedDefendantAndUnregisteredSol + "Unregistered defendant solicitor firm: Mr. Sole Trader."); } - @Nested - class ToBeRemovedAfterNOC { - @BeforeEach - public void setup() { - when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(false); - } - - @Test - void prod_shouldHaveCorrectDescription_whenInUnregisteredSolicitorState() { - FlowState.Main state = PENDING_CLAIM_ISSUED_UNREGISTERED_DEFENDANT; - VariableMap variables = Variables.createVariables(); - variables.putValue(FLOW_STATE, state.fullName()); - variables.putValue( - FLOW_FLAGS, - getFlowFlags(state) - ); - - when(mockTask.getVariable(FLOW_STATE)).thenReturn(state.fullName()); - - CaseData caseData = CaseDataBuilder.builder() - .atStatePendingClaimIssuedUnregisteredDefendant() - .businessProcess(BusinessProcess.builder().status(BusinessProcessStatus.READY).build()) - .respondent1OrganisationPolicy(null) - .respondent2OrganisationPolicy(null) - .build(); - - CaseDetails caseDetails = CaseDetailsBuilder.builder().data(caseData).build(); - - when(coreCaseDataService.startUpdate(CASE_ID, PROCEEDS_IN_HERITAGE_SYSTEM)) - .thenReturn(StartEventResponse.builder().caseDetails(caseDetails) - .eventId(PROCEEDS_IN_HERITAGE_SYSTEM.name()).build()); - - when(coreCaseDataService.submitUpdate(eq(CASE_ID), caseDataContentArgumentCaptor.capture())) - .thenReturn(caseData); - - caseEventTaskHandler.execute(mockTask, externalTaskService); - - CaseDataContent caseDataContent = caseDataContentArgumentCaptor.getValue(); - Event event = caseDataContent.getEvent(); - assertThat(event.getDescription()).isEqualTo("Unregistered defendant solicitor firm: Mr. Sole Trader"); - } - - @Test - void prod_shouldHaveCorrectDescription_whenInUnrepresentedDefendantAndUnregisteredSolicitorState() { - FlowState.Main state = PENDING_CLAIM_ISSUED_UNREPRESENTED_UNREGISTERED_DEFENDANT; - VariableMap variables = Variables.createVariables(); - variables.putValue(FLOW_STATE, state.fullName()); - variables.putValue( - FLOW_FLAGS, - getFlowFlags(state) - ); - - when(mockTask.getVariable(FLOW_STATE)).thenReturn(state.fullName()); - - CaseData caseData = CaseDataBuilder.builder() - .atStatePendingClaimIssuedUnrepresentedUnregisteredDefendant() - .businessProcess(BusinessProcess.builder().status(BusinessProcessStatus.READY).build()) - .respondent1OrganisationPolicy(null) - .respondent2OrganisationPolicy(null) - .build(); - CaseDetails caseDetails = CaseDetailsBuilder.builder().data(caseData).build(); - - when(coreCaseDataService.startUpdate(CASE_ID, PROCEEDS_IN_HERITAGE_SYSTEM)) - .thenReturn(StartEventResponse.builder().caseDetails(caseDetails) - .eventId(PROCEEDS_IN_HERITAGE_SYSTEM.name()).build()); - - when(coreCaseDataService.submitUpdate(eq(CASE_ID), caseDataContentArgumentCaptor.capture())) - .thenReturn(caseData); - - caseEventTaskHandler.execute(mockTask, externalTaskService); - - CaseDataContent caseDataContent = caseDataContentArgumentCaptor.getValue(); - Event event = caseDataContent.getEvent(); - assertThat(event.getDescription()) - .isEqualTo("Unrepresented defendant and unregistered defendant solicitor firm. " - + "Unrepresented defendant: Mr. John Rambo. " - + "Unregistered defendant solicitor firm: Mr. Sole Trader."); - } - } - @Nested class FullDefenceProceed { FlowState.Main state = FULL_DEFENCE_PROCEED; @@ -713,12 +631,11 @@ void shouldHaveExpectedDescription_WhenOnlySecondClaimantProceeds() { @NotNull private Map getFlowFlags(FlowState.Main state) { if (state.equals(TAKEN_OFFLINE_AFTER_CLAIM_NOTIFIED) - || state.equals(TAKEN_OFFLINE_AFTER_CLAIM_DETAILS_NOTIFIED)) { + || state.equals(TAKEN_OFFLINE_AFTER_CLAIM_DETAILS_NOTIFIED) + || state.equals(PENDING_CLAIM_ISSUED_UNREGISTERED_DEFENDANT)) { return Map.of("TWO_RESPONDENT_REPRESENTATIVES", true, "ONE_RESPONDENT_REPRESENTATIVE", false, - FlowFlag.NOTICE_OF_CHANGE.name(), true, FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false, - FlowFlag.CERTIFICATE_OF_SERVICE.name(), true, FlowFlag.BULK_CLAIM_ENABLED.name(), false ); } else if (state.equals(TAKEN_OFFLINE_BY_STAFF) @@ -731,15 +648,11 @@ private Map getFlowFlags(FlowState.Main state) { || state.equals(CLAIM_DETAILS_NOTIFIED) || state.equals(NOTIFICATION_ACKNOWLEDGED_TIME_EXTENSION)) { return Map.of("ONE_RESPONDENT_REPRESENTATIVE", true, - FlowFlag.NOTICE_OF_CHANGE.name(), true, FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false, - FlowFlag.CERTIFICATE_OF_SERVICE.name(), true, FlowFlag.BULK_CLAIM_ENABLED.name(), false ); } - return Map.of(FlowFlag.NOTICE_OF_CHANGE.name(), true, - FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false, - FlowFlag.CERTIFICATE_OF_SERVICE.name(), true, + return Map.of(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false, FlowFlag.BULK_CLAIM_ENABLED.name(), false ); } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/tasks/PaymentTaskHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/tasks/PaymentTaskHandlerTest.java index c04cc3b01ac..f9adb659089 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/tasks/PaymentTaskHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/tasks/PaymentTaskHandlerTest.java @@ -87,9 +87,7 @@ void shouldTriggerMakePbaPaymentCCDEvent_whenHandlerIsExecuted() { variables.putValue(FLOW_STATE, "MAIN.CLAIM_SUBMITTED"); variables.putValue(FLOW_FLAGS, Map.of("ONE_RESPONDENT_REPRESENTATIVE", true, FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false, - FlowFlag.NOTICE_OF_CHANGE.name(), false, - FlowFlag.BULK_CLAIM_ENABLED.name(), false, - FlowFlag.CERTIFICATE_OF_SERVICE.name(), false)); + FlowFlag.BULK_CLAIM_ENABLED.name(), false)); CaseDetails caseDetails = CaseDetailsBuilder.builder().data(caseData).build(); diff --git a/src/test/java/uk/gov/hmcts/reform/civil/helpers/bundle/BundleRequestMapperTest.java b/src/test/java/uk/gov/hmcts/reform/civil/helpers/bundle/BundleRequestMapperTest.java index 1e4665f1f00..eaa0e647a85 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/helpers/bundle/BundleRequestMapperTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/helpers/bundle/BundleRequestMapperTest.java @@ -36,6 +36,7 @@ class BundleRequestMapperTest { @InjectMocks private BundleRequestMapper bundleRequestMapper; private static final String TEST_URL = "url"; + private static final String TEST_FILE_TYPE = "Email"; private static final String TEST_FILE_NAME = "testFileName.pdf"; @Test @@ -117,7 +118,7 @@ void testBundleRequestMapperWithAllDocs() { bundleCreateRequest.getCaseDetails().getCaseData().getClaimant1WitnessStatements().get(4).getValue().getDocumentFileName()); assertEquals("Witness Summary cl1Fname 12/12/2023", bundleCreateRequest.getCaseDetails().getCaseData().getClaimant1WitnessStatements().get(5).getValue().getDocumentFileName()); - assertEquals("Documents referred to in statement 1 12/12/2022", + assertEquals("Email referred to in the statement of witness 12/12/2022", bundleCreateRequest.getCaseDetails().getCaseData().getClaimant1WitnessStatements().get(10).getValue().getDocumentFileName()); assertEquals("Expert Evidence expert1 Test 12/01/2023", bundleCreateRequest.getCaseDetails().getCaseData().getClaimant1ExpertEvidence().get(0).getValue().getDocumentFileName()); @@ -168,10 +169,10 @@ private CaseData getCaseData() { .documentHearsayNoticeApp2(getWitnessDocs()) .documentHearsayNoticeRes(getWitnessDocs()) .documentHearsayNoticeRes2(getWitnessDocs()) - .documentReferredInStatement(setupOtherEvidenceDocs()) - .documentReferredInStatementApp2(setupOtherEvidenceDocs()) - .documentReferredInStatementRes(setupOtherEvidenceDocs()) - .documentReferredInStatementRes2(setupOtherEvidenceDocs()) + .documentReferredInStatement(setupOtherEvidenceDocs("witness")) + .documentReferredInStatementApp2(setupOtherEvidenceDocs("witness")) + .documentReferredInStatementRes(setupOtherEvidenceDocs("witness")) + .documentReferredInStatementRes2(setupOtherEvidenceDocs("witness")) .documentExpertReport(getExpertDocs("expert1")) .documentExpertReportApp2(getExpertDocs("expert2")) .documentExpertReportRes(getExpertDocs("expert3")) @@ -192,19 +193,19 @@ private CaseData getCaseData() { .documentEvidenceForTrialApp2(getDocumentEvidenceForTrial()) .documentEvidenceForTrialRes(getDocumentEvidenceForTrial()) .documentEvidenceForTrialRes2(getDocumentEvidenceForTrial()) - .documentCaseSummary(setupOtherEvidenceDocs()) - .documentCaseSummaryApp2(setupOtherEvidenceDocs()) - .documentCaseSummaryRes(setupOtherEvidenceDocs()) - .documentCaseSummaryRes2(setupOtherEvidenceDocs()) - .documentForDisclosure(setupOtherEvidenceDocs()) + .documentCaseSummary(setupOtherEvidenceDocs(null)) + .documentCaseSummaryApp2(setupOtherEvidenceDocs(null)) + .documentCaseSummaryRes(setupOtherEvidenceDocs(null)) + .documentCaseSummaryRes2(setupOtherEvidenceDocs(null)) + .documentForDisclosure(setupOtherEvidenceDocs(null)) .defendantResponseDocuments(getDefendantResponseDocs()) .claimantResponseDocuments(getClaimantResponseDocs()) .dismissalOrderDocStaff(getOrderDoc(DocumentType.DISMISSAL_ORDER)) .generalOrderDocStaff(getOrderDoc(DocumentType.GENERAL_ORDER)) - .documentCosts(setupOtherEvidenceDocs()) - .documentCostsApp2(setupOtherEvidenceDocs()) - .documentCostsRes(setupOtherEvidenceDocs()) - .documentCostsRes2(setupOtherEvidenceDocs()) + .documentCosts(setupOtherEvidenceDocs(null)) + .documentCostsApp2(setupOtherEvidenceDocs(null)) + .documentCostsRes(setupOtherEvidenceDocs(null)) + .documentCostsRes2(setupOtherEvidenceDocs(null)) .systemGeneratedCaseDocuments(setupSystemGeneratedCaseDocs()) .applicant1(Party.builder().individualLastName("lastname").individualFirstName("cl1Fname").partyName( "applicant1").type(Party.Type.INDIVIDUAL).build()) @@ -328,10 +329,12 @@ private List> getDocumentEvidenceForTrial() return otherEvidenceDocs; } - private List> setupOtherEvidenceDocs() { + private List> setupOtherEvidenceDocs(String witnessOptionName) { List> otherEvidenceDocs = new ArrayList<>(); otherEvidenceDocs.add(ElementUtils.element(UploadEvidenceDocumentType .builder() + .witnessOptionName(witnessOptionName) + .typeOfDocument(TEST_FILE_TYPE) .documentUpload(Document.builder().documentBinaryUrl(TEST_URL) .documentFileName(TEST_FILE_NAME).build()) .documentIssuedDate(LocalDate.of(2022, 12, 12)) diff --git a/src/test/java/uk/gov/hmcts/reform/civil/model/CaseDataTest.java b/src/test/java/uk/gov/hmcts/reform/civil/model/CaseDataTest.java index 6652420c25f..9a5eea4a631 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/model/CaseDataTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/model/CaseDataTest.java @@ -1,5 +1,6 @@ package uk.gov.hmcts.reform.civil.model; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import uk.gov.hmcts.reform.ccd.model.Organisation; import uk.gov.hmcts.reform.ccd.model.OrganisationPolicy; @@ -11,6 +12,8 @@ import uk.gov.hmcts.reform.civil.handler.callback.user.spec.show.ResponseOneVOneShowTag; import uk.gov.hmcts.reform.civil.model.citizenui.CaseDataLiP; import uk.gov.hmcts.reform.civil.model.citizenui.ClaimantMediationLip; +import uk.gov.hmcts.reform.civil.model.common.DynamicList; +import uk.gov.hmcts.reform.civil.model.common.DynamicListElement; import uk.gov.hmcts.reform.civil.model.common.Element; import uk.gov.hmcts.reform.civil.model.dq.RecurringExpenseLRspec; import uk.gov.hmcts.reform.civil.model.dq.RecurringIncomeLRspec; @@ -25,6 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static uk.gov.hmcts.reform.civil.documentmanagement.model.DocumentType.DEFENCE_TRANSLATED_DOCUMENT; import static uk.gov.hmcts.reform.civil.enums.RespondentResponseTypeSpec.FULL_ADMISSION; @@ -43,16 +47,16 @@ public class CaseDataTest { @Test public void applicant1Proceed_when1v1() { CaseData caseData = CaseData.builder() - .applicant1ProceedWithClaim(YesOrNo.YES) - .build(); + .applicant1ProceedWithClaim(YesOrNo.YES) + .build(); assertEquals(YesOrNo.YES, caseData.getApplicant1ProceedsWithClaimSpec()); } @Test public void applicant1Proceed_when2v1() { CaseData caseData = CaseData.builder() - .applicant1ProceedWithClaimSpec2v1(YesOrNo.YES) - .build(); + .applicant1ProceedWithClaimSpec2v1(YesOrNo.YES) + .build(); assertEquals(YesOrNo.YES, caseData.getApplicant1ProceedsWithClaimSpec()); } @@ -60,12 +64,12 @@ public void applicant1Proceed_when2v1() { void givenApplicantAgreedToMediation_whenHasClaimantAgreedToFreeMediation_thenTrue() { //Given CaseData caseData = CaseData.builder() - .caseDataLiP(CaseDataLiP.builder() - .applicant1ClaimMediationSpecRequiredLip(ClaimantMediationLip.builder() - .hasAgreedFreeMediation(MediationDecision.Yes) - .build()) - .build()) - .build(); + .caseDataLiP(CaseDataLiP.builder() + .applicant1ClaimMediationSpecRequiredLip(ClaimantMediationLip.builder() + .hasAgreedFreeMediation(MediationDecision.Yes) + .build()) + .build()) + .build(); //When boolean result = caseData.hasClaimantAgreedToFreeMediation(); //Then @@ -86,12 +90,12 @@ void givenNoDataForAgreedToMediation_whenHasClaimantAgreedToFeeMediation_thenFal void givenApplicantDidNotAgreeToFreeMediation_whenHasClaimantAgreedToFeeMediation_thenFalse() { //Given CaseData caseData = CaseData.builder() - .caseDataLiP(CaseDataLiP.builder() - .applicant1ClaimMediationSpecRequiredLip(ClaimantMediationLip.builder() - .hasAgreedFreeMediation(MediationDecision.No) - .build()) - .build()) - .build(); + .caseDataLiP(CaseDataLiP.builder() + .applicant1ClaimMediationSpecRequiredLip(ClaimantMediationLip.builder() + .hasAgreedFreeMediation(MediationDecision.No) + .build()) + .build()) + .build(); //When boolean result = caseData.hasClaimantAgreedToFreeMediation(); //Then @@ -122,11 +126,11 @@ void givenNotOneVTwoTwoLegalRepCaseResponsePartAdmit_whenIsRespondentResponseFul void givenOneVTwoTwoLegalRepCaseRespondent1FullDefence_whenIsRespondentResponseFullDefence_thenFalse() { //Given CaseData caseData = CaseData.builder() - .respondent1(PartyBuilder.builder().build()) - .respondent2(PartyBuilder.builder().build()) - .applicant1(PartyBuilder.builder().build()) - .respondent1ClaimResponseTypeForSpec(FULL_DEFENCE) - .build(); + .respondent1(PartyBuilder.builder().build()) + .respondent2(PartyBuilder.builder().build()) + .applicant1(PartyBuilder.builder().build()) + .respondent1ClaimResponseTypeForSpec(FULL_DEFENCE) + .build(); //When boolean result = caseData.isRespondentResponseFullDefence(); //Then @@ -137,12 +141,12 @@ void givenOneVTwoTwoLegalRepCaseRespondent1FullDefence_whenIsRespondentResponseF void givenOneVTwoTwoLegalRepCaseRespondent1And2FullDefence_whenIsRespondentResponseFullDefence_thenTrue() { //Given CaseData caseData = CaseData.builder() - .respondent1(PartyBuilder.builder().build()) - .respondent2(PartyBuilder.builder().build()) - .applicant1(PartyBuilder.builder().build()) - .respondent1ClaimResponseTypeForSpec(FULL_DEFENCE) - .respondent2ClaimResponseTypeForSpec(FULL_DEFENCE) - .build(); + .respondent1(PartyBuilder.builder().build()) + .respondent2(PartyBuilder.builder().build()) + .applicant1(PartyBuilder.builder().build()) + .respondent1ClaimResponseTypeForSpec(FULL_DEFENCE) + .respondent2ClaimResponseTypeForSpec(FULL_DEFENCE) + .build(); //When boolean result = caseData.isRespondentResponseFullDefence(); //Then @@ -153,10 +157,10 @@ void givenOneVTwoTwoLegalRepCaseRespondent1And2FullDefence_whenIsRespondentRespo void applicant_partAdmitClaimSettled() { //Given CaseData caseData = CaseData.builder() - .respondent1ClaimResponseTypeForSpec(PART_ADMISSION) - .applicant1PartAdmitIntentionToSettleClaimSpec(YesOrNo.YES) - .applicant1PartAdmitConfirmAmountPaidSpec(YesOrNo.YES) - .build(); + .respondent1ClaimResponseTypeForSpec(PART_ADMISSION) + .applicant1PartAdmitIntentionToSettleClaimSpec(YesOrNo.YES) + .applicant1PartAdmitConfirmAmountPaidSpec(YesOrNo.YES) + .build(); //When //Then assertTrue(caseData.isPartAdmitClaimSettled()); @@ -166,10 +170,10 @@ void applicant_partAdmitClaimSettled() { void applicant_partAdmitClaimNotSettled() { //Given CaseData caseData = CaseData.builder() - .respondent1ClaimResponseTypeForSpec(PART_ADMISSION) - .applicant1PartAdmitIntentionToSettleClaimSpec(YesOrNo.YES) - .applicant1PartAdmitConfirmAmountPaidSpec(YesOrNo.NO) - .build(); + .respondent1ClaimResponseTypeForSpec(PART_ADMISSION) + .applicant1PartAdmitIntentionToSettleClaimSpec(YesOrNo.YES) + .applicant1PartAdmitConfirmAmountPaidSpec(YesOrNo.NO) + .build(); //When //Then assertTrue(caseData.isPartAdmitClaimNotSettled()); @@ -179,8 +183,8 @@ void applicant_partAdmitClaimNotSettled() { void applicant_isClaimPartAdmitSpec() { //Given CaseData caseData = CaseData.builder() - .respondent1ClaimResponseTypeForSpec(PART_ADMISSION) - .build(); + .respondent1ClaimResponseTypeForSpec(PART_ADMISSION) + .build(); //When //Then assertTrue(caseData.isPartAdmitClaimSpec()); @@ -190,8 +194,8 @@ void applicant_isClaimPartAdmitSpec() { void applicant_isPartAdmitIntentionToSettleClaim() { //Given CaseData caseData = CaseData.builder() - .applicant1PartAdmitIntentionToSettleClaimSpec(YesOrNo.YES) - .build(); + .applicant1PartAdmitIntentionToSettleClaimSpec(YesOrNo.YES) + .build(); //When //Then assertTrue(caseData.isClaimantIntentionSettlePartAdmit()); @@ -201,8 +205,8 @@ void applicant_isPartAdmitIntentionToSettleClaim() { void applicant_isPartAdmitIntentionNotToSettleClaim() { //Given CaseData caseData = CaseData.builder() - .applicant1PartAdmitIntentionToSettleClaimSpec(YesOrNo.NO) - .build(); + .applicant1PartAdmitIntentionToSettleClaimSpec(YesOrNo.NO) + .build(); //When //Then assertTrue(caseData.isClaimantIntentionNotSettlePartAdmit()); @@ -212,8 +216,8 @@ void applicant_isPartAdmitIntentionNotToSettleClaim() { void applicant_isPartAdmitConfirmAmountPaid() { //Given CaseData caseData = CaseData.builder() - .applicant1PartAdmitConfirmAmountPaidSpec(YesOrNo.YES) - .build(); + .applicant1PartAdmitConfirmAmountPaidSpec(YesOrNo.YES) + .build(); //When //Then assertTrue(caseData.isClaimantConfirmAmountPaidPartAdmit()); @@ -223,8 +227,8 @@ void applicant_isPartAdmitConfirmAmountPaid() { void applicant_isPartAdmitConfirmAmountNotPaid() { //Given CaseData caseData = CaseData.builder() - .applicant1PartAdmitConfirmAmountPaidSpec(YesOrNo.NO) - .build(); + .applicant1PartAdmitConfirmAmountPaidSpec(YesOrNo.NO) + .build(); assertTrue(caseData.isClaimantConfirmAmountNotPaidPartAdmit()); } @@ -232,11 +236,11 @@ void applicant_isPartAdmitConfirmAmountNotPaid() { public void givenRespondentUnrepresentedAndOnevOne_whenIsLRvLipOneVOne_thenTrue() { //Given CaseData caseData = CaseData.builder() - .respondent1Represented(YesOrNo.NO) - .applicant1Represented(YesOrNo.YES) - .respondent1(Party.builder().build()) - .applicant1(Party.builder().build()) - .build(); + .respondent1Represented(YesOrNo.NO) + .applicant1Represented(YesOrNo.YES) + .respondent1(Party.builder().build()) + .applicant1(Party.builder().build()) + .build(); //Then assertTrue(caseData.isLRvLipOneVOne()); } @@ -245,11 +249,11 @@ public void givenRespondentUnrepresentedAndOnevOne_whenIsLRvLipOneVOne_thenTrue( public void givenRespondentRepresentedAndOnevOne_whenIsLRvLipOneVOne_thenFalse() { //Given CaseData caseData = CaseData.builder() - .respondent1Represented(YesOrNo.YES) - .applicant1Represented(YesOrNo.YES) - .respondent1(Party.builder().build()) - .applicant1(Party.builder().build()) - .build(); + .respondent1Represented(YesOrNo.YES) + .applicant1Represented(YesOrNo.YES) + .respondent1(Party.builder().build()) + .applicant1(Party.builder().build()) + .build(); //Then assertFalse(caseData.isLRvLipOneVOne()); } @@ -258,11 +262,11 @@ public void givenRespondentRepresentedAndOnevOne_whenIsLRvLipOneVOne_thenFalse() public void givenApplicantUnrepresentedAndOnevOne_whenIsLRvLipOneVOne_thenFalse() { //Given CaseData caseData = CaseData.builder() - .respondent1Represented(YesOrNo.NO) - .applicant1Represented(YesOrNo.NO) - .respondent1(Party.builder().build()) - .applicant1(Party.builder().build()) - .build(); + .respondent1Represented(YesOrNo.NO) + .applicant1Represented(YesOrNo.NO) + .respondent1(Party.builder().build()) + .applicant1(Party.builder().build()) + .build(); //Then assertFalse(caseData.isLRvLipOneVOne()); } @@ -271,11 +275,11 @@ public void givenApplicantUnrepresentedAndOnevOne_whenIsLRvLipOneVOne_thenFalse( public void givenRespondentUnrepresentedAndApplicantUnrepresentedAndOnevOne_whenIsLipvLipOneVOne_thenTrue() { //Given CaseData caseData = CaseData.builder() - .respondent1Represented(YesOrNo.NO) - .applicant1Represented(YesOrNo.NO) - .respondent1(Party.builder().build()) - .applicant1(Party.builder().build()) - .build(); + .respondent1Represented(YesOrNo.NO) + .applicant1Represented(YesOrNo.NO) + .respondent1(Party.builder().build()) + .applicant1(Party.builder().build()) + .build(); //Then assertTrue(caseData.isLipvLipOneVOne()); } @@ -284,9 +288,9 @@ public void givenRespondentUnrepresentedAndApplicantUnrepresentedAndOnevOne_when public void givenApplicantUnrepresented_whenIsApplicant1NotRepresented_thenTrue() { //Given CaseData caseData = CaseData.builder() - .applicant1Represented(YesOrNo.NO) - .applicant1(Party.builder().build()) - .build(); + .applicant1Represented(YesOrNo.NO) + .applicant1(Party.builder().build()) + .build(); //Then assertTrue(caseData.isApplicant1NotRepresented()); } @@ -295,9 +299,9 @@ public void givenApplicantUnrepresented_whenIsApplicant1NotRepresented_thenTrue( public void givenApplicantRepresented_whenIsApplicant1NotRepresented_thenFalse() { //Given CaseData caseData = CaseData.builder() - .applicant1Represented(YesOrNo.YES) - .applicant1(Party.builder().build()) - .build(); + .applicant1Represented(YesOrNo.YES) + .applicant1(Party.builder().build()) + .build(); //Then assertFalse(caseData.isApplicant1NotRepresented()); } @@ -306,10 +310,10 @@ public void givenApplicantRepresented_whenIsApplicant1NotRepresented_thenFalse() void isClaimantNotSettlePartAdmitClaim_thenTrue() { //Given CaseData caseData = CaseData.builder() - .applicant1PartAdmitConfirmAmountPaidSpec(YesOrNo.NO) - .applicant1PartAdmitIntentionToSettleClaimSpec(YesOrNo.NO) - .applicant1AcceptAdmitAmountPaidSpec(YesOrNo.NO) - .build(); + .applicant1PartAdmitConfirmAmountPaidSpec(YesOrNo.NO) + .applicant1PartAdmitIntentionToSettleClaimSpec(YesOrNo.NO) + .applicant1AcceptAdmitAmountPaidSpec(YesOrNo.NO) + .build(); //When //Then assertTrue(caseData.isClaimantNotSettlePartAdmitClaim()); @@ -319,10 +323,10 @@ void isClaimantNotSettlePartAdmitClaim_thenTrue() { void isClaimantNotSettlePartAdmitClaim_thenFalse() { //Given CaseData caseData = CaseData.builder() - .applicant1PartAdmitConfirmAmountPaidSpec(YesOrNo.YES) - .applicant1PartAdmitIntentionToSettleClaimSpec(YesOrNo.YES) - .applicant1AcceptAdmitAmountPaidSpec(YesOrNo.YES) - .build(); + .applicant1PartAdmitConfirmAmountPaidSpec(YesOrNo.YES) + .applicant1PartAdmitIntentionToSettleClaimSpec(YesOrNo.YES) + .applicant1AcceptAdmitAmountPaidSpec(YesOrNo.YES) + .build(); //When //Then assertFalse(caseData.isClaimantNotSettlePartAdmitClaim()); @@ -332,10 +336,10 @@ void isClaimantNotSettlePartAdmitClaim_thenFalse() { void doesPartPaymentRejectedOrItsFullDefenceResponse_fullDefence() { //Given CaseData caseData = CaseData.builder() - .respondent1ClaimResponseTypeForSpec(RespondentResponseTypeSpec.FULL_DEFENCE) - .applicant1ProceedWithClaim(YesOrNo.YES) - .applicant1ProceedWithClaimSpec2v1(YesOrNo.YES) - .build(); + .respondent1ClaimResponseTypeForSpec(RespondentResponseTypeSpec.FULL_DEFENCE) + .applicant1ProceedWithClaim(YesOrNo.YES) + .applicant1ProceedWithClaimSpec2v1(YesOrNo.YES) + .build(); //When //Then assertEquals(YesOrNo.YES, caseData.doesPartPaymentRejectedOrItsFullDefenceResponse()); @@ -345,10 +349,10 @@ void doesPartPaymentRejectedOrItsFullDefenceResponse_fullDefence() { void doesPartPaymentRejectedOrItsFullDefenceResponse_partAdmitRejectYes() { //Given CaseData caseData = CaseData.builder() - .applicant1PartAdmitConfirmAmountPaidSpec(YesOrNo.NO) - .applicant1PartAdmitIntentionToSettleClaimSpec(YesOrNo.NO) - .applicant1AcceptAdmitAmountPaidSpec(YesOrNo.NO) - .build(); + .applicant1PartAdmitConfirmAmountPaidSpec(YesOrNo.NO) + .applicant1PartAdmitIntentionToSettleClaimSpec(YesOrNo.NO) + .applicant1AcceptAdmitAmountPaidSpec(YesOrNo.NO) + .build(); //When //Then assertEquals(YesOrNo.YES, caseData.doesPartPaymentRejectedOrItsFullDefenceResponse()); @@ -358,10 +362,10 @@ void doesPartPaymentRejectedOrItsFullDefenceResponse_partAdmitRejectYes() { void doesPartPaymentRejectedOrItsFullDefenceResponse_partAdmitRejectNo() { //Given CaseData caseData = CaseData.builder() - .applicant1PartAdmitConfirmAmountPaidSpec(YesOrNo.YES) - .applicant1PartAdmitIntentionToSettleClaimSpec(YesOrNo.YES) - .applicant1AcceptAdmitAmountPaidSpec(YesOrNo.YES) - .build(); + .applicant1PartAdmitConfirmAmountPaidSpec(YesOrNo.YES) + .applicant1PartAdmitIntentionToSettleClaimSpec(YesOrNo.YES) + .applicant1AcceptAdmitAmountPaidSpec(YesOrNo.YES) + .build(); //When //Then assertEquals(YesOrNo.NO, caseData.doesPartPaymentRejectedOrItsFullDefenceResponse()); @@ -371,8 +375,8 @@ void doesPartPaymentRejectedOrItsFullDefenceResponse_partAdmitRejectNo() { void hasDefendantNotAgreedToFreeMediation_Yes() { //Given CaseData caseData = CaseData.builder() - .responseClaimMediationSpecRequired(YesOrNo.YES) - .build(); + .responseClaimMediationSpecRequired(YesOrNo.YES) + .build(); //When //Then assertFalse(caseData.hasDefendantNotAgreedToFreeMediation()); @@ -382,8 +386,8 @@ void hasDefendantNotAgreedToFreeMediation_Yes() { void hasDefendantNotAgreedToFreeMediation_No() { //Given CaseData caseData = CaseData.builder() - .responseClaimMediationSpecRequired(YesOrNo.NO) - .build(); + .responseClaimMediationSpecRequired(YesOrNo.NO) + .build(); //When //Then assertTrue(caseData.hasDefendantNotAgreedToFreeMediation()); @@ -393,8 +397,8 @@ void hasDefendantNotAgreedToFreeMediation_No() { void isFastTrackClaim_thenTrue() { //Given CaseData caseData = CaseData.builder() - .responseClaimTrack(AllocatedTrack.FAST_CLAIM.name()) - .build(); + .responseClaimTrack(AllocatedTrack.FAST_CLAIM.name()) + .build(); //When //Then assertTrue(caseData.isFastTrackClaim()); @@ -404,8 +408,8 @@ void isFastTrackClaim_thenTrue() { void isFastTrackClaim_thenFalse() { //Given CaseData caseData = CaseData.builder() - .responseClaimTrack(AllocatedTrack.SMALL_CLAIM.name()) - .build(); + .responseClaimTrack(AllocatedTrack.SMALL_CLAIM.name()) + .build(); //When //Then assertFalse(caseData.isFastTrackClaim()); @@ -415,8 +419,8 @@ void isFastTrackClaim_thenFalse() { void isSmallClaim_thenTrue() { //Given CaseData caseData = CaseData.builder() - .responseClaimTrack(AllocatedTrack.SMALL_CLAIM.name()) - .build(); + .responseClaimTrack(AllocatedTrack.SMALL_CLAIM.name()) + .build(); //When //Then assertTrue(caseData.isSmallClaim()); @@ -426,8 +430,8 @@ void isSmallClaim_thenTrue() { void isSmallClaim_thenFalse() { //Given CaseData caseData = CaseData.builder() - .responseClaimTrack(AllocatedTrack.FAST_CLAIM.name()) - .build(); + .responseClaimTrack(AllocatedTrack.FAST_CLAIM.name()) + .build(); //When //Then assertFalse(caseData.isSmallClaim()); @@ -437,9 +441,9 @@ void isSmallClaim_thenFalse() { void isRejectWithMediation_thenFalse() { //Given CaseData caseData = CaseData.builder() - .applicant1PartAdmitConfirmAmountPaidSpec(YesOrNo.YES) - .applicant1PartAdmitIntentionToSettleClaimSpec(YesOrNo.YES) - .build(); + .applicant1PartAdmitConfirmAmountPaidSpec(YesOrNo.YES) + .applicant1PartAdmitIntentionToSettleClaimSpec(YesOrNo.YES) + .build(); //When //Then assertFalse(caseData.isRejectWithNoMediation()); @@ -449,9 +453,9 @@ void isRejectWithMediation_thenFalse() { void isRejectWithMediation_thenTrue() { //Given CaseData caseData = CaseData.builder() - .applicant1PartAdmitConfirmAmountPaidSpec(YesOrNo.NO) - .responseClaimMediationSpecRequired(YesOrNo.NO) - .build(); + .applicant1PartAdmitConfirmAmountPaidSpec(YesOrNo.NO) + .responseClaimMediationSpecRequired(YesOrNo.NO) + .build(); //When //Then assertTrue(caseData.isRejectWithNoMediation()); @@ -462,12 +466,12 @@ void shouldGetApplicantOrganisationId_whenOrganisationDetailsArePresent() { //Given String organisationId = "1245"; CaseData caseData = CaseData.builder() - .applicant1OrganisationPolicy(OrganisationPolicy.builder() - .organisation(Organisation.builder() - .organisationID(organisationId) - .build()) - .build()) - .build(); + .applicant1OrganisationPolicy(OrganisationPolicy.builder() + .organisation(Organisation.builder() + .organisationID(organisationId) + .build()) + .build()) + .build(); //When String result = caseData.getApplicantOrganisationId(); //Then @@ -488,7 +492,7 @@ void shouldReturnEmptyString_whenNoOrganisationDetailsArePresent() { void isTranslatedDocumentUploaded_thenFalse() { //Given CaseData caseData = CaseData.builder() - .systemGeneratedCaseDocuments(null).build(); + .systemGeneratedCaseDocuments(null).build(); //When //Then assertFalse(caseData.isTranslatedDocumentUploaded()); @@ -498,7 +502,7 @@ void isTranslatedDocumentUploaded_thenFalse() { void isTranslatedDocumentUploaded_thenTrue() { //Given CaseData caseData = CaseData.builder() - .systemGeneratedCaseDocuments(wrapElements(CaseDocument.builder().documentType(DEFENCE_TRANSLATED_DOCUMENT).build())).build(); + .systemGeneratedCaseDocuments(wrapElements(CaseDocument.builder().documentType(DEFENCE_TRANSLATED_DOCUMENT).build())).build(); //When //Then assertTrue(caseData.isTranslatedDocumentUploaded()); @@ -507,7 +511,7 @@ void isTranslatedDocumentUploaded_thenTrue() { @Test void getSDOOrderDocument_WhenItPresent() { CaseData caseData = CaseData.builder() - .systemGeneratedCaseDocuments(wrapElements(CaseDocument.builder().documentType(SDO_ORDER).build())).build(); + .systemGeneratedCaseDocuments(wrapElements(CaseDocument.builder().documentType(SDO_ORDER).build())).build(); //When Optional> caseDocument = caseData.getSDODocument(); //Then @@ -517,7 +521,7 @@ void getSDOOrderDocument_WhenItPresent() { @Test void getSDOOrderDocument_WhenItsNull() { CaseData caseData = CaseData.builder() - .systemGeneratedCaseDocuments(null).build(); + .systemGeneratedCaseDocuments(null).build(); //When Optional> caseDocument = caseData.getSDODocument(); //Then @@ -527,11 +531,11 @@ void getSDOOrderDocument_WhenItsNull() { void isPartAdmitPayImmediatelyAccepted_thenTrue() { //Given CaseData caseData = CaseData.builder() - .respondent1ClaimResponseTypeForSpec(RespondentResponseTypeSpec.PART_ADMISSION) - .applicant1AcceptAdmitAmountPaidSpec(YES) - .showResponseOneVOneFlag(ResponseOneVOneShowTag.ONE_V_ONE_PART_ADMIT_PAY_IMMEDIATELY) - .caseAccessCategory(SPEC_CLAIM) - .build(); + .respondent1ClaimResponseTypeForSpec(RespondentResponseTypeSpec.PART_ADMISSION) + .applicant1AcceptAdmitAmountPaidSpec(YES) + .showResponseOneVOneFlag(ResponseOneVOneShowTag.ONE_V_ONE_PART_ADMIT_PAY_IMMEDIATELY) + .caseAccessCategory(SPEC_CLAIM) + .build(); //When //Then assertTrue(caseData.isPartAdmitPayImmediatelyAccepted()); @@ -549,16 +553,16 @@ void isPartAdmitPayImmediatelyAccepted_thenFalse() { @Test void shouldReturnTrueWhenResponseIsFullAdmit() { CaseData caseData = CaseData.builder() - .respondent1ClaimResponseTypeForSpec(FULL_ADMISSION) - .build(); + .respondent1ClaimResponseTypeForSpec(FULL_ADMISSION) + .build(); assertTrue(caseData.isFullAdmitClaimSpec()); } @Test void shouldReturnFalseWhenResponseIsNotFullAdmit() { CaseData caseData = CaseData.builder() - .respondent1ClaimResponseTypeForSpec(PART_ADMISSION) - .build(); + .respondent1ClaimResponseTypeForSpec(PART_ADMISSION) + .build(); assertFalse(caseData.isFullAdmitClaimSpec()); } @@ -566,10 +570,10 @@ void shouldReturnFalseWhenResponseIsNotFullAdmit() { void shouldReturnRecurringIncomeForFullAdmitWhenTheyExist() { //Given CaseData caseData = CaseData.builder() - .respondent1ClaimResponseTypeForSpec(FULL_ADMISSION) - .respondent1DQ(Respondent1DQ.builder().respondent1DQRecurringIncomeFA(List.of(element( - RecurringIncomeLRspec.builder().build()))).build()) - .build(); + .respondent1ClaimResponseTypeForSpec(FULL_ADMISSION) + .respondent1DQ(Respondent1DQ.builder().respondent1DQRecurringIncomeFA(List.of(element( + RecurringIncomeLRspec.builder().build()))).build()) + .build(); //When List> results = caseData.getRecurringIncomeForRespondent1(); //Then @@ -580,10 +584,10 @@ void shouldReturnRecurringIncomeForFullAdmitWhenTheyExist() { void shouldReturnRecurringIncomeForNonFullAdmitCaseWhenTheyExist() { //Given CaseData caseData = CaseData.builder() - .respondent1ClaimResponseTypeForSpec(PART_ADMISSION) - .respondent1DQ(Respondent1DQ.builder().respondent1DQRecurringIncome(List.of(element( - RecurringIncomeLRspec.builder().build()))).build()) - .build(); + .respondent1ClaimResponseTypeForSpec(PART_ADMISSION) + .respondent1DQ(Respondent1DQ.builder().respondent1DQRecurringIncome(List.of(element( + RecurringIncomeLRspec.builder().build()))).build()) + .build(); //When List> results = caseData.getRecurringIncomeForRespondent1(); //Then @@ -604,10 +608,10 @@ void shouldReturnNullForRecurringIncomeWhenRespondentDqIsNull() { void shouldReturnRecurringExpensesForFullAdmitWhenTheyExist() { //Given CaseData caseData = CaseData.builder() - .respondent1ClaimResponseTypeForSpec(FULL_ADMISSION) - .respondent1DQ(Respondent1DQ.builder().respondent1DQRecurringExpensesFA(List.of(element( - RecurringExpenseLRspec.builder().build()))).build()) - .build(); + .respondent1ClaimResponseTypeForSpec(FULL_ADMISSION) + .respondent1DQ(Respondent1DQ.builder().respondent1DQRecurringExpensesFA(List.of(element( + RecurringExpenseLRspec.builder().build()))).build()) + .build(); //When List> results = caseData.getRecurringExpensesForRespondent1(); @@ -619,10 +623,10 @@ void shouldReturnRecurringExpensesForFullAdmitWhenTheyExist() { void shouldReturnRecurringExpensesForNonFullAdmitWhenTheyExist() { //Given CaseData caseData = CaseData.builder() - .respondent1ClaimResponseTypeForSpec(PART_ADMISSION) - .respondent1DQ(Respondent1DQ.builder().respondent1DQRecurringExpenses(List.of(element( - RecurringExpenseLRspec.builder().build()))).build()) - .build(); + .respondent1ClaimResponseTypeForSpec(PART_ADMISSION) + .respondent1DQ(Respondent1DQ.builder().respondent1DQRecurringExpenses(List.of(element( + RecurringExpenseLRspec.builder().build()))).build()) + .build(); //When List> results = caseData.getRecurringExpensesForRespondent1(); @@ -668,6 +672,67 @@ void shouldReturnEmptyArrayListOfManageDocumentsIfNull() { assertThat(caseData.getManageDocumentsList()).isEmpty(); } + + @Nested + class GetHearingLocationText { + + @Test + public void shouldReturnNull_whenHearingLocationIsNull() { + CaseData caseData = CaseData.builder().build(); + String actual = caseData.getHearingLocationText(); + + assertNull(actual); + } + + @Test + public void shouldReturnNull_whenHearingLocationValueIsNull() { + CaseData caseData = CaseData.builder() + .hearingLocation(DynamicList.builder().value(DynamicListElement.EMPTY).build()).build(); + String actual = caseData.getHearingLocationText(); + + assertNull(actual); + } + + @Test + public void shouldExpectedString_whenHearingLocationValueLabelIsNotNull() { + CaseData caseData = CaseData.builder() + .hearingLocation(DynamicList.builder().value( + DynamicListElement.dynamicElement("label")).build()).build(); + String actual = caseData.getHearingLocationText(); + + assertEquals("label", actual); + } + + @Test + void shouldReturnTrueWhenRespondentSignSettlementAgreementIsNotNull() { + + //Given + CaseData caseData = CaseDataBuilder.builder() + .caseDataLip(CaseDataLiP.builder().respondentSignSettlementAgreement(YesOrNo.NO).build()) + .build(); + + //When + boolean isRespondentSignSettlementAgreement = caseData.isRespondentSignSettlementAgreement(); + + //Then + assertTrue(isRespondentSignSettlementAgreement); + } + + @Test + void shouldReturnFalseWhenRespondentSignSettlementAgreementIsNull() { + + //Given + CaseData caseData = CaseDataBuilder.builder() + .caseDataLip(CaseDataLiP.builder().build()) + .build(); + + //When + boolean isRespondentSignSettlementAgreement = caseData.isRespondentSignSettlementAgreement(); + + //Then + assertFalse(isRespondentSignSettlementAgreement); + } + } } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/model/citizenui/CcdClaimStatusDashboardFactoryTest.java b/src/test/java/uk/gov/hmcts/reform/civil/model/citizenui/CcdClaimStatusDashboardFactoryTest.java index 4798beaffd0..9995c418d76 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/model/citizenui/CcdClaimStatusDashboardFactoryTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/model/citizenui/CcdClaimStatusDashboardFactoryTest.java @@ -56,7 +56,7 @@ void given_hasResponsePending_whenGetStatus_thenReturnNoResponse() { .respondent1ResponseDeadline(LocalDate.now().plusDays(10).atTime(16, 0, 0)) .build(); - DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher( + DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( claim, featureToggleService)); assertThat(status).isEqualTo(DashboardClaimStatus.NO_RESPONSE); } @@ -68,7 +68,7 @@ void given_isEligibleForCCJ_whenGetStatus_thenReturnEligibleForCCJStatus() { .respondent1ResponseDeadline(LocalDateTime.of(2022, 2, 2, 16, 0)) .build(); - DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher( + DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( claim, featureToggleService)); assertThat(status).isEqualTo(DashboardClaimStatus.ELIGIBLE_FOR_CCJ); } @@ -81,7 +81,7 @@ void given_isEligibleForCCJ_whenGetStatus_thenReturnDefaultJudgementStatus() { .paymentTypeSelection(DJPaymentTypeSelection.IMMEDIATELY) .build(); - DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher( + DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( claim, featureToggleService)); assertThat(status).isEqualTo(DashboardClaimStatus.DEFAULT_JUDGEMENT); } @@ -92,7 +92,7 @@ void given_hasResponseDueToday_whenGetStatus_thenReturnResponseDueNow() { .respondent1ResponseDeadline(LocalDate.now().atTime(10, 0, 0)) .build(); - DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher( + DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( claim, featureToggleService)); assertThat(status).isEqualTo(DashboardClaimStatus.RESPONSE_DUE_NOW); } @@ -104,7 +104,7 @@ void given_moreTimeRequested_whenGetStatus_thenReturnMoreTimeRequested() { .respondent1TimeExtensionDate(LocalDateTime.now().plusDays(30)) .build(); - DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher( + DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( claim, featureToggleService)); assertThat(status).isEqualTo(DashboardClaimStatus.MORE_TIME_REQUESTED); } @@ -113,7 +113,7 @@ void given_moreTimeRequested_whenGetStatus_thenReturnMoreTimeRequested() { void given_responseAdmitPayImmediately_whenGetStatus_thenReturnAdmitPayImmediately() { CaseData claim = getClaimWithFullAdmitResponse(RespondentResponsePartAdmissionPaymentTimeLRspec.IMMEDIATELY); - DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher( + DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( claim, featureToggleService)); assertThat(status).isEqualTo(DashboardClaimStatus.ADMIT_PAY_IMMEDIATELY); } @@ -122,7 +122,7 @@ void given_responseAdmitPayImmediately_whenGetStatus_thenReturnAdmitPayImmediate void given_responseAdmitPayBySetDate_whenGetStatus_thenReturnAdmitPayBySetDate() { CaseData claim = getClaimWithFullAdmitResponse(RespondentResponsePartAdmissionPaymentTimeLRspec.BY_SET_DATE); - DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher( + DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( claim, featureToggleService)); assertThat(status).isEqualTo(DashboardClaimStatus.ADMIT_PAY_BY_SET_DATE); } @@ -131,7 +131,7 @@ void given_responseAdmitPayBySetDate_whenGetStatus_thenReturnAdmitPayBySetDate() void given_responseAdmitPayByInstallments_whenGetStatus_thenReturnAdmitPayByInstallments() { CaseData claim = getClaimWithFullAdmitResponse(RespondentResponsePartAdmissionPaymentTimeLRspec.SUGGESTION_OF_REPAYMENT_PLAN); - DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher( + DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( claim, featureToggleService)); assertThat(status).isEqualTo(DashboardClaimStatus.ADMIT_PAY_INSTALLMENTS); } @@ -145,7 +145,7 @@ void given_claimantConfirmedDefendantPaid_whenGetStatus_thenReturnClaimantAccept .respondent1ClaimResponsePaymentAdmissionForSpec(RespondentResponseTypeSpecPaidStatus.PAID_FULL_OR_MORE_THAN_CLAIMED_AMOUNT) .build(); - DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher( + DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( claim, featureToggleService)); assertThat(status).isEqualTo(DashboardClaimStatus.CLAIMANT_ACCEPTED_STATES_PAID); } @@ -158,7 +158,7 @@ void given_defendantPayedInFull_whenGetStatus_thenReturnSettled() { .respondent1ClaimResponsePaymentAdmissionForSpec(RespondentResponseTypeSpecPaidStatus.PAID_FULL_OR_MORE_THAN_CLAIMED_AMOUNT) .build(); - DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher( + DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( claim, featureToggleService)); assertThat(status).isEqualTo(DashboardClaimStatus.SETTLED); } @@ -171,7 +171,7 @@ void given_claimantAcceptedDefendantResponse_whenGetStatus_thenReturnSettled() { .applicant1AcceptAdmitAmountPaidSpec(YesOrNo.YES) .build(); - DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher( + DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( claim, featureToggleService)); assertThat(status).isEqualTo(DashboardClaimStatus.SETTLED); } @@ -184,7 +184,7 @@ void given_claimantRequestedCountyCourtJudgement_whenGetStatus_thenReturnRequest .applicant1DQ(Applicant1DQ.builder().applicant1DQRequestedCourt(RequestedCourt.builder().build()).build()) .build(); - DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher( + DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( claim, featureToggleService)); assertThat(status).isEqualTo(DashboardClaimStatus.REQUESTED_COUNTRY_COURT_JUDGEMENT); } @@ -198,7 +198,7 @@ void given_claimantAcceptedAdmission_whenGetStatus_thenReturnRelevantStatus() { .defenceAdmitPartPaymentTimeRouteRequired(RespondentResponsePartAdmissionPaymentTimeLRspec.IMMEDIATELY) .applicant1AcceptPartAdmitPaymentPlanSpec(YesOrNo.YES) .build(); - DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher( + DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( claim, featureToggleService)); assertThat(status).isEqualTo(DashboardClaimStatus.CLAIMANT_ACCEPTED_ADMISSION_OF_AMOUNT); } @@ -210,7 +210,7 @@ void given_defendantRespondedWithPartAdmit_whenGetStatus_thenReturnRelevantStatu .respondent1ResponseDate(LocalDateTime.now()) .respondent1ClaimResponseTypeForSpec(RespondentResponseTypeSpec.PART_ADMISSION) .build(); - DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher( + DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( claim, featureToggleService)); assertThat(status).isEqualTo(DashboardClaimStatus.DEFENDANT_PART_ADMIT); } @@ -223,7 +223,7 @@ void given_hearingNoticeDocumentIssued_whenGetStatus_thenReturnHearingFormGenera .documentName("testDoc") .build()).build())) .build(); - DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher( + DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( claim, featureToggleService)); assertThat(status).isEqualTo(DashboardClaimStatus.HEARING_FORM_GENERATED); } @@ -244,7 +244,7 @@ void given_hearingDateForSmallClaimIsAfterToday_and_SDOBeenDrawn_whenGetStatus_m .systemGeneratedCaseDocuments(List.of(document)) .build(); given(featureToggleService.isCaseProgressionEnabled()).willReturn(true); - DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher( + DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( claim, featureToggleService)); assertThat(status).isEqualTo(DashboardClaimStatus.MORE_DETAILS_REQUIRED); } @@ -265,7 +265,7 @@ void given_hearingDateForFastTrackClaimIsAfterToday_and_SDOBeenDrawn_whenGetStat .systemGeneratedCaseDocuments(List.of(document)) .build(); given(featureToggleService.isCaseProgressionEnabled()).willReturn(true); - DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher( + DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( claim, featureToggleService)); assertThat(status).isEqualTo(DashboardClaimStatus.MORE_DETAILS_REQUIRED); } @@ -281,7 +281,7 @@ void given_mediation_whenGetSatus_mediationSuccessful() { .build()) .respondent1ClaimResponseTypeForSpec(PART_ADMISSION) .build(); - DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher( + DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( claim, featureToggleService)); assertThat(status).isEqualTo(DashboardClaimStatus.MEDIATION_SUCCESSFUL); } @@ -296,7 +296,7 @@ void given_mediation_whenGetStatus_mediationUnsuccessful() { .build()) .respondent1ClaimResponseTypeForSpec(PART_ADMISSION) .build(); - DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher( + DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( claim, featureToggleService)); assertThat(status).isEqualTo(DashboardClaimStatus.MEDIATION_UNSUCCESSFUL); } @@ -311,7 +311,7 @@ void given_mediation_whenGetStatus_mediationPending() { .build()) .build()) .build(); - DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher( + DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( claim, featureToggleService)); assertThat(status).isEqualTo(DashboardClaimStatus.IN_MEDIATION); } @@ -324,7 +324,7 @@ void given_court_whenGetStatus_courtReview() { .respondent1ClaimResponseTypeForSpec(RespondentResponseTypeSpec.FULL_DEFENCE) .applicant1ResponseDate(LocalDateTime.now()) .build(); - DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher( + DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( claim, featureToggleService)); assertThat(status).isEqualTo(DashboardClaimStatus.WAITING_COURT_REVIEW); } @@ -337,7 +337,7 @@ void given_respondentFullDefenceAndApplicantNotProceedsWithClaim_whenGetStatus_c .respondent1ClaimResponseTypeForSpec(RespondentResponseTypeSpec.FULL_DEFENCE) .applicant1ResponseDate(LocalDateTime.now()) .build(); - DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher( + DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( claim, featureToggleService)); assertThat(status).isEqualTo(DashboardClaimStatus.CLAIM_ENDED); } @@ -351,7 +351,7 @@ void given_applicantRejectPartialAdmit_whenGetStatus_rejectOffer() { .applicant1AcceptAdmitAmountPaidSpec(YesOrNo.NO) .ccdState(CaseState.JUDICIAL_REFERRAL) .build(); - DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher( + DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( claim, featureToggleService)); assertThat(status).isEqualTo(DashboardClaimStatus.WAITING_COURT_REVIEW); } @@ -380,7 +380,7 @@ void given_SDOBeenDrawn_whenGetStatus_sdoOrderCreatedRequired() { .ccdState(CaseState.CASE_PROGRESSION) .build(); DashboardClaimStatus status = - ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher( + ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( claim, featureToggleService)); assertThat(status).isEqualTo(DashboardClaimStatus.SDO_ORDER_CREATED); } @@ -392,7 +392,7 @@ void given_claimantNotRespondedWithInDeadLine_whenGetStatus_claimEnded() { .applicant1ResponseDeadline(LocalDateTime.now().minusDays(1)) .build(); DashboardClaimStatus status = - ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher( + ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( claim, featureToggleService)); assertThat(status).isEqualTo(DashboardClaimStatus.CLAIM_ENDED); } @@ -405,7 +405,7 @@ void given_claimantRejectsDefendantsPaymentPlan() { .applicant1AcceptPartAdmitPaymentPlanSpec(YesOrNo.NO) .ccdState(CaseState.PROCEEDS_IN_HERITAGE_SYSTEM) .build(); - DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher( + DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( claim, featureToggleService)); assertThat(status).isEqualTo(DashboardClaimStatus.WAITING_COURT_REVIEW); } @@ -421,7 +421,7 @@ void givenClaimStatusInProcessHeritageSystem_WhenGetStatus_thenReturnResponseByP .ccdState(CaseState.PROCEEDS_IN_HERITAGE_SYSTEM) .build(); - DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardClaimMatcher( + DashboardClaimStatus status = ccdClaimStatusDashboardFactory.getDashboardClaimStatus(new CcdDashboardDefendantClaimMatcher( claim, featureToggleService)); assertThat(status).isEqualTo(DashboardClaimStatus.RESPONSE_BY_POST); diff --git a/src/test/java/uk/gov/hmcts/reform/civil/sampledata/CaseDataBuilder.java b/src/test/java/uk/gov/hmcts/reform/civil/sampledata/CaseDataBuilder.java index df35ed83ab4..5e445820d77 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/sampledata/CaseDataBuilder.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/sampledata/CaseDataBuilder.java @@ -37,6 +37,7 @@ import uk.gov.hmcts.reform.civil.enums.sdo.TrialHearingTimeEstimateDJ; import uk.gov.hmcts.reform.civil.handler.callback.user.spec.show.ResponseOneVOneShowTag; import uk.gov.hmcts.reform.civil.enums.sdo.DateToShowToggle; +import uk.gov.hmcts.reform.civil.model.FlightDelayDetails; import uk.gov.hmcts.reform.civil.model.UpdateDetailsForm; import uk.gov.hmcts.reform.civil.model.Address; import uk.gov.hmcts.reform.civil.model.Bundle; @@ -504,6 +505,7 @@ public class CaseDataBuilder { private DynamicList transferCourtLocationList; private String reasonForTransfer; + private FlightDelayDetails flightDelayDetails; public CaseDataBuilder sameRateInterestSelection(SameRateInterestSelection sameRateInterestSelection) { this.sameRateInterestSelection = sameRateInterestSelection; @@ -1863,6 +1865,7 @@ public CaseDataBuilder atStateProceedsOffline1v1UnregisteredDefendant() { addRespondent2 = NO; respondent2 = null; respondent2Represented = null; + respondent2OrgRegistered = null; return this; } @@ -2293,8 +2296,8 @@ public CaseDataBuilder atStateClaimSubmittedNoRespondentRepresented() { atStateClaimSubmitted(); addRespondent2 = YES; respondent2SameLegalRepresentative = NO; - respondent1OrgRegistered = NO; - respondent2OrgRegistered = NO; + respondent1OrgRegistered = null; + respondent2OrgRegistered = null; respondent1Represented = NO; respondent2Represented = NO; respondent2 = PartyBuilder.builder().individual().build().toBuilder().partyID("res-2-party-id").build(); @@ -5189,6 +5192,11 @@ public CaseDataBuilder reasonForTransfer(String reasonForTransfer) { return this; } + public CaseDataBuilder flightDelay(FlightDelayDetails flightDelayDetails) { + this.flightDelayDetails = flightDelayDetails; + return this; + } + public CaseData buildMakePaymentsCaseData() { Organisation orgId = Organisation.builder() .organisationID("OrgId").build(); @@ -5771,7 +5779,7 @@ public CaseDataBuilder withApplicant1Flags(List> flags) { .partyID("res-1-party-id") .flags(Flags.builder() .partyName(applicant1.getPartyName()) - .roleOnCase("Applicant 1") + .roleOnCase("Claimant 1") .details(flags) .build()) .build(); @@ -5784,7 +5792,7 @@ public CaseDataBuilder withApplicant1WitnessFlags() { .lastName("W last") .flags(Flags.builder() .partyName("W First W Last") - .roleOnCase("Applicant 1 Witness") + .roleOnCase("Claimant 1 Witness") .details(flagDetails()) .build()) .build()); @@ -5797,7 +5805,7 @@ public CaseDataBuilder withApplicant1ExpertFlags() { .lastName("E last") .flags(Flags.builder() .partyName("E First E Last") - .roleOnCase("Applicant 1 Expert") + .roleOnCase("Claimant 1 Expert") .details(flagDetails()) .build()) .build()); @@ -5808,7 +5816,7 @@ public CaseDataBuilder withApplicant1LitigationFriendFlags() { this.applicant1LitigationFriend = applicant1LitigationFriend.toBuilder() .flags(Flags.builder() .partyName(applicant1LitigationFriend.getFullName()) - .roleOnCase("Applicant 1 Litigation Friend") + .roleOnCase("Claimant 1 Litigation Friend") .details(flagDetails()) .build()) .build(); @@ -5819,7 +5827,7 @@ public CaseDataBuilder withApplicant2Flags() { this.applicant2 = applicant2.toBuilder() .flags(Flags.builder() .partyName(applicant2.getPartyName()) - .roleOnCase("Applicant 2") + .roleOnCase("Claimant 2") .details(flagDetails()) .build()) .build(); @@ -5832,7 +5840,7 @@ public CaseDataBuilder withApplicant2WitnessFlags() { .lastName("W last") .flags(Flags.builder() .partyName("W First W Last") - .roleOnCase("Applicant 2 Witness") + .roleOnCase("Claimant 2 Witness") .details(flagDetails()) .build()) .build()); @@ -5845,7 +5853,7 @@ public CaseDataBuilder withApplicant2ExpertFlags() { .lastName("E last") .flags(Flags.builder() .partyName("E First E Last") - .roleOnCase("Applicant 2 Expert") + .roleOnCase("Claimant 2 Expert") .details(flagDetails()) .build()) .build()); @@ -5856,7 +5864,7 @@ public CaseDataBuilder withApplicant2LitigationFriendFlags() { this.applicant2LitigationFriend = applicant2LitigationFriend.toBuilder() .flags(Flags.builder() .partyName(applicant2LitigationFriend.getFullName()) - .roleOnCase("Applicant 2 Litigation Friend") + .roleOnCase("Claimant 2 Litigation Friend") .details(flagDetails()) .build()) .build(); @@ -5872,7 +5880,7 @@ public CaseDataBuilder withRespondent1LitigationFriendFlags(List> flags) { .partyID("res-1-party-id") .flags(Flags.builder() .partyName(respondent1.getPartyName()) - .roleOnCase("Respondent 1") + .roleOnCase("Defendant 1") .details(flags) .build()) .build(); @@ -5903,7 +5911,7 @@ public CaseDataBuilder withRespondent1WitnessFlags() { .lastName("W last") .flags(Flags.builder() .partyName("W First W Last") - .roleOnCase("Respondent 1 Witness") + .roleOnCase("Defendant 1 Witness") .details(flagDetails()) .build()) .build()); @@ -5918,7 +5926,7 @@ public CaseDataBuilder withRespondent1ExpertFlags() { .lastName("E last") .flags(Flags.builder() .partyName("E First E Last") - .roleOnCase("Respondent 1 Expert") + .roleOnCase("Defendant 1 Expert") .details(flagDetails()) .build()) .build()); @@ -5929,7 +5937,7 @@ public CaseDataBuilder withRespondent2Flags() { this.respondent2 = respondent2.toBuilder() .flags(Flags.builder() .partyName(respondent2.getPartyName()) - .roleOnCase("Respondent 2") + .roleOnCase("Defendant 2") .details(flagDetails()) .build()) .build(); @@ -5942,7 +5950,7 @@ public CaseDataBuilder withRespondent2ExpertFlags() { .lastName("E last") .flags(Flags.builder() .partyName("E First E Last") - .roleOnCase("Respondent 2 Expert") + .roleOnCase("Defendant 2 Expert") .details(flagDetails()) .build()) .build()); @@ -5955,7 +5963,7 @@ public CaseDataBuilder withRespondent2WitnessFlags() { .lastName("W last") .flags(Flags.builder() .partyName("W First W Last") - .roleOnCase("Respondent 2 Witness") + .roleOnCase("Defendant 2 Witness") .details(flagDetails()) .build()) .build()); @@ -5966,7 +5974,7 @@ public CaseDataBuilder withRespondent2LitigationFriendFlags() { this.respondent2LitigationFriend = respondent2LitigationFriend.toBuilder() .flags(Flags.builder() .partyName(respondent2LitigationFriend.getFullName()) - .roleOnCase("Respondent 2 Litigation Friend") + .roleOnCase("Defendant 2 Litigation Friend") .details(flagDetails()) .build()) .build(); @@ -6544,6 +6552,7 @@ public CaseData build() { .drawDirectionsOrderRequired(drawDirectionsOrderRequired) .transferCourtLocationList(transferCourtLocationList) .reasonForTransfer(reasonForTransfer) + .applicant1LRIndividuals(applicant1LRIndividuals) .respondent1LRIndividuals(respondent1LRIndividuals) .respondent2LRIndividuals(respondent2LRIndividuals) @@ -6551,6 +6560,7 @@ public CaseData build() { .applicant2OrgIndividuals(applicant2OrgIndividuals) .respondent1OrgIndividuals(respondent1OrgIndividuals) .respondent2OrgIndividuals(respondent2OrgIndividuals) + .flightDelayDetails(flightDelayDetails) .build(); } } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/sampledata/CaseDataBuilderSpec.java b/src/test/java/uk/gov/hmcts/reform/civil/sampledata/CaseDataBuilderSpec.java index bb94bb5256d..747d17d86f9 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/sampledata/CaseDataBuilderSpec.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/sampledata/CaseDataBuilderSpec.java @@ -354,8 +354,8 @@ public CaseDataBuilderSpec atStateSpec1v2BothDefendantUnrepresentedClaimSubmitte respondent2 = PartyBuilder.builder().individual().build(); respondent1Represented = NO; respondent2Represented = NO; - respondent1OrgRegistered = NO; - respondent2OrgRegistered = NO; + respondent1OrgRegistered = null; + respondent2OrgRegistered = null; return this; } @@ -392,7 +392,7 @@ public CaseDataBuilderSpec atStateSpec1v2OneDefendantRepresentedUnregisteredOthe addRespondent2 = YES; respondent2 = PartyBuilder.builder().individual().build(); respondent1Represented = NO; - respondent1OrgRegistered = NO; + respondent1OrgRegistered = null; respondent2Represented = YES; respondent2OrgRegistered = NO; return this; diff --git a/src/test/java/uk/gov/hmcts/reform/civil/sampledata/CaseDataBuilderUnspec.java b/src/test/java/uk/gov/hmcts/reform/civil/sampledata/CaseDataBuilderUnspec.java index c8157be2880..2fb122ed673 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/sampledata/CaseDataBuilderUnspec.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/sampledata/CaseDataBuilderUnspec.java @@ -310,8 +310,8 @@ public CaseDataBuilderUnspec atState1v2BothDefendantUnrepresentedClaimSubmitted( respondent2 = PartyBuilder.builder().individual().build(); respondent1Represented = NO; respondent2Represented = NO; - respondent1OrgRegistered = NO; - respondent2OrgRegistered = NO; + respondent1OrgRegistered = null; + respondent2OrgRegistered = null; return this; } @@ -348,7 +348,7 @@ public CaseDataBuilderUnspec atState1v2OneDefendantRepresentedUnregisteredOtherU addRespondent2 = YES; respondent2 = PartyBuilder.builder().individual().build(); respondent1Represented = NO; - respondent1OrgRegistered = NO; + respondent1OrgRegistered = null; respondent2Represented = YES; respondent2OrgRegistered = YES; return this; diff --git a/src/test/java/uk/gov/hmcts/reform/civil/sampledata/GeneralApplicationDetailsBuilder.java b/src/test/java/uk/gov/hmcts/reform/civil/sampledata/GeneralApplicationDetailsBuilder.java index cdd3e35fc73..0caef94ebf2 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/sampledata/GeneralApplicationDetailsBuilder.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/sampledata/GeneralApplicationDetailsBuilder.java @@ -1588,6 +1588,7 @@ public CaseData getVaryJudgmentWithN245TestData() { .ccdCaseReference(1L) .applicant1(Party.builder().type(Party.Type.COMPANY).companyName("Applicant1").build()) .respondent1(Party.builder().type(Party.Type.COMPANY).companyName("Respondent1").build()) + .addRespondent2(NO) .courtLocation(CourtLocation.builder() .caseLocation(CaseLocationCivil.builder() .region("2") diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/AirlineEpimsDataLoaderTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/AirlineEpimsDataLoaderTest.java new file mode 100644 index 00000000000..7b8b2e07427 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/AirlineEpimsDataLoaderTest.java @@ -0,0 +1,27 @@ +package uk.gov.hmcts.reform.civil.service; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.BeforeEach; +import org.springframework.boot.test.context.SpringBootTest; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +@SpringBootTest(classes = {AirlineEpimsDataLoader.class}) +class AirlineEpimsDataLoaderTest { + + private AirlineEpimsDataLoader airlineEpimsDataLoader; + + @BeforeEach + public void setUp() { + airlineEpimsDataLoader = new AirlineEpimsDataLoader(); + airlineEpimsDataLoader.init(); + } + + @Test + void shouldGetAnAirlineEpimsList() { + String airline = airlineEpimsDataLoader.getAirlineEpimsIDList().get(0).getAirline(); + String epimsID = airlineEpimsDataLoader.getAirlineEpimsIDList().get(0).getEpimsID(); + assertEquals("Aegean", airline); + assertEquals("298828", epimsID); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/AirlineEpimsServiceTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/AirlineEpimsServiceTest.java new file mode 100644 index 00000000000..ccbfcd2b902 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/AirlineEpimsServiceTest.java @@ -0,0 +1,64 @@ +package uk.gov.hmcts.reform.civil.service; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import uk.gov.hmcts.reform.civil.model.AirlineEpimsId; +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.mockito.BDDMockito.given; + +@SpringBootTest(classes = {AirlineEpimsService.class}) +class AirlineEpimsServiceTest { + + @MockBean + private AirlineEpimsDataLoader airlineEpimsDataLoader; + + private AirlineEpimsService airlineEpimsService; + + @BeforeEach + void setup() { + List airlineEpimsIDList = new ArrayList<>(); + airlineEpimsIDList.add(AirlineEpimsId.builder().airline("Gulf Air").epimsID("36791").build()); + airlineEpimsIDList.add(AirlineEpimsId.builder().airline("NoLocationAirline").build()); + + given(airlineEpimsDataLoader.getAirlineEpimsIDList()) + .willReturn(airlineEpimsIDList); + } + + @Test + void getEpimsIdForAirline_shouldReturnCorrespondingEpimsIdForAirline() { + // Given + airlineEpimsService = new AirlineEpimsService(airlineEpimsDataLoader); + + // When + String result = airlineEpimsService.getEpimsIdForAirline("Gulf Air"); + + // Then + assertThat(result).isEqualTo("36791"); + } + + @Test + void getEpimsIdForAirline_givenInvalidAirline_shouldThrowException() { + // Given + airlineEpimsService = new AirlineEpimsService(airlineEpimsDataLoader); + + // Then + assertThatExceptionOfType(IllegalStateException.class) + .isThrownBy(() -> airlineEpimsService.getEpimsIdForAirline("INVALID_AIRLINE")); + } + + @Test + void getEpimsIdForAirline_givenNoLocationAirline_shouldThrowException() { + // Given + airlineEpimsService = new AirlineEpimsService(airlineEpimsDataLoader); + + // Then + assertThatExceptionOfType(IllegalStateException.class) + .isThrownBy(() -> airlineEpimsService.getEpimsIdForAirline("NoLocationAirline")); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/AuthorisationServiceTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/AuthorisationServiceTest.java new file mode 100644 index 00000000000..1a7680539bf --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/AuthorisationServiceTest.java @@ -0,0 +1,99 @@ +package uk.gov.hmcts.reform.civil.service; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.test.util.ReflectionTestUtils; +import uk.gov.hmcts.reform.authorisation.ServiceAuthorisationApi; +import uk.gov.hmcts.reform.idam.client.IdamClient; +import uk.gov.hmcts.reform.idam.client.models.UserInfo; + +import java.util.Arrays; +import java.util.UUID; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +@ExtendWith(MockitoExtension.class) +public class AuthorisationServiceTest { + + @InjectMocks + AuthorisationService authorisationService; + + @Mock + ServiceAuthorisationApi serviceAuthorisationApi; + + @Mock + IdamClient idamClient; + + @BeforeEach + public void setup() { + ReflectionTestUtils.setField(authorisationService, "s2sAuthorisedServices", Arrays.asList("payment_app")); + } + + @Test + public void authoriseWhenTheServiceIsCalledFromPayment() { + + when(serviceAuthorisationApi.getServiceName(any())).thenReturn("payment_app"); + assertTrue(authorisationService.authoriseService("Bearer abcasda")); + + } + + @Test + public void authoriseWhenTheServiceAuthHeaderIsNull() { + assertFalse(authorisationService.authoriseService(null)); + } + + @Test + public void doNotAuthoriseWhenTheServiceIsCalledFromUnknownApi() { + when(serviceAuthorisationApi.getServiceName(any())).thenReturn("unknown_api"); + assertFalse(authorisationService.authoriseService("Bearer abc")); + + } + + @Test + public void throwUnAuthorisedExceptionWhenS2sTokenIsMalformed() { + assertFalse(authorisationService.authoriseService("Bearer malformed")); + } + + @Test + public void authoriseUserTheServiceIsCalledWithValidToken() { + when(idamClient.getUserInfo(any())).thenReturn(UserInfo.builder().uid(UUID.randomUUID().toString()).build()); + assertTrue(authorisationService.authoriseUser("Bearer abcasda")); + } + + @Test + public void authoriseUserTheServiceIsCalledWithNullToken() { + assertFalse(authorisationService.authoriseUser(null)); + } + + @Test + public void doNotAuthoriseUserWhenCalledWithInvalidToken() { + assertFalse(authorisationService.authoriseUser("Bearer malformed")); + } + + @Test + public void checkIsAuthorizedForUserAndServiceReturnTrue() { + when(idamClient.getUserInfo(any())).thenReturn(UserInfo.builder().uid(UUID.randomUUID().toString()).build()); + when(serviceAuthorisationApi.getServiceName(any())).thenReturn("payment_app"); + assertTrue(authorisationService.isServiceAndUserAuthorized("Bearer abcasda", "s2s token")); + } + + @Test + public void checkIsAuthorizedForUserAndServiceReturnFalse() { + when(idamClient.getUserInfo(any())).thenReturn(UserInfo.builder().uid(UUID.randomUUID().toString()).build()); + when(serviceAuthorisationApi.getServiceName(any())).thenReturn("unknown_api"); + assertFalse(authorisationService.isServiceAndUserAuthorized("Bearer abcasda", "s2s token")); + } + + @Test + public void checkIsAuthorizedForServiceReturnFalse() { + when(serviceAuthorisationApi.getServiceName(any())).thenReturn("unknown_api"); + assertFalse(authorisationService.isServiceAuthorized("s2s token")); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/CaseNoteServiceTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/CaseNoteServiceTest.java index 5cb2b9f02ac..715cb1080f1 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/CaseNoteServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/CaseNoteServiceTest.java @@ -6,8 +6,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; +import uk.gov.hmcts.reform.civil.documentmanagement.model.Document; import uk.gov.hmcts.reform.civil.model.CaseNote; import uk.gov.hmcts.reform.civil.model.common.Element; +import uk.gov.hmcts.reform.civil.model.documents.DocumentAndNote; +import uk.gov.hmcts.reform.civil.model.documents.DocumentWithName; import uk.gov.hmcts.reform.idam.client.IdamClient; import uk.gov.hmcts.reform.idam.client.models.UserDetails; @@ -95,6 +98,34 @@ void shouldAddNoteToListWithNewestAtTop_WhenExistingNotes() { assertThat(unwrapElements(caseNotes)).isEqualTo(List.of(newNote, oldNote)); } + + @Test + void shouldBuildJudgeNote_whenInvokedAndDocumentAndNote() { + Document document = Document.builder().documentFileName("fileName").build(); + DocumentAndNote testDocument = DocumentAndNote.builder().documentName("testDocument").document(document).documentNote("Note").build(); + when(idamClient.getUserDetails(BEARER_TOKEN)).thenReturn(USER_DETAILS); + + var builtDoc = caseNoteService.buildJudgeCaseNoteAndDocument(testDocument, BEARER_TOKEN); + + assertThat(builtDoc.get(0).getValue().getDocumentName()).isEqualTo("testDocument");; + assertThat(builtDoc.get(0).getValue().getDocument()).isEqualTo(document); + assertThat(builtDoc.get(0).getValue().getDocumentNote()).isEqualTo("Note"); + assertThat(builtDoc.get(0).getValue().getCreatedBy()).isEqualTo("John Smith");; + } + + @Test + void shouldBuildJudgeNote_whenInvokedAndDocumentAndName() { + Document document = Document.builder().documentFileName("fileName").build(); + DocumentWithName testDocument = DocumentWithName.builder().documentName("testDocument").document(document).build(); + when(idamClient.getUserDetails(BEARER_TOKEN)).thenReturn(USER_DETAILS); + + var builtDoc = caseNoteService.buildJudgeCaseNoteDocumentAndName(testDocument, BEARER_TOKEN); + + assertThat(builtDoc.get(0).getValue().getDocumentName()).isEqualTo("testDocument");; + assertThat(builtDoc.get(0).getValue().getDocument()).isEqualTo(document); + assertThat(builtDoc.get(0).getValue().getCreatedBy()).isEqualTo("John Smith");; + } + } private CaseNote caseNoteForToday(String note) { diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/FeatureToggleServiceTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/FeatureToggleServiceTest.java index 764bd837d0b..3563aef0920 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/FeatureToggleServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/FeatureToggleServiceTest.java @@ -33,15 +33,6 @@ void shouldReturnCorrectValue_whenMyFeatureIsEnabledOrDisabled(Boolean toggleSta assertThat(featureToggleService.isFeatureEnabled("myFeature")).isEqualTo(toggleState); } - @ParameterizedTest - @ValueSource(booleans = {true, false}) - void shouldReturnCorrectValue_whenIsNoticeOfChangeEnabledInvoked(Boolean toggleState) { - var noticeOfChangeKey = "notice-of-change"; - givenToggle(noticeOfChangeKey, toggleState); - - assertThat(featureToggleService.isNoticeOfChangeEnabled()).isEqualTo(toggleState); - } - @ParameterizedTest @ValueSource(booleans = {true, false}) void shouldReturnCorrectValue_whenAutomatedHearingNoticeEnabledInvoked(Boolean toggleStat) { @@ -78,15 +69,6 @@ void shouldReturnCorrectValue_whenIsPinInPostEnabledInvoked(Boolean toggleStat) assertThat(featureToggleService.isPinInPostEnabled()).isEqualTo(toggleStat); } - @ParameterizedTest - @ValueSource(booleans = {true, false}) - void shouldReturnCorrectValue_whenIsCertificateOfServiceEnabledInvoked(Boolean toggleStat) { - var certificateOfServiceKey = "isCertificateOfServiceEnabled"; - givenToggle(certificateOfServiceKey, toggleStat); - - assertThat(featureToggleService.isCertificateOfServiceEnabled()).isEqualTo(toggleStat); - } - @ParameterizedTest @ValueSource(booleans = {true, false}) void shouldReturnCorrectValue_whenIsPbaV3EnabledInvoked(Boolean toggleStat) { diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/RepresentativeServiceTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/RepresentativeServiceTest.java index 6f0b54ba275..c2cba69a173 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/RepresentativeServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/RepresentativeServiceTest.java @@ -29,7 +29,6 @@ import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoInteractions; -import static org.mockito.Mockito.when; import static uk.gov.hmcts.reform.civil.enums.CaseCategory.SPEC_CLAIM; @SpringBootTest(classes = { @@ -122,10 +121,6 @@ void setup() { @Nested class GetRespondent1Representative { - @BeforeEach - public void setup() { - when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(true); - } @Test void shouldReturnValidOrganisationDetails_whenDefendantIsRepresented() { @@ -331,10 +326,6 @@ void prod_shouldReturnEmptyRepresentative_whenDefendantSolicitorIsNotRegistered( @Nested class GetRespondent2Representative { - @BeforeEach - public void setup() { - when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(true); - } @Test void shouldReturnValidOrganisationDetails_whenDefendantIsRepresented() { @@ -468,54 +459,6 @@ void shouldReturnValidOrganisationDetails_whenOrganisationIDIsEmpty() { respondent2ContactInformation.getPostCode() ); } - - @Nested - class ToBeRemovedAfterNOC { - @BeforeEach - public void setup() { - when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(false); - } - - @Test - void prod_shouldReturnValidOrganisationDetails_whenDefendantIsNotRepresented() { - CaseData caseData = CaseDataBuilder.builder() - .atStatePendingClaimIssuedUnrepresentedDefendant() - .respondent1OrganisationPolicy(null) - .respondent2OrganisationPolicy(null) - .multiPartyClaimTwoDefendantSolicitors().build(); - - Representative representative = representativeService.getRespondent2Representative(caseData); - - verifyNoInteractions(organisationService); - assertThat(representative).extracting( - "organisationName", "phoneNumber", "dxAddress", "emailAddress").containsExactly( - null, - null, - null, - null - ); - assertThat(representative).extracting("serviceAddress").isNull(); - - } - - @Test - void prod_shouldReturnEmptyRepresentative_whenDefendantSolicitorIsNotRegistered() { - CaseData caseData = CaseDataBuilder.builder() - .atStatePendingClaimIssuedUnregisteredDefendant() - .respondent1OrganisationPolicy(null) - .respondent2OrganisationPolicy(null) - .multiPartyClaimTwoDefendantSolicitors().build(); - - Representative representative = representativeService.getRespondent2Representative(caseData); - - verifyNoInteractions(organisationService); - assertThat(representative).extracting( - "organisationName", "phoneNumber", "dxAddress", "emailAddress").containsExactly( - null, null, null, null - ); - assertThat(representative).extracting("serviceAddress").isNull(); - } - } } @Nested diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/caseprogression/JudgeFinalOrderGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/caseprogression/JudgeFinalOrderGeneratorTest.java index 4df8a53ee4d..c1c79423304 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/caseprogression/JudgeFinalOrderGeneratorTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/caseprogression/JudgeFinalOrderGeneratorTest.java @@ -1,6 +1,7 @@ package uk.gov.hmcts.reform.civil.service.docmosis.caseprogression; import com.fasterxml.jackson.core.JsonProcessingException; +import lombok.SneakyThrows; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -35,6 +36,7 @@ import uk.gov.hmcts.reform.civil.model.common.DynamicList; import uk.gov.hmcts.reform.civil.model.common.DynamicListElement; import uk.gov.hmcts.reform.civil.model.common.MappableObject; +import uk.gov.hmcts.reform.civil.model.defaultjudgment.CaseLocationCivil; import uk.gov.hmcts.reform.civil.model.docmosis.DocmosisDocument; import uk.gov.hmcts.reform.civil.model.finalorders.AppealChoiceSecondDropdown; @@ -52,11 +54,13 @@ import uk.gov.hmcts.reform.civil.model.finalorders.OrderMadeOnDetails; import uk.gov.hmcts.reform.civil.model.finalorders.OrderMadeOnDetailsOrderWithoutNotice; import uk.gov.hmcts.reform.civil.model.finalorders.TrialNoticeProcedure; +import uk.gov.hmcts.reform.civil.referencedata.LocationRefDataException; import uk.gov.hmcts.reform.civil.referencedata.LocationRefDataService; import uk.gov.hmcts.reform.civil.referencedata.model.LocationRefData; import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; import uk.gov.hmcts.reform.civil.sampledata.CaseDocumentBuilder; import uk.gov.hmcts.reform.civil.sampledata.PartyBuilder; +import uk.gov.hmcts.reform.civil.service.FeatureToggleService; import uk.gov.hmcts.reform.civil.service.docmosis.DocumentGeneratorService; import uk.gov.hmcts.reform.civil.service.docmosis.DocumentHearingLocationHelper; import uk.gov.hmcts.reform.civil.utils.MonetaryConversions; @@ -75,8 +79,11 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static uk.gov.hmcts.reform.civil.documentmanagement.model.DocumentType.JUDGE_FINAL_ORDER; @@ -104,6 +111,7 @@ public class JudgeFinalOrderGeneratorTest { private static final String DATE_FORMAT = "dd/MM/yyyy"; private static final String fileFreeForm = format(FREE_FORM_ORDER_PDF.getDocumentTitle(), formatLocalDate(LocalDate.now(), DATE_FORMAT)); private static final String assistedForm = format(ASSISTED_ORDER_PDF.getDocumentTitle(), formatLocalDate(LocalDate.now(), DATE_FORMAT)); + private static final CaseLocationCivil caseManagementLocation = CaseLocationCivil.builder().baseLocation("000000").build(); List toggleList = new ArrayList(Arrays.asList(FinalOrderToggle.SHOW)); private static final CaseDocument FREE_FROM_ORDER = CaseDocumentBuilder.builder() .documentName(fileFreeForm) @@ -127,6 +135,8 @@ public class JudgeFinalOrderGeneratorTest { private DocumentHearingLocationHelper locationHelper; @Autowired private JudgeFinalOrderGenerator generator; + @MockBean + FeatureToggleService featureToggleService; private static LocationRefData locationRefData = LocationRefData.builder().siteName("SiteName") .courtAddress("1").postcode("1") @@ -144,6 +154,29 @@ public void setUp() throws JsonProcessingException { when(locationHelper.getHearingLocation(any(), any(), any())).thenReturn(locationRefData); when(locationRefDataService.getCcmccLocation(any())).thenReturn(locationRefData); + when(locationRefDataService.getCourtLocationsByEpimmsId(anyString(), anyString())).thenReturn(List.of( + locationRefData + )); + when(featureToggleService.isHmcEnabled()).thenReturn(true); + } + + @Test + void shouldGenerateFreeFormOrder_whenHmcToggleDisabled() { + when(featureToggleService.isHmcEnabled()).thenReturn(false); + when(documentGeneratorService.generateDocmosisDocument(any(MappableObject.class), eq(FREE_FORM_ORDER_PDF))) + .thenReturn(new DocmosisDocument(FREE_FORM_ORDER_PDF.getDocumentTitle(), bytes)); + when(documentManagementService + .uploadDocument(BEARER_TOKEN, new PDF(fileFreeForm, bytes, JUDGE_FINAL_ORDER))) + .thenReturn(FREE_FROM_ORDER); + + CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() + .finalOrderSelection(FinalOrderSelection.FREE_FORM_ORDER) + .build(); + CaseDocument caseDocument = generator.generate(caseData, BEARER_TOKEN); + + assertNotNull(caseDocument); + verify(documentManagementService) + .uploadDocument(BEARER_TOKEN, new PDF(fileFreeForm, bytes, JUDGE_FINAL_ORDER)); } @Test @@ -156,10 +189,12 @@ void shouldGenerateFreeFormOrder_whenNoneSelected() { CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() .finalOrderSelection(FinalOrderSelection.FREE_FORM_ORDER) + .caseManagementLocation(caseManagementLocation) .build(); CaseDocument caseDocument = generator.generate(caseData, BEARER_TOKEN); assertNotNull(caseDocument); + verify(locationRefDataService).getCourtLocationsByEpimmsId(BEARER_TOKEN, caseManagementLocation.getBaseLocation()); verify(documentManagementService) .uploadDocument(BEARER_TOKEN, new PDF(fileFreeForm, bytes, JUDGE_FINAL_ORDER)); } @@ -175,10 +210,12 @@ void shouldGenerateFreeFormOrder_whenClaimantAndDefendantReferenceNotAddedToCase CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() .solicitorReferences(null) .finalOrderSelection(FinalOrderSelection.FREE_FORM_ORDER) + .caseManagementLocation(caseManagementLocation) .build(); CaseDocument caseDocument = generator.generate(caseData, BEARER_TOKEN); assertNotNull(caseDocument); + verify(locationRefDataService).getCourtLocationsByEpimmsId(BEARER_TOKEN, caseManagementLocation.getBaseLocation()); verify(documentManagementService) .uploadDocument(BEARER_TOKEN, new PDF(fileFreeForm, bytes, JUDGE_FINAL_ORDER)); } @@ -195,10 +232,12 @@ void shouldGenerateFreeFormOrder_whenOrderOnCourtInitiativeSelected() { .finalOrderSelection(FinalOrderSelection.FREE_FORM_ORDER) .orderOnCourtInitiative(FreeFormOrderValues.builder().onInitiativeSelectionTextArea("test").onInitiativeSelectionDate( LocalDate.now()).build()) + .caseManagementLocation(caseManagementLocation) .build(); CaseDocument caseDocument = generator.generate(caseData, BEARER_TOKEN); assertNotNull(caseDocument); + verify(locationRefDataService).getCourtLocationsByEpimmsId(BEARER_TOKEN, caseManagementLocation.getBaseLocation()); verify(documentManagementService) .uploadDocument(BEARER_TOKEN, new PDF(fileFreeForm, bytes, JUDGE_FINAL_ORDER)); } @@ -223,14 +262,158 @@ void shouldGenerateFreeFormOrder_whenOrderWithoutNoticeIsSelected() { .partyID("res-2-party-id") .partyName("Respondent2") .build()) - .build(); + .caseManagementLocation(caseManagementLocation) + .build();; CaseDocument caseDocument = generator.generate(caseData, BEARER_TOKEN); assertNotNull(caseDocument); + verify(locationRefDataService).getCourtLocationsByEpimmsId(BEARER_TOKEN, caseManagementLocation.getBaseLocation()); verify(documentManagementService) .uploadDocument(BEARER_TOKEN, new PDF(fileFreeForm, bytes, JUDGE_FINAL_ORDER)); } + @Test + @SneakyThrows + void shouldThrowLocationRefDataExceptionOnGeneratingFreeFormOrder_whenLocationServiceDoesNotReturnOnlyASingleLocation() { + when(locationRefDataService.getCourtLocationsByEpimmsId(BEARER_TOKEN, caseManagementLocation.getBaseLocation())) + .thenReturn(List.of(locationRefData, locationRefData)); + when(documentGeneratorService.generateDocmosisDocument(any(MappableObject.class), eq(FREE_FORM_ORDER_PDF))) + .thenReturn(new DocmosisDocument(FREE_FORM_ORDER_PDF.getDocumentTitle(), bytes)); + when(documentManagementService + .uploadDocument(BEARER_TOKEN, new PDF(fileFreeForm, bytes, JUDGE_FINAL_ORDER))) + .thenReturn(FREE_FROM_ORDER); + CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() + .finalOrderSelection(FinalOrderSelection.FREE_FORM_ORDER) + .ccdState(CaseState.CASE_PROGRESSION) + .orderWithoutNotice(FreeFormOrderValues.builder().withoutNoticeSelectionTextArea("test without notice") + .withoutNoticeSelectionDate(LocalDate.now()).build()) + .respondent2(PartyBuilder.builder().individual().build().toBuilder() + .partyID("app-2-party-id") + .partyName("Applicant2") + .build()) + .applicant2(PartyBuilder.builder().soleTrader().build().toBuilder() + .partyID("res-2-party-id") + .partyName("Respondent2") + .build()) + .caseManagementLocation(caseManagementLocation) + .build();; + + assertThrows(LocationRefDataException.class, () -> generator.generate(caseData, BEARER_TOKEN), + "Unexpected amount of locations (2) where matched against location epimms id: 000000" + ); + } + + @Test + @SneakyThrows + void shouldThrowLocationRefDataExceptionOnGeneratingFreeFormOrder_whenLocationServiceReturnsCourtsWithoutCaseTypeIdOf10() { + when(locationRefDataService.getCourtLocationsByEpimmsId(BEARER_TOKEN, caseManagementLocation.getBaseLocation())) + .thenReturn(List.of(locationRefData.toBuilder().courtTypeId("5").build())); + when(documentGeneratorService.generateDocmosisDocument(any(MappableObject.class), eq(FREE_FORM_ORDER_PDF))) + .thenReturn(new DocmosisDocument(FREE_FORM_ORDER_PDF.getDocumentTitle(), bytes)); + when(documentManagementService + .uploadDocument(BEARER_TOKEN, new PDF(fileFreeForm, bytes, JUDGE_FINAL_ORDER))) + .thenReturn(FREE_FROM_ORDER); + CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() + .finalOrderSelection(FinalOrderSelection.FREE_FORM_ORDER) + .ccdState(CaseState.CASE_PROGRESSION) + .orderWithoutNotice(FreeFormOrderValues.builder().withoutNoticeSelectionTextArea("test without notice") + .withoutNoticeSelectionDate(LocalDate.now()).build()) + .respondent2(PartyBuilder.builder().individual().build().toBuilder() + .partyID("app-2-party-id") + .partyName("Applicant2") + .build()) + .applicant2(PartyBuilder.builder().soleTrader().build().toBuilder() + .partyID("res-2-party-id") + .partyName("Respondent2") + .build()) + .caseManagementLocation(caseManagementLocation) + .build();; + + assertThrows(LocationRefDataException.class, () -> generator.generate(caseData, BEARER_TOKEN), + "Unexpected amount of locations (2) where matched against location epimms id: 000000" + ); + } + + @Test + void shouldGenerateFreeFormOrder_whenHearingLocationExists() { + when(documentGeneratorService.generateDocmosisDocument(any(MappableObject.class), eq(FREE_FORM_ORDER_PDF))) + .thenReturn(new DocmosisDocument(FREE_FORM_ORDER_PDF.getDocumentTitle(), bytes)); + when(documentManagementService + .uploadDocument(BEARER_TOKEN, new PDF(fileFreeForm, bytes, JUDGE_FINAL_ORDER))) + .thenReturn(FREE_FROM_ORDER); + CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() + .finalOrderSelection(FinalOrderSelection.FREE_FORM_ORDER) + .ccdState(CaseState.CASE_PROGRESSION) + .orderWithoutNotice(FreeFormOrderValues.builder().withoutNoticeSelectionTextArea("test without notice") + .withoutNoticeSelectionDate(LocalDate.now()).build()) + .respondent2(PartyBuilder.builder().individual().build().toBuilder() + .partyID("app-2-party-id") + .partyName("Applicant2") + .build()) + .applicant2(PartyBuilder.builder().soleTrader().build().toBuilder() + .partyID("res-2-party-id") + .partyName("Respondent2") + .build()) + .hearingLocation(DynamicList.builder() + .value(DynamicListElement.dynamicElement("hearing-location")).build()) + .build();; + CaseDocument caseDocument = generator.generate(caseData, BEARER_TOKEN); + + assertNotNull(caseDocument); + verify(locationRefDataService, times(0)) + .getCourtLocationsByEpimmsId(BEARER_TOKEN, caseManagementLocation.getBaseLocation()); + verify(documentManagementService) + .uploadDocument(BEARER_TOKEN, new PDF(fileFreeForm, bytes, JUDGE_FINAL_ORDER)); + } + + @Test + void shouldGenerateAssistedFormOrder_whenHmcToggleDisabled() { + //Given: case data without recitals selected + when(featureToggleService.isHmcEnabled()).thenReturn(false); + when(documentGeneratorService.generateDocmosisDocument(any(MappableObject.class), eq(ASSISTED_ORDER_PDF))) + .thenReturn(new DocmosisDocument(ASSISTED_ORDER_PDF.getDocumentTitle(), bytes)); + when(documentManagementService + .uploadDocument(BEARER_TOKEN, new PDF(assistedForm, bytes, JUDGE_FINAL_ORDER))) + .thenReturn(ASSISTED_FROM_ORDER); + + CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() + .ccdState(CaseState.CASE_PROGRESSION) + .finalOrderSelection(FinalOrderSelection.ASSISTED_ORDER) + // Order made section + .finalOrderMadeSelection(NO) + // judge heard from section + .finalOrderJudgeHeardFrom(null) + // recitals section + .finalOrderRecitals(null) + // ordered section + .finalOrderOrderedThatText("order text") + // Further hearing section + .finalOrderFurtherHearingToggle(null) + .finalOrderFurtherHearingComplex(null) + // Costs section + .assistedOrderCostList(AssistedCostTypesList.COSTS_IN_THE_CASE) + .assistedOrderMakeAnOrderForCosts(null) + .assistedOrderMakeAnOrderForCosts(AssistedOrderCostDetails.builder().makeAnOrderForCostsList(null).build()) + .publicFundingCostsProtection(NO) + // Appeal section + .finalOrderAppealToggle(null) + // initiative or without notice section + .orderMadeOnDetailsList(OrderMadeOnTypes.COURTS_INITIATIVE) + .orderMadeOnDetailsOrderCourt(OrderMadeOnDetails.builder() + .ownInitiativeText("own initiative test") + .ownInitiativeDate(LocalDate.now()) + .build()) + .finalOrderGiveReasonsYesNo(NO) + .build(); + + //When: Assisted order document generation called + CaseDocument caseDocument = generator.generate(caseData, BEARER_TOKEN); + //Then: It should generate assisted order document + assertNotNull(caseDocument); + verify(documentManagementService) + .uploadDocument(BEARER_TOKEN, new PDF(assistedForm, bytes, JUDGE_FINAL_ORDER)); + } + @Test void shouldGenerateAssistedFormOrder_whenOptionalSectionsNotPresent() { //Given: case data without recitals selected diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/dj/DefaultJudgmentOrderFormGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/dj/DefaultJudgmentOrderFormGeneratorTest.java index 9555538850e..14d23a6819a 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/dj/DefaultJudgmentOrderFormGeneratorTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/dj/DefaultJudgmentOrderFormGeneratorTest.java @@ -200,7 +200,6 @@ void shouldDefaultJudgementDisposalFormGenerator_HnlFieldsWhenToggled() { @Test void shouldDefaultJudgmentTrialOrderFormGenerator_whenNoticeOfChangeEnabled() { - when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(true); when(documentGeneratorService.generateDocmosisDocument(any(MappableObject.class), eq(DJ_SDO_TRIAL))) .thenReturn(new DocmosisDocument(DJ_SDO_TRIAL.getDocumentTitle(), bytes)); when(documentManagementService diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/hearing/HearingFormGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/hearing/HearingFormGeneratorTest.java index 23b051fd7fa..d817d478715 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/hearing/HearingFormGeneratorTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/hearing/HearingFormGeneratorTest.java @@ -18,11 +18,15 @@ import uk.gov.hmcts.reform.civil.model.docmosis.DocmosisDocument; import uk.gov.hmcts.reform.civil.documentmanagement.model.CaseDocument; import uk.gov.hmcts.reform.civil.documentmanagement.model.PDF; +import uk.gov.hmcts.reform.civil.referencedata.LocationRefDataService; +import uk.gov.hmcts.reform.civil.referencedata.model.LocationRefData; import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; import uk.gov.hmcts.reform.civil.sampledata.CaseDocumentBuilder; +import uk.gov.hmcts.reform.civil.service.FeatureToggleService; import uk.gov.hmcts.reform.civil.service.docmosis.DocumentGeneratorService; import uk.gov.hmcts.reform.civil.documentmanagement.UnsecuredDocumentManagementService; import uk.gov.hmcts.reform.civil.utils.AssignCategoryId; +import uk.gov.hmcts.reform.civil.utils.CourtLocationUtils; import java.math.BigDecimal; import java.util.List; @@ -35,6 +39,13 @@ import static uk.gov.hmcts.reform.civil.documentmanagement.model.DocumentType.DEFAULT_JUDGMENT; import static uk.gov.hmcts.reform.civil.documentmanagement.model.DocumentType.HEARING_FORM; import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.HEARING_APPLICATION; +import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.HEARING_APPLICATION_AHN; +import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.HEARING_FAST_TRACK; +import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.HEARING_FAST_TRACK_AHN; +import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.HEARING_OTHER; +import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.HEARING_OTHER_AHN; +import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.HEARING_SMALL_CLAIMS; +import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.HEARING_SMALL_CLAIMS_AHN; @ExtendWith(SpringExtension.class) @ContextConfiguration(classes = { @@ -48,6 +59,13 @@ public class HearingFormGeneratorTest { private static final byte[] bytes = {1, 2, 3, 4, 5, 6}; private static final String fileName_application = String.format( HEARING_APPLICATION.getDocumentTitle(), REFERENCE_NUMBER); + private static final String fileName_small_claim = String.format( + HEARING_SMALL_CLAIMS.getDocumentTitle(), REFERENCE_NUMBER); + private static final String fileName_fast_track = String.format( + HEARING_FAST_TRACK.getDocumentTitle(), REFERENCE_NUMBER); + private static final String fileName_other_claim = String.format( + HEARING_OTHER.getDocumentTitle(), REFERENCE_NUMBER); + private static final CaseDocument CASE_DOCUMENT = CaseDocumentBuilder.builder() .documentName(fileName_application) .documentType(DEFAULT_JUDGMENT) @@ -55,22 +73,148 @@ public class HearingFormGeneratorTest { @MockBean private UnsecuredDocumentManagementService documentManagementService; - @MockBean private DocumentGeneratorService documentGeneratorService; @MockBean private AssignCategoryId assignCategoryId; + @MockBean + FeatureToggleService featureToggleService; + @MockBean + private LocationRefDataService locationRefDataService; + @MockBean + private CourtLocationUtils courtLocationUtils; + @Autowired private HearingFormGenerator generator; @Test - void shouldHearingFormGeneratorOneForm_whenValidDataIsProvided() { + void shouldHearingFormGeneratorOneForm_whenValidDataIsProvided_hearing_application() { when(documentGeneratorService.generateDocmosisDocument(any(MappableObject.class), eq(HEARING_APPLICATION))) .thenReturn(new DocmosisDocument(HEARING_APPLICATION.getDocumentTitle(), bytes)); + when(documentManagementService + .uploadDocument(BEARER_TOKEN, new PDF(fileName_application, bytes, HEARING_FORM))) + .thenReturn(CASE_DOCUMENT); + when(courtLocationUtils.findPreferredLocationData(any(), any())).thenReturn(LocationRefData.builder().build()); + + when(featureToggleService.isAutomatedHearingNoticeEnabled()).thenReturn(false); + + CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged() + .listingOrRelisting(ListingOrRelisting.LISTING) + .totalClaimAmount(new BigDecimal(2000)) + .build().toBuilder() + .hearingLocation(DynamicList.builder().value(DynamicListElement.builder().label("County Court").build()) + .build()) + .hearingTimeHourMinute("0800") + .channel(HearingChannel.IN_PERSON) + .hearingDuration(HearingDuration.DAY_1) + .hearingNoticeList(HearingNoticeList.HEARING_OF_APPLICATION).build(); + List caseDocuments = generator.generate(caseData, BEARER_TOKEN); + + assertThat(caseDocuments.size()).isEqualTo(1); + + verify(documentManagementService) + .uploadDocument(BEARER_TOKEN, new PDF(fileName_application, bytes, HEARING_FORM)); + } + + @Test + void shouldHearingFormGeneratorOneForm_whenValidDataIsProvided_hearing_small_claims() { + when(documentGeneratorService.generateDocmosisDocument(any(MappableObject.class), eq(HEARING_SMALL_CLAIMS))) + .thenReturn(new DocmosisDocument(HEARING_SMALL_CLAIMS.getDocumentTitle(), bytes)); + + when(documentManagementService + .uploadDocument(BEARER_TOKEN, new PDF(fileName_small_claim, bytes, HEARING_FORM))) + .thenReturn(CASE_DOCUMENT); + when(courtLocationUtils.findPreferredLocationData(any(), any())).thenReturn(LocationRefData.builder().build()); + when(featureToggleService.isAutomatedHearingNoticeEnabled()).thenReturn(false); + + CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged() + .listingOrRelisting(ListingOrRelisting.LISTING) + .totalClaimAmount(new BigDecimal(2000)) + .build().toBuilder() + .hearingLocation(DynamicList.builder().value(DynamicListElement.builder().label("County Court").build()) + .build()) + .hearingTimeHourMinute("0800") + .channel(HearingChannel.IN_PERSON) + .hearingDuration(HearingDuration.DAY_1) + .hearingNoticeList(HearingNoticeList.SMALL_CLAIMS).build(); + List caseDocuments = generator.generate(caseData, BEARER_TOKEN); + + assertThat(caseDocuments.size()).isEqualTo(1); + + verify(documentManagementService) + .uploadDocument(BEARER_TOKEN, new PDF(fileName_small_claim, bytes, HEARING_FORM)); + } + + @Test + void shouldHearingFormGeneratorOneForm_whenValidDataIsProvided_hearing_fast_track() { + when(documentGeneratorService.generateDocmosisDocument(any(MappableObject.class), eq(HEARING_FAST_TRACK))) + .thenReturn(new DocmosisDocument(HEARING_FAST_TRACK.getDocumentTitle(), bytes)); + + when(documentManagementService + .uploadDocument(BEARER_TOKEN, new PDF(fileName_fast_track, bytes, HEARING_FORM))) + .thenReturn(CASE_DOCUMENT); + when(courtLocationUtils.findPreferredLocationData(any(), any())).thenReturn(LocationRefData.builder().build()); + when(featureToggleService.isAutomatedHearingNoticeEnabled()).thenReturn(false); + + CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged() + .listingOrRelisting(ListingOrRelisting.LISTING) + .totalClaimAmount(new BigDecimal(2000)) + .build().toBuilder() + .hearingLocation(DynamicList.builder().value(DynamicListElement.builder().label("County Court").build()) + .build()) + .hearingTimeHourMinute("0800") + .channel(HearingChannel.IN_PERSON) + .hearingDuration(HearingDuration.DAY_1) + .hearingNoticeList(HearingNoticeList.FAST_TRACK_TRIAL).build(); + List caseDocuments = generator.generate(caseData, BEARER_TOKEN); + + assertThat(caseDocuments.size()).isEqualTo(1); + + verify(documentManagementService) + .uploadDocument(BEARER_TOKEN, new PDF(fileName_fast_track, bytes, HEARING_FORM)); + } + + @Test + void shouldHearingFormGeneratorOneForm_whenValidDataIsProvided_hearing_oher() { + when(documentGeneratorService.generateDocmosisDocument(any(MappableObject.class), eq(HEARING_OTHER))) + .thenReturn(new DocmosisDocument(HEARING_OTHER.getDocumentTitle(), bytes)); + + when(documentManagementService + .uploadDocument(BEARER_TOKEN, new PDF(fileName_other_claim, bytes, HEARING_FORM))) + .thenReturn(CASE_DOCUMENT); + when(courtLocationUtils.findPreferredLocationData(any(), any())).thenReturn(LocationRefData.builder().build()); + + when(featureToggleService.isAutomatedHearingNoticeEnabled()).thenReturn(false); + + CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged() + .listingOrRelisting(ListingOrRelisting.LISTING) + .totalClaimAmount(new BigDecimal(2000)) + .build().toBuilder() + .hearingLocation(DynamicList.builder().value(DynamicListElement.builder().label("County Court").build()) + .build()) + .hearingTimeHourMinute("0800") + .channel(HearingChannel.IN_PERSON) + .hearingDuration(HearingDuration.DAY_1) + .hearingNoticeList(HearingNoticeList.OTHER).build(); + List caseDocuments = generator.generate(caseData, BEARER_TOKEN); + + assertThat(caseDocuments.size()).isEqualTo(1); + + verify(documentManagementService) + .uploadDocument(BEARER_TOKEN, new PDF(fileName_other_claim, bytes, HEARING_FORM)); + } + + @Test + void shouldHearingFormGeneratorOneForm_whenValidDataIsProvided_hearing_application_ahn() { + when(documentGeneratorService.generateDocmosisDocument(any(MappableObject.class), eq(HEARING_APPLICATION_AHN))) + .thenReturn(new DocmosisDocument(HEARING_APPLICATION_AHN.getDocumentTitle(), bytes)); when(documentManagementService .uploadDocument(BEARER_TOKEN, new PDF(fileName_application, bytes, HEARING_FORM))) .thenReturn(CASE_DOCUMENT); + when(courtLocationUtils.findPreferredLocationData(any(), any())).thenReturn(LocationRefData.builder().build()); + + when(featureToggleService.isAutomatedHearingNoticeEnabled()).thenReturn(true); CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged() .listingOrRelisting(ListingOrRelisting.LISTING) @@ -89,4 +233,94 @@ void shouldHearingFormGeneratorOneForm_whenValidDataIsProvided() { verify(documentManagementService) .uploadDocument(BEARER_TOKEN, new PDF(fileName_application, bytes, HEARING_FORM)); } + + @Test + void shouldHearingFormGeneratorOneForm_whenValidDataIsProvided_hearing_small_claims_ahn() { + when(documentGeneratorService.generateDocmosisDocument(any(MappableObject.class), eq(HEARING_SMALL_CLAIMS_AHN))) + .thenReturn(new DocmosisDocument(HEARING_SMALL_CLAIMS_AHN.getDocumentTitle(), bytes)); + + when(documentManagementService + .uploadDocument(BEARER_TOKEN, new PDF(fileName_small_claim, bytes, HEARING_FORM))) + .thenReturn(CASE_DOCUMENT); + when(courtLocationUtils.findPreferredLocationData(any(), any())).thenReturn(LocationRefData.builder().build()); + + when(featureToggleService.isAutomatedHearingNoticeEnabled()).thenReturn(true); + + CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged() + .listingOrRelisting(ListingOrRelisting.LISTING) + .totalClaimAmount(new BigDecimal(2000)) + .build().toBuilder() + .hearingLocation(DynamicList.builder().value(DynamicListElement.builder().label("County Court").build()) + .build()) + .hearingTimeHourMinute("0800") + .channel(HearingChannel.IN_PERSON) + .hearingDuration(HearingDuration.DAY_1) + .hearingNoticeList(HearingNoticeList.SMALL_CLAIMS).build(); + List caseDocuments = generator.generate(caseData, BEARER_TOKEN); + + assertThat(caseDocuments.size()).isEqualTo(1); + + verify(documentManagementService) + .uploadDocument(BEARER_TOKEN, new PDF(fileName_small_claim, bytes, HEARING_FORM)); + } + + @Test + void shouldHearingFormGeneratorOneForm_whenValidDataIsProvided_hearing_fast_track_ahn() { + when(documentGeneratorService.generateDocmosisDocument(any(MappableObject.class), eq(HEARING_FAST_TRACK_AHN))) + .thenReturn(new DocmosisDocument(HEARING_FAST_TRACK_AHN.getDocumentTitle(), bytes)); + + when(documentManagementService + .uploadDocument(BEARER_TOKEN, new PDF(fileName_fast_track, bytes, HEARING_FORM))) + .thenReturn(CASE_DOCUMENT); + when(courtLocationUtils.findPreferredLocationData(any(), any())).thenReturn(LocationRefData.builder().build()); + + when(featureToggleService.isAutomatedHearingNoticeEnabled()).thenReturn(true); + + CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged() + .listingOrRelisting(ListingOrRelisting.LISTING) + .totalClaimAmount(new BigDecimal(2000)) + .build().toBuilder() + .hearingLocation(DynamicList.builder().value(DynamicListElement.builder().label("County Court").build()) + .build()) + .hearingTimeHourMinute("0800") + .channel(HearingChannel.IN_PERSON) + .hearingDuration(HearingDuration.DAY_1) + .hearingNoticeList(HearingNoticeList.FAST_TRACK_TRIAL).build(); + List caseDocuments = generator.generate(caseData, BEARER_TOKEN); + + assertThat(caseDocuments.size()).isEqualTo(1); + + verify(documentManagementService) + .uploadDocument(BEARER_TOKEN, new PDF(fileName_fast_track, bytes, HEARING_FORM)); + } + + @Test + void shouldHearingFormGeneratorOneForm_whenValidDataIsProvided_hearing_other_ahn() { + when(documentGeneratorService.generateDocmosisDocument(any(MappableObject.class), eq(HEARING_OTHER_AHN))) + .thenReturn(new DocmosisDocument(HEARING_OTHER_AHN.getDocumentTitle(), bytes)); + + when(documentManagementService + .uploadDocument(BEARER_TOKEN, new PDF(fileName_other_claim, bytes, HEARING_FORM))) + .thenReturn(CASE_DOCUMENT); + when(courtLocationUtils.findPreferredLocationData(any(), any())).thenReturn(LocationRefData.builder().build()); + + when(featureToggleService.isAutomatedHearingNoticeEnabled()).thenReturn(true); + + CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged() + .listingOrRelisting(ListingOrRelisting.LISTING) + .totalClaimAmount(new BigDecimal(2000)) + .build().toBuilder() + .hearingLocation(DynamicList.builder().value(DynamicListElement.builder().label("County Court").build()) + .build()) + .hearingTimeHourMinute("0800") + .channel(HearingChannel.IN_PERSON) + .hearingDuration(HearingDuration.DAY_1) + .hearingNoticeList(HearingNoticeList.OTHER).build(); + List caseDocuments = generator.generate(caseData, BEARER_TOKEN); + + assertThat(caseDocuments.size()).isEqualTo(1); + + verify(documentManagementService) + .uploadDocument(BEARER_TOKEN, new PDF(fileName_other_claim, bytes, HEARING_FORM)); + } } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/hearing/HearingNoticeHmcGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/hearing/HearingNoticeHmcGeneratorTest.java index c7ab605231c..ebae86ffe38 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/hearing/HearingNoticeHmcGeneratorTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/docmosis/hearing/HearingNoticeHmcGeneratorTest.java @@ -159,7 +159,8 @@ void shouldGenerateHearingNoticeHmc_1v1_whenHearingFeeHasBeenPaid() { .calculatedAmountInPence(new BigDecimal(123)) .build()); - var actual = generator.getHearingNoticeTemplateData(caseData, hearing, BEARER_TOKEN); + var actual = generator.getHearingNoticeTemplateData(caseData, hearing, BEARER_TOKEN, + "SiteName - CourtAddress - Postcode", "hearingId"); var expected = HearingNoticeHmc.builder() .caseNumber(caseData.getCcdCaseReference()) .creationDate(LocalDate.now()) @@ -212,7 +213,8 @@ void shouldGenerateHearingNoticeHmc_1v1_whenHearingFeeHasNotBeenPaid() { .calculatedAmountInPence(new BigDecimal(123)) .build()); - var actual = generator.getHearingNoticeTemplateData(caseData, hearing, BEARER_TOKEN); + var actual = generator.getHearingNoticeTemplateData(caseData, hearing, BEARER_TOKEN, + "SiteName - CourtAddress - Postcode", "hearingId"); var expected = HearingNoticeHmc.builder() .caseNumber(caseData.getCcdCaseReference()) .creationDate(LocalDate.now()) @@ -265,7 +267,8 @@ void shouldGenerateHearingNoticeHmc_1v2DS_whenHearingFeeHasBeenPaid() { .calculatedAmountInPence(new BigDecimal(123)) .build()); - var actual = generator.getHearingNoticeTemplateData(caseData, hearing, BEARER_TOKEN); + var actual = generator.getHearingNoticeTemplateData(caseData, hearing, BEARER_TOKEN, + "SiteName - CourtAddress - Postcode", "hearingId"); var expected = HearingNoticeHmc.builder() .caseNumber(caseData.getCcdCaseReference()) .creationDate(LocalDate.now()) @@ -322,7 +325,8 @@ void shouldGenerateHearingNoticeHmc_2v1_whenHearingFeeHasBeenPaid() { .calculatedAmountInPence(new BigDecimal(123)) .build()); - var actual = generator.getHearingNoticeTemplateData(caseData, hearing, BEARER_TOKEN); + var actual = generator.getHearingNoticeTemplateData(caseData, hearing, BEARER_TOKEN, + "SiteName - CourtAddress - Postcode", "hearingId"); var expected = HearingNoticeHmc.builder() .caseNumber(caseData.getCcdCaseReference()) .creationDate(LocalDate.now()) @@ -377,7 +381,8 @@ void shouldReturnListOfExpectedCaseDocuments() { .calculatedAmountInPence(new BigDecimal(123)) .build()); - var actual = generator.generate(caseData, hearing, BEARER_TOKEN); + var actual = generator.generate(caseData, hearing, BEARER_TOKEN, + "SiteName - CourtAddress - Postcode", "hearingId"); var expected = List.of(CASE_DOCUMENT); verify(documentManagementService) diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowPredicateTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowPredicateTest.java index 89a8e8f507a..7d910330a96 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowPredicateTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowPredicateTest.java @@ -56,6 +56,7 @@ import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.claimDismissedByCamunda; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.claimIssued; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.claimNotified; +import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.claimSubmitted1v1RespondentOneUnregistered; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.claimSubmittedBothRespondentUnrepresented; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.claimSubmittedBothUnregisteredSolicitors; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowPredicate.claimSubmittedOneRespondentRepresentative; @@ -172,6 +173,21 @@ void shouldReturnTrue_whenCaseTakenOfflineBeforeIssue() { .build(); assertTrue(takenOfflineByStaffBeforeClaimIssued.test(caseData)); } + + @Test + void shouldReturnTrue_whenRespondentSolicitorUnregistered() { + CaseData caseData = CaseDataBuilder.builder() + .atStateClaimSubmittedRespondent1Unregistered() + .addRespondent2(NO) + .build(); + assertTrue(claimSubmitted1v1RespondentOneUnregistered.test(caseData)); + } + + @Test + void shouldReturnFalse_whenRespondentSolicitorRegistered() { + CaseData caseData = CaseDataBuilder.builder().atStateClaimSubmitted().build(); + assertFalse(claimSubmitted1v1RespondentOneUnregistered.test(caseData)); + } } @Nested diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowStateAllowedEventServiceTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowStateAllowedEventServiceTest.java index f1dd6858eae..fd68c866dc9 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowStateAllowedEventServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/flowstate/FlowStateAllowedEventServiceTest.java @@ -571,7 +571,8 @@ public Stream provideArguments(ExtensionContext context) { JUDGMENT_PAID_IN_FULL, RECORD_JUDGMENT, TRANSFER_ONLINE_CASE, - asyncStitchingComplete + asyncStitchingComplete, + CLAIMANT_RESPONSE_CUI } ), of( diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/flowstate/StateFlowEngineSpecTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/flowstate/StateFlowEngineSpecTest.java index 92c2cbfd854..e186a771137 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/flowstate/StateFlowEngineSpecTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/flowstate/StateFlowEngineSpecTest.java @@ -55,8 +55,6 @@ class StateFlowEngineSpecTest { @BeforeEach void setup() { given(featureToggleService.isGeneralApplicationsEnabled()).willReturn(false); - given(featureToggleService.isCertificateOfServiceEnabled()).willReturn(false); - given(featureToggleService.isNoticeOfChangeEnabled()).willReturn(false); } static Stream caseDataStream() { @@ -198,12 +196,9 @@ void shouldContainCommonFlags_whenCaseDataAtStateClaimSubmitted(CaseData caseDat //When StateFlow stateFlow = stateFlowEngine.evaluate(caseData); - // Then Claim will have NOTICE_OF_CHANGE, GENERAL_APPLICATION_ENABLED, CERTIFICATE_OF_SERVICE and RPA_CONTINUOUS_FEED + // Then Claim will have GENERAL_APPLICATION_ENABLED and RPA_CONTINUOUS_FEED assertThat(stateFlow.getFlags()).contains( - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false)); } @ParameterizedTest(name = "{index}: The state flow flag ONE_RESPONDENT_REPRESENTATIVE is set to true (for appropriate cases)") @@ -216,7 +211,7 @@ void shouldHaveOneRespondentRepresentativeFlagsSet_whenCaseDataAtStateClaimSubmi assertThat(stateFlow.getFlags()).contains( entry(FlowFlag.ONE_RESPONDENT_REPRESENTATIVE.name(), true) ); - assertThat(stateFlow.getFlags()).hasSize(5); // bonus: if this fails, a flag was added/removed but tests were not updated + assertThat(stateFlow.getFlags()).hasSize(3); // bonus: if this fails, a flag was added/removed but tests were not updated } @ParameterizedTest(name = "{index}: The state flow flags ONE_RESPONDENT_REPRESENTATIVE and " + @@ -231,7 +226,7 @@ void shouldReturnFlags_whenAtStateClaimSubmitted1v2DiffSol_OrSolicitor1UnrepAndS entry(FlowFlag.ONE_RESPONDENT_REPRESENTATIVE.name(), false), entry(FlowFlag.TWO_RESPONDENT_REPRESENTATIVES.name(), true) ); - assertThat(stateFlow.getFlags()).hasSize(6); // bonus: if this fails, a flag was added/removed but tests were not updated + assertThat(stateFlow.getFlags()).hasSize(4); // bonus: if this fails, a flag was added/removed but tests were not updated } public interface StubbingFn extends Function> { @@ -239,12 +234,8 @@ public interface StubbingFn extends Function commonFlagNames() { return Stream.of( - arguments(FlowFlag.NOTICE_OF_CHANGE.name(), (StubbingFn)(featureToggleService) - -> when(featureToggleService.isNoticeOfChangeEnabled())), arguments(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), (StubbingFn)(featureToggleService) - -> when(featureToggleService.isGeneralApplicationsEnabled())), - arguments(FlowFlag.CERTIFICATE_OF_SERVICE.name(), (StubbingFn)(featureToggleService) - -> when(featureToggleService.isCertificateOfServiceEnabled())) + -> when(featureToggleService.isGeneralApplicationsEnabled())) ); } @@ -432,7 +423,7 @@ void shouldGoClaimIssued_1v1_whenRepresented() { // Specified 1V2 both unrepresented with state transition from PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT -> // TAKEN_OFFLINE_UNREPRESENTED_DEFENDANT @Test() - void shouldGoOffline_1v2_whenBothUnrepresented() { + void shouldNotGoOffline_1v2_whenBothUnrepresented() { //Given CaseData caseData = CaseDataBuilderSpec.builder().atStateTakenOfflineUnrepresentedDefendantSameSolicitor() .build(); diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/flowstate/StateFlowEngineTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/flowstate/StateFlowEngineTest.java index e281096e8cd..fade4561d58 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/flowstate/StateFlowEngineTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/flowstate/StateFlowEngineTest.java @@ -31,8 +31,10 @@ import uk.gov.hmcts.reform.civil.service.FeatureToggleService; import uk.gov.hmcts.reform.civil.stateflow.StateFlow; import uk.gov.hmcts.reform.civil.stateflow.model.State; + import java.time.LocalDate; import java.time.LocalDateTime; + import static java.util.Map.entry; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -83,6 +85,7 @@ import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT_ONE_V_ONE_SPEC; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.PENDING_CLAIM_ISSUED_UNREPRESENTED_UNREGISTERED_DEFENDANT; +import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.SIGN_SETTLEMENT_AGREEMENT; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.SPEC_DRAFT; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.TAKEN_OFFLINE_AFTER_CLAIM_DETAILS_NOTIFIED; import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.TAKEN_OFFLINE_AFTER_CLAIM_NOTIFIED; @@ -129,10 +132,8 @@ void shouldReturnClaimSubmitted_whenCaseDataAtStateClaimSubmittedWithOneResponde .containsExactly( DRAFT.fullName(), CLAIM_SUBMITTED.fullName()); - assertThat(stateFlow.getFlags()).hasSize(5).contains( - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), entry("ONE_RESPONDENT_REPRESENTATIVE", true) ); @@ -159,10 +160,8 @@ void shouldReturnTakenOffline_whenCaseTakenOfflineBeforeIssue() { .containsExactly( DRAFT.fullName(), CLAIM_SUBMITTED.fullName(), TAKEN_OFFLINE_BY_STAFF.fullName()); - assertThat(stateFlow.getFlags()).hasSize(5).contains( - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), entry("ONE_RESPONDENT_REPRESENTATIVE", true) ); @@ -194,13 +193,11 @@ void shouldReturnClaimSubmitted_whenCaseDataAtStateClaimSubmittedTwoRespondentRe .containsExactly( DRAFT.fullName(), CLAIM_SUBMITTED.fullName()); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), entry("TWO_RESPONDENT_REPRESENTATIVES", true), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) + entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -229,13 +226,10 @@ void shouldReturnClaimSubmitted_whenCaseDataAtStateClaimSubmittedTwoRepresentati .containsExactly( DRAFT.fullName(), CLAIM_SUBMITTED.fullName()); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), entry("TWO_RESPONDENT_REPRESENTATIVES", true), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false) - ); + entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false)); } @Test @@ -380,144 +374,6 @@ void shouldReturnClaimSubmitted_whenCaseDataAtStateClaimSubmitted2v1RespondentIs DRAFT.fullName(), CLAIM_SUBMITTED.fullName()); } - // remove this when NoC is implemented - @Nested - class UnrepresentedTakenOfflineBeforeNoC { - // 1v1 Unrepresented - @Test - void shouldReturnProceedsWithOfflineJourney_1v1_whenCaseDataAtStateClaimDraftIssuedAndResUnrepresented() { - // Given - CaseData caseData = CaseDataBuilder.builder() - .atStateClaimIssued1v1UnrepresentedDefendant() - .defendant1LIPAtClaimIssued(null) - .defendant2LIPAtClaimIssued(null) - .build(); - - // When - StateFlow stateFlow = stateFlowEngine.evaluate(caseData); - - // Then - assertThat(stateFlow.getState()) - .extracting(State::getName) - .isNotNull() - .isEqualTo(TAKEN_OFFLINE_UNREPRESENTED_DEFENDANT.fullName()); - assertThat(stateFlow.getStateHistory()) - .hasSize(5) - .extracting(State::getName) - .containsExactly( - DRAFT.fullName(), CLAIM_SUBMITTED.fullName(), CLAIM_ISSUED_PAYMENT_SUCCESSFUL.fullName(), - PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT.fullName(), - TAKEN_OFFLINE_UNREPRESENTED_DEFENDANT.fullName() - ); - assertThat(stateFlow.getFlags()).hasSize(4).contains( - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) - ); - } - - // 1v2 - // Unrepresented - // 1. Both def1 and def2 unrepresented - @Test - void shouldReturnProceedsWithOfflineJourney_whenCaseDataAtStateClaimDraftIssuedRespondentsNotRepresented() { - // Given - CaseData caseData = CaseDataBuilder.builder() - .atStateClaimIssuedUnrepresentedDefendants() - .defendant1LIPAtClaimIssued(null) - .defendant2LIPAtClaimIssued(null) - .build(); - - // When - StateFlow stateFlow = stateFlowEngine.evaluate(caseData); - - // Then - assertThat(stateFlow.getState()) - .extracting(State::getName) - .isNotNull() - .isEqualTo(TAKEN_OFFLINE_UNREPRESENTED_DEFENDANT.fullName()); - assertThat(stateFlow.getStateHistory()) - .hasSize(5) - .extracting(State::getName) - .containsExactly( - DRAFT.fullName(), CLAIM_SUBMITTED.fullName(), CLAIM_ISSUED_PAYMENT_SUCCESSFUL.fullName(), - PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT.fullName(), - TAKEN_OFFLINE_UNREPRESENTED_DEFENDANT.fullName() - ); - assertThat(stateFlow.getFlags()).hasSize(4).contains( - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) - ); - } - - // Unrepresented - // 2. Def1 unrepresented, Def2 registered - @Test - void shouldReturnProceedsWithOfflineJourney_whenCaseDataAtStateClaimDraftIssuedRespondent1NotRepresented() { - // Given - CaseData caseData = CaseDataBuilder.builder() - .atStateClaimIssuedUnrepresentedDefendant1() - .defendant1LIPAtClaimIssued(null) - .build(); - - // When - StateFlow stateFlow = stateFlowEngine.evaluate(caseData); - - // Then - assertThat(stateFlow.getState()) - .extracting(State::getName) - .isNotNull() - .isEqualTo(TAKEN_OFFLINE_UNREPRESENTED_DEFENDANT.fullName()); - assertThat(stateFlow.getStateHistory()) - .hasSize(5) - .extracting(State::getName) - .containsExactly( - DRAFT.fullName(), CLAIM_SUBMITTED.fullName(), CLAIM_ISSUED_PAYMENT_SUCCESSFUL.fullName(), - PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT.fullName(), - TAKEN_OFFLINE_UNREPRESENTED_DEFENDANT.fullName() - ); - assertThat(stateFlow.getFlags()).hasSize(4).contains( - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) - ); - } - - // Unrepresented - // 3. Def1 registered, Def 2 unrepresented - @Test - void shouldReturnProceedsWithOfflineJourney_whenCaseDataAtStateClaimDraftIssuedRespondent2NotRepresented() { - // Given - CaseData caseData = CaseDataBuilder.builder() - .atStateClaimIssuedUnrepresentedDefendant2() - .defendant2LIPAtClaimIssued(null) - .build(); - - // When - StateFlow stateFlow = stateFlowEngine.evaluate(caseData); - - // Then - assertThat(stateFlow.getState()) - .extracting(State::getName) - .isNotNull() - .isEqualTo(TAKEN_OFFLINE_UNREPRESENTED_DEFENDANT.fullName()); - assertThat(stateFlow.getStateHistory()) - .hasSize(5) - .extracting(State::getName) - .containsExactly( - DRAFT.fullName(), CLAIM_SUBMITTED.fullName(), CLAIM_ISSUED_PAYMENT_SUCCESSFUL.fullName(), - PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT.fullName(), - TAKEN_OFFLINE_UNREPRESENTED_DEFENDANT.fullName() - ); - assertThat(stateFlow.getFlags()).hasSize(4).contains( - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) - ); - } - } - @Nested class UnrepresentedDefendant { @Test @@ -547,52 +403,13 @@ void shouldGoOffline_whenDeadlinePassed() { PAST_CLAIM_NOTIFICATION_DEADLINE_AWAITING_CAMUNDA.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry(FlowFlag.UNREPRESENTED_DEFENDANT_ONE.name(), true), entry(FlowFlag.UNREPRESENTED_DEFENDANT_TWO.name(), true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } - // 1v1 - // Unrepresented cos service not activated - @Test - void shouldContinueOnline_1v1_whenDefendantIsUnrepresented() { - // Given - CaseData caseData = CaseDataBuilder.builder() - .atStateClaimIssued1v1UnrepresentedDefendant() - .defendant1LIPAtClaimIssued(YES) - .build(); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(false); - - // When - StateFlow stateFlow = stateFlowEngine.evaluate(caseData); - - // Then - assertThat(stateFlow.getState()) - .extracting(State::getName) - .isNotNull() - .isEqualTo(PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT.fullName()); - assertThat(stateFlow.getStateHistory()) - .hasSize(4) - .extracting(State::getName) - .containsExactly( - DRAFT.fullName(), CLAIM_SUBMITTED.fullName(), CLAIM_ISSUED_PAYMENT_SUCCESSFUL.fullName(), - PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT.fullName() - ); - - assertThat(stateFlow.getFlags()).hasSize(5).contains( - entry(FlowFlag.UNREPRESENTED_DEFENDANT_ONE.name(), true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); - } - - // Unrepresented cos service activated @Test void shouldContinueOnline_1v1_cos_whenDefendantIsUnrepresented() { // Given @@ -600,7 +417,6 @@ void shouldContinueOnline_1v1_cos_whenDefendantIsUnrepresented() { .atStateClaimIssued1v1UnrepresentedDefendant() .defendant2LIPAtClaimIssued(YES) .build(); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); // When StateFlow stateFlow = stateFlowEngine.evaluate(caseData); @@ -618,11 +434,9 @@ void shouldContinueOnline_1v1_cos_whenDefendantIsUnrepresented() { PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry(FlowFlag.UNREPRESENTED_DEFENDANT_ONE.name(), true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), true) + entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -654,10 +468,8 @@ void shouldContinueOnline_1v1Spec_whenDefendantIsUnrepresented() { PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT_ONE_V_ONE_SPEC.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry(FlowFlag.UNREPRESENTED_DEFENDANT_ONE.name(), true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -673,7 +485,6 @@ void shouldContinueOnline_WhenBothDefendantsAreUnrepresented() { .defendant1LIPAtClaimIssued(YES) .defendant2LIPAtClaimIssued(YES) .build(); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(false); // When StateFlow stateFlow = stateFlowEngine.evaluate(caseData); @@ -691,11 +502,9 @@ void shouldContinueOnline_WhenBothDefendantsAreUnrepresented() { PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry(FlowFlag.UNREPRESENTED_DEFENDANT_ONE.name(), true), entry(FlowFlag.UNREPRESENTED_DEFENDANT_TWO.name(), true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -708,7 +517,6 @@ void shouldContinueOnline_WhenCaseDataAtStateClaimDraftIssuedAndRespondent1NotRe CaseData caseData = CaseDataBuilder.builder() .atStateClaimIssuedUnrepresentedDefendant1() .build(); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(false); // When StateFlow stateFlow = stateFlowEngine.evaluate(caseData); @@ -726,11 +534,9 @@ void shouldContinueOnline_WhenCaseDataAtStateClaimDraftIssuedAndRespondent1NotRe PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry(FlowFlag.UNREPRESENTED_DEFENDANT_ONE.name(), true), entry(FlowFlag.UNREPRESENTED_DEFENDANT_TWO.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -743,7 +549,6 @@ void shouldContinueOnline_Cos_WhenCaseDataAtStateClaimDraftIssuedAndRespondent1N CaseData caseData = CaseDataBuilder.builder() .atStateClaimIssuedUnrepresentedDefendant1() .build(); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); // When StateFlow stateFlow = stateFlowEngine.evaluate(caseData); @@ -761,11 +566,9 @@ void shouldContinueOnline_Cos_WhenCaseDataAtStateClaimDraftIssuedAndRespondent1N PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry(FlowFlag.UNREPRESENTED_DEFENDANT_ONE.name(), true), entry(FlowFlag.UNREPRESENTED_DEFENDANT_TWO.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), true), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -779,7 +582,6 @@ void shouldContinueOnline_WhenCaseDataAtStateClaimDraftIssuedAndRespondent2NotRe .atStateClaimIssuedUnrepresentedDefendant2() .defendant2LIPAtClaimIssued(YES) .build(); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(false); // When StateFlow stateFlow = stateFlowEngine.evaluate(caseData); @@ -797,11 +599,9 @@ void shouldContinueOnline_WhenCaseDataAtStateClaimDraftIssuedAndRespondent2NotRe PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry(FlowFlag.UNREPRESENTED_DEFENDANT_ONE.name(), false), entry(FlowFlag.UNREPRESENTED_DEFENDANT_TWO.name(), true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -816,8 +616,6 @@ void shouldContinueOnline_Cos_WhenCaseDataAtStateClaimDraftIssuedAndRespondent2N .defendant2LIPAtClaimIssued(YES) .build(); - when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); - // When StateFlow stateFlow = stateFlowEngine.evaluate(caseData); @@ -834,13 +632,10 @@ void shouldContinueOnline_Cos_WhenCaseDataAtStateClaimDraftIssuedAndRespondent2N PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry(FlowFlag.UNREPRESENTED_DEFENDANT_ONE.name(), false), entry(FlowFlag.UNREPRESENTED_DEFENDANT_TWO.name(), true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), true) - ); + entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false)); } // 1v2 spec @@ -862,19 +657,18 @@ void shouldContinueOnline_WhenCaseDataAtStateClaimDraftIssuedAndRespondent2NotRe assertThat(stateFlow.getState()) .extracting(State::getName) .isNotNull() - .isEqualTo(PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT.fullName()); + .isEqualTo(TAKEN_OFFLINE_UNREPRESENTED_DEFENDANT.fullName()); assertThat(stateFlow.getStateHistory()) - .hasSize(4) + .hasSize(5) .extracting(State::getName) .containsExactly( SPEC_DRAFT.fullName(), CLAIM_SUBMITTED.fullName(), CLAIM_ISSUED_PAYMENT_SUCCESSFUL.fullName(), - PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT.fullName() + PENDING_CLAIM_ISSUED_UNREPRESENTED_DEFENDANT.fullName(), + TAKEN_OFFLINE_UNREPRESENTED_DEFENDANT.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry(FlowFlag.UNREPRESENTED_DEFENDANT_TWO.name(), true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -905,10 +699,8 @@ void shouldReturnProceedsWithOfflineJourney_1v1_whenCaseDataAtStateClaimDraftIss TAKEN_OFFLINE_UNREGISTERED_DEFENDANT.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -938,8 +730,6 @@ void shouldReturnProceedsWithOfflineJourney_whenCaseDataAtStateClaimDraftIssuedR TAKEN_OFFLINE_UNREGISTERED_DEFENDANT.fullName() ); assertThat(stateFlow.getFlags()).hasSize(4).contains( - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -970,8 +760,6 @@ void shouldReturnProceedsWithOfflineJourney_whenRespondentsNotRegisteredSpec() { TAKEN_OFFLINE_UNREGISTERED_DEFENDANT.fullName() ); assertThat(stateFlow.getFlags()).hasSize(4).contains( - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -1000,10 +788,8 @@ void shouldReturnProceedsWithOfflineJourney_whenCaseDataAtStateClaimDraftIssuedR TAKEN_OFFLINE_UNREGISTERED_DEFENDANT.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -1038,10 +824,8 @@ void shouldReturnProceedsWithOfflineJourney_whenCaseDataAtStateClaimDraftIssuedR TAKEN_OFFLINE_UNREGISTERED_DEFENDANT.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -1069,10 +853,8 @@ void shouldReturnProceedsWithOfflineJourney_whenCaseDataAtStateClaimDraftIssuedS TAKEN_OFFLINE_UNREGISTERED_DEFENDANT.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -1104,8 +886,6 @@ void shouldReturnProceedsWithOfflineJourney_whenCaseDataAtStateClaimDraftIssuedA TAKEN_OFFLINE_UNREPRESENTED_UNREGISTERED_DEFENDANT.fullName() ); assertThat(stateFlow.getFlags()).hasSize(4).contains( - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -1136,8 +916,6 @@ void shouldReturnProceedsWithOfflineJourney_whenCaseDataAtStateClaimDraftIssuedA ); assertThat(stateFlow.getFlags()).hasSize(4).contains( - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -1169,11 +947,9 @@ void shouldReturnPaymentSuccessful_whenCaseDataAtStatePaymentSuccessful() { .containsExactly( DRAFT.fullName(), CLAIM_SUBMITTED.fullName(), CLAIM_ISSUED_PAYMENT_SUCCESSFUL.fullName()); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -1198,13 +974,10 @@ void shouldReturnPaymentSuccessful_whenCaseDataAtStatePaymentSuccessful1v2SameRe .containsExactly( DRAFT.fullName(), CLAIM_SUBMITTED.fullName(), CLAIM_ISSUED_PAYMENT_SUCCESSFUL.fullName()); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false)); } @Test @@ -1226,13 +999,10 @@ void shouldReturnPaymentFailed_whenCaseDataAtStatePaymentFailed() { .containsExactly( DRAFT.fullName(), CLAIM_SUBMITTED.fullName(), CLAIM_ISSUED_PAYMENT_FAILED.fullName()); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false)); } @Test @@ -1262,13 +1032,10 @@ void shouldReturnAwaitingCaseNotification_whenCaseDataAtStateAwaitingCaseNotific PENDING_CLAIM_ISSUED.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false)); } @Test @@ -1302,14 +1069,11 @@ void shouldReturnProceedsWithOfflineJourney_whenCaseDataAtStateClaimIssued_andOn CLAIM_ISSUED.fullName(), TAKEN_OFFLINE_AFTER_CLAIM_NOTIFIED.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), entry("TWO_RESPONDENT_REPRESENTATIVES", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false)); } @Test @@ -1343,14 +1107,11 @@ void shouldReturnClaimNotified_whenCaseDataAtStateClaimNotified_andBothSolicitor CLAIM_ISSUED.fullName(), CLAIM_NOTIFIED.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), entry("TWO_RESPONDENT_REPRESENTATIVES", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false)); } @Test @@ -1380,13 +1141,10 @@ void shouldReturnAwaitingCaseNotification_whenCaseDataAtStateAwaitingCaseDetails PENDING_CLAIM_ISSUED.fullName(), CLAIM_ISSUED.fullName(), CLAIM_NOTIFIED.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), entry("ONE_RESPONDENT_REPRESENTATIVE", true), - entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false)); } @Test @@ -1411,12 +1169,9 @@ void shouldReturnClaimDetailsNotified_whenCaseDataAtStateClaimDetailsNotified() CLAIM_DETAILS_NOTIFIED.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry("ONE_RESPONDENT_REPRESENTATIVE", true), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry("ONE_RESPONDENT_REPRESENTATIVE", true)); } @Test @@ -1449,13 +1204,10 @@ void shouldReturnClaimDetailsNotified_whenCaseDataAtStateClaimDetailsNotifiedBot CLAIM_DETAILS_NOTIFIED.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), entry("TWO_RESPONDENT_REPRESENTATIVES", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false)); } @Test @@ -1512,12 +1264,9 @@ void shouldReturnClaimDetailsNotifiedTimeExtension_whenCaseDataAtStateClaimDetai CLAIM_DETAILS_NOTIFIED.fullName(), CLAIM_DETAILS_NOTIFIED_TIME_EXTENSION.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false)); } @Test @@ -1548,12 +1297,9 @@ void shouldReturnClaimAcknowledge_whenCaseDataAtStateClaimAcknowledge() { CLAIM_DETAILS_NOTIFIED.fullName(), NOTIFICATION_ACKNOWLEDGED.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false)); } @Test @@ -1586,12 +1332,9 @@ void shouldReturnNotificationAcknowledgedTimeExtension_whenCaseDataAtStateClaimA NOTIFICATION_ACKNOWLEDGED_TIME_EXTENSION.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false)); } @Test @@ -1622,13 +1365,10 @@ void shouldReturnClaimDismissed_whenCaseDataAtStateClaimAcknowledgeAndCcdStateIs CLAIM_DISMISSED_PAST_CLAIM_DISMISSED_DEADLINE.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false)); } @Test @@ -1653,12 +1393,9 @@ void shouldReturnExtensionRequested_whenCaseDataAtStateClaimDetailsNotifiedTimeE CLAIM_DETAILS_NOTIFIED.fullName(), CLAIM_DETAILS_NOTIFIED_TIME_EXTENSION.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false)); } @Nested @@ -1689,12 +1426,9 @@ void shouldReturnFullDefence_whenCaseDataAtStateRespondentFullDefence() { ALL_RESPONSES_RECEIVED.fullName(), FULL_DEFENCE.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry("ONE_RESPONDENT_REPRESENTATIVE", true), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry("ONE_RESPONDENT_REPRESENTATIVE", true)); } @Test @@ -1734,12 +1468,9 @@ void shouldReturnFullAdmission_whenCaseDataAtStateRespondentFullAdmission() { FULL_ADMISSION.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry("ONE_RESPONDENT_REPRESENTATIVE", true), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry("ONE_RESPONDENT_REPRESENTATIVE", true)); } @Test @@ -1773,12 +1504,9 @@ void shouldReturnPartAdmission_whenCaseDataAtStateRespondentPartAdmission() { PART_ADMISSION.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false)); } @Test @@ -1816,12 +1544,9 @@ void shouldReturnCounterClaim_whenCaseDataAtStateRespondentCounterClaim() { COUNTER_CLAIM.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false)); } } @@ -1861,13 +1586,10 @@ void shouldGenerateDQ_1v2DiffSol_whenFirstResponseIsFullDefence() { AWAITING_RESPONSES_FULL_DEFENCE_RECEIVED.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), entry("TWO_RESPONDENT_REPRESENTATIVES", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false)); } //1v2 Different solicitor scenario-first response FullDefence received @@ -1903,13 +1625,10 @@ void shouldGenerateDQ_1v2DiffSol_whenFirstResponseIsNotFullDefence() { AWAITING_RESPONSES_NOT_FULL_DEFENCE_RECEIVED.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), entry("TWO_RESPONDENT_REPRESENTATIVES", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false)); } //1v2 Different solicitor scenario-first response FullDefence received @@ -1945,13 +1664,10 @@ void shouldGenerateDQ_in1v2Scenario_whenFirstPartySubmitFullDefenceResponse() { AWAITING_RESPONSES_FULL_DEFENCE_RECEIVED.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), entry("TWO_RESPONDENT_REPRESENTATIVES", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false)); } //1v2 Different solicitor scenario-first party acknowledges, not responds @@ -1988,13 +1704,10 @@ void shouldGenerateDQ_in1v2Scenario_whenSecondPartySubmitFullDefenceResponse() { AWAITING_RESPONSES_FULL_DEFENCE_RECEIVED.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry("TWO_RESPONDENT_REPRESENTATIVES", true), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry("TWO_RESPONDENT_REPRESENTATIVES", true)); } //Respondent 1 submits FULL DEFENCE, Respondent 2 submits FULL DEFENCE @@ -2030,13 +1743,10 @@ void shouldReturnFullDefence_in1v2Scenario_whenBothPartiesSubmitFullDefenceRespo ALL_RESPONSES_RECEIVED.fullName(), FULL_DEFENCE.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry("TWO_RESPONDENT_REPRESENTATIVES", true), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry("TWO_RESPONDENT_REPRESENTATIVES", true)); } //Respondent 1 and 2 acknowledges claim, then submits FULL DEFENCE @@ -2073,13 +1783,10 @@ void shouldReturnFullDefence_in1v2Scenario_whenBothPartiesAcknowledgedAndSubmitF ALL_RESPONSES_RECEIVED.fullName(), FULL_DEFENCE.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry("TWO_RESPONDENT_REPRESENTATIVES", true), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry("TWO_RESPONDENT_REPRESENTATIVES", true)); } //Respondent 1 acknowledges claim, then Respondent 1 & 2 submits FULL DEFENCE @@ -2117,13 +1824,10 @@ void shouldReturnFullDefence_in1v2Scenario_whenRep1AcknowledgedAndBothSubmitFull ALL_RESPONSES_RECEIVED.fullName(), FULL_DEFENCE.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry("TWO_RESPONDENT_REPRESENTATIVES", true), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry("TWO_RESPONDENT_REPRESENTATIVES", true)); } // Respondent 2 acknowledges claim, Respondent 1 & 2 submits FULL DEFENCE @@ -2161,10 +1865,8 @@ void shouldReturnFullDefence_in1v2Scenario_whenRep2AcknowledgedAndBothSubmitFull ALL_RESPONSES_RECEIVED.fullName(), FULL_DEFENCE.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), entry("TWO_RESPONDENT_REPRESENTATIVES", true) ); @@ -2203,10 +1905,8 @@ void shouldReturnDivergentResponseAndGoOffline_1v2Scenario_whenFirstRespondentSu ALL_RESPONSES_RECEIVED.fullName(), DIVERGENT_RESPOND_GO_OFFLINE.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), entry("TWO_RESPONDENT_REPRESENTATIVES", true) ); @@ -2246,10 +1946,8 @@ void shouldReturnDivergentResponse_in1v2SameSolicitorScenario_whenOneRespondentS ALL_RESPONSES_RECEIVED.fullName(), DIVERGENT_RESPOND_GENERATE_DQ_GO_OFFLINE.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -2287,11 +1985,9 @@ void shouldReturnDivergentResponse_in1v2Scenario_whenNeitherRespondentSubmitsFul ALL_RESPONSES_RECEIVED.fullName(), DIVERGENT_RESPOND_GO_OFFLINE.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), entry("TWO_RESPONDENT_REPRESENTATIVES", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -2329,10 +2025,8 @@ void shouldReturnAdmitsPartResponse_in1v2Scenario_whenBothRespondentsSubmitAdmit ALL_RESPONSES_RECEIVED.fullName(), FULL_ADMISSION.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), entry("TWO_RESPONDENT_REPRESENTATIVES", true) ); @@ -2363,10 +2057,8 @@ void shouldReturnClaimDismissed_whenCaseDataAtStateClaimDismissed() { CLAIM_DISMISSED_PAST_CLAIM_DISMISSED_DEADLINE.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -2417,17 +2109,13 @@ void shouldReturnFullDefenceProceed_whenCaseDataAtStateApplicantRespondToDefence } if (flowState == FlowState.Main.FULL_DEFENCE_NOT_PROCEED) { - assertThat(stateFlow.getFlags()).hasSize(5).contains( - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), entry("ONE_RESPONDENT_REPRESENTATIVE", true) ); } else if (flowState == TAKEN_OFFLINE_AFTER_SDO) { - assertThat(stateFlow.getFlags()).hasSize(6).contains( - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), entry("ONE_RESPONDENT_REPRESENTATIVE", true), @@ -2504,12 +2192,10 @@ void shouldAwaitResponse_1v2DiffSol_whenFirstResponseIsFullDefenceAndTimeExtensi AWAITING_RESPONSES_FULL_DEFENCE_RECEIVED.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), entry("TWO_RESPONDENT_REPRESENTATIVES", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -2556,13 +2242,11 @@ void shouldAwaitResponse_1v2DiffSol_whenBothRespondFullDefenceAndTimeExtension() FULL_DEFENCE.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry("TWO_RESPONDENT_REPRESENTATIVES", true), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) + entry("TWO_RESPONDENT_REPRESENTATIVES", true) ); } @@ -2602,11 +2286,9 @@ void shouldAwaitResponse_1v2DiffSol_whenFirstResponseIsFullDefenceAfterAcknowled AWAITING_RESPONSES_FULL_DEFENCE_RECEIVED.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), entry("TWO_RESPONDENT_REPRESENTATIVES", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -2632,9 +2314,7 @@ void shouldReturnProceedsWithOfflineJourney_whenCaseDataIsCaseProceedsInCaseman( PENDING_CLAIM_ISSUED.fullName(), CLAIM_ISSUED.fullName(), TAKEN_OFFLINE_BY_STAFF.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), entry("ONE_RESPONDENT_REPRESENTATIVE", true) ); @@ -2690,9 +2370,7 @@ void shouldReturnTakenOffline_whenApplicantIsOutOfTimeAndCamundaHasProcessedCase TAKEN_OFFLINE_PAST_APPLICANT_RESPONSE_DEADLINE.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), entry("ONE_RESPONDENT_REPRESENTATIVE", true) ); @@ -2752,9 +2430,7 @@ void shouldReturnClaimDismissedState_whenPastClaimNotificationDeadlineAndProcess CLAIM_DISMISSED_HEARING_FEE_DUE_DEADLINE.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), entry("ONE_RESPONDENT_REPRESENTATIVE", true), @@ -2846,10 +2522,8 @@ void shouldReturnCaseDismissedState_whenCaseDataIsPastClaimDetailsNotificationAn CLAIM_DISMISSED_PAST_CLAIM_DETAILS_NOTIFICATION_DEADLINE.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), entry("ONE_RESPONDENT_REPRESENTATIVE", true) ); @@ -2879,9 +2553,7 @@ void shouldReturnClaimDismissedState_whenPastHearingFeeDueDeadlineAndProcessedBy CLAIM_DISMISSED_HEARING_FEE_DUE_DEADLINE.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), entry(FlowFlag.SDO_ENABLED.name(), false) ); @@ -2929,11 +2601,9 @@ void shouldReturnClaimantResponse_FullDefence_in1v2Scenario_whenRep2Acknowledged FULL_DEFENCE_PROCEED.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(8).contains( + assertThat(stateFlow.getFlags()).hasSize(6).contains( entry("BULK_CLAIM_ENABLED", false), entry("ONE_RESPONDENT_REPRESENTATIVE", false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), entry("TWO_RESPONDENT_REPRESENTATIVES", true), entry(FlowFlag.IS_MULTI_TRACK.name(), true), @@ -2967,11 +2637,9 @@ void shouldReturnProceedsWithOfflineJourney_whenCaseTakenOfflineAfterClaimIssue( PENDING_CLAIM_ISSUED.fullName(), CLAIM_ISSUED.fullName(), TAKEN_OFFLINE_BY_STAFF.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -2998,11 +2666,9 @@ void shouldReturnProceedsWithOfflineJourney_whenCaseTakenOfflineAfterClaimIssueS PENDING_CLAIM_ISSUED.fullName(), CLAIM_ISSUED.fullName(), TAKEN_OFFLINE_BY_STAFF.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -3029,11 +2695,9 @@ void shouldReturnProceedsWithOfflineJourney_whenCaseTakenOfflineAfterClaimNotifi TAKEN_OFFLINE_BY_STAFF.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -3060,11 +2724,9 @@ void shouldReturnProceedsWithOfflineJourney_whenCaseTakenOfflineAfterClaimDetail CLAIM_DETAILS_NOTIFIED.fullName(), TAKEN_OFFLINE_BY_STAFF.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -3093,11 +2755,9 @@ void shouldReturnProceedsWithOfflineJourney_whenCaseTakenOfflineAfterClaimDetail TAKEN_OFFLINE_BY_STAFF.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -3126,11 +2786,9 @@ void shouldReturnProceedsWithOfflineJourney_whenCaseTakenOfflineAfterNotificatio TAKEN_OFFLINE_BY_STAFF.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -3160,11 +2818,9 @@ void shouldReturnProceedsWithOfflineJourney_whenCaseTakenOfflineAfterNotificatio NOTIFICATION_ACKNOWLEDGED_TIME_EXTENSION.fullName(), TAKEN_OFFLINE_BY_STAFF.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -3202,12 +2858,10 @@ void shouldAwaitResponse_1v2DiffSol_whenFirstResponseIsFullDefenceAfterAcknowled TAKEN_OFFLINE_BY_STAFF.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), entry("TWO_RESPONDENT_REPRESENTATIVES", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -3236,11 +2890,9 @@ void shouldReturnProceedsWithOfflineJourney_whenCaseTakenOfflineAfterDefendantRe ALL_RESPONSES_RECEIVED.fullName(), FULL_DEFENCE.fullName(), TAKEN_OFFLINE_BY_STAFF.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -3271,11 +2923,9 @@ void shouldReturnProceedsWithOfflineJourney_whenCaseTakenOfflinePastClaimNotific TAKEN_OFFLINE_BY_STAFF.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -3306,11 +2956,9 @@ void shouldReturnProceedsWithOfflineJourney_whenCaseTakenOfflinePastClaimDetails TAKEN_OFFLINE_BY_STAFF.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -3432,11 +3080,9 @@ void shouldReturnAwaitingCamundaState_whenDeadlinePassedAfterStateClaimDetailsNo PAST_CLAIM_DISMISSED_DEADLINE_AWAITING_CAMUNDA.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -3475,12 +3121,10 @@ void shouldReturnDismissedState_whenDeadlinePassedAfterClaimDetailsNotifiedExten ); assertThat(stateFlow.getFlags()) - .hasSize(5) + .hasSize(3) .contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -3517,11 +3161,9 @@ void shouldReturnClaimDismissedPastDeadline_whenDeadlinePassedAfterStateNotifica PAST_CLAIM_DISMISSED_DEADLINE_AWAITING_CAMUNDA.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -3554,11 +3196,9 @@ void shouldReturnDismissedState_whenDeadlinePassedAfterNotificationAcknowledgedA CLAIM_DISMISSED_PAST_CLAIM_DISMISSED_DEADLINE.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -3656,11 +3296,9 @@ void shouldReturnClaimDismissed_whenCaseDataAtStateClaimDismissed() { CLAIM_DISMISSED_PAST_CLAIM_DISMISSED_DEADLINE.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -3729,12 +3367,10 @@ void shouldGenerateDQ_1v2DiffSol_whenFirstResponseIsFullDefence() { AWAITING_RESPONSES_FULL_DEFENCE_RECEIVED.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), entry("TWO_RESPONDENT_REPRESENTATIVES", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -3772,12 +3408,10 @@ void shouldGenerateDQ_1v2DiffSol_whenFirstResponseIsNotFullDefence() { AWAITING_RESPONSES_NOT_FULL_DEFENCE_RECEIVED.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), entry("TWO_RESPONDENT_REPRESENTATIVES", true), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -3815,12 +3449,10 @@ void shouldGenerateDQ_in1v2Scenario_whenFirstPartySubmitFullDefenceResponse() { AWAITING_RESPONSES_FULL_DEFENCE_RECEIVED.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), entry("TWO_RESPONDENT_REPRESENTATIVES", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -3859,12 +3491,10 @@ void shouldGenerateDQ_in1v2Scenario_whenSecondPartySubmitFullDefenceResponse() { AWAITING_RESPONSES_FULL_DEFENCE_RECEIVED.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), entry("TWO_RESPONDENT_REPRESENTATIVES", true), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -3901,12 +3531,10 @@ void shouldReturnFullDefence_in1v2Scenario_whenBothPartiesSubmitFullDefenceRespo ALL_RESPONSES_RECEIVED.fullName(), FULL_DEFENCE.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), entry("TWO_RESPONDENT_REPRESENTATIVES", true), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -3944,12 +3572,10 @@ void shouldReturnFullDefence_in1v2Scenario_whenBothPartiesAcknowledgedAndSubmitF ALL_RESPONSES_RECEIVED.fullName(), FULL_DEFENCE.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), entry("TWO_RESPONDENT_REPRESENTATIVES", true), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -3989,12 +3615,10 @@ void shouldReturnFullDefence_in1v2Scenario_whenRep1AcknowledgedAndBothSubmitFull ALL_RESPONSES_RECEIVED.fullName(), FULL_DEFENCE.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), entry("TWO_RESPONDENT_REPRESENTATIVES", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -4034,13 +3658,11 @@ void shouldReturnFullDefence_in1v2Scenario_whenRep2AcknowledgedAndBothSubmitFull ALL_RESPONSES_RECEIVED.fullName(), FULL_DEFENCE.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), entry("TWO_RESPONDENT_REPRESENTATIVES", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) + entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -4077,12 +3699,10 @@ void shouldReturnDivergentResponseAndGoOffline_1v2Scenario_whenFirstRespondentSu ALL_RESPONSES_RECEIVED.fullName(), DIVERGENT_RESPOND_GO_OFFLINE.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), entry("TWO_RESPONDENT_REPRESENTATIVES", true), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -4121,10 +3741,8 @@ void shouldReturnDivergentResponse_in1v2SameSolicitorScenario_whenOneRespondentS ALL_RESPONSES_RECEIVED.fullName(), DIVERGENT_RESPOND_GENERATE_DQ_GO_OFFLINE.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); @@ -4163,12 +3781,10 @@ void shouldReturnDivergentResponse_in1v2Scenario_whenNeitherRespondentSubmitsFul ALL_RESPONSES_RECEIVED.fullName(), DIVERGENT_RESPOND_GO_OFFLINE.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), entry("TWO_RESPONDENT_REPRESENTATIVES", true), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -4206,12 +3822,10 @@ void shouldReturnAdmitsPartResponse_in1v2Scenario_whenBothRespondentsSubmitAdmit ALL_RESPONSES_RECEIVED.fullName(), FULL_ADMISSION.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", false), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), entry("TWO_RESPONDENT_REPRESENTATIVES", true), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -4501,12 +4115,10 @@ void shouldReturnContactDetailsChange_whenCaseDataAtStateRespondentContactDetail PENDING_CLAIM_ISSUED.fullName(), CLAIM_ISSUED.fullName(), CONTACT_DETAILS_CHANGE.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(6).contains( - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), + assertThat(stateFlow.getFlags()).hasSize(4).contains( entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), entry(FlowFlag.CONTACT_DETAILS_CHANGE.name(), true), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false), entry("ONE_RESPONDENT_REPRESENTATIVE", true) ); } @@ -4686,13 +4298,10 @@ void shouldReturnInHearingReadiness_whenTransitionedFromCaseDetailsNotified() { CLAIM_DETAILS_NOTIFIED.fullName(), IN_HEARING_READINESS.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry("ONE_RESPONDENT_REPRESENTATIVE", true), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry("ONE_RESPONDENT_REPRESENTATIVE", true)); } @Test @@ -4827,13 +4436,10 @@ void shouldReaturnTakenOfflineSdoNotDrawn_whenCaseDataAtStateClaimDetailsNotifie CLAIM_DETAILS_NOTIFIED.fullName(), TAKEN_OFFLINE_SDO_NOT_DRAWN.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry("ONE_RESPONDENT_REPRESENTATIVE", true), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry("ONE_RESPONDENT_REPRESENTATIVE", true)); } @Test @@ -4860,13 +4466,10 @@ void shouldReaturnTakenOfflineSdoNotDrawn_whenCaseDataAtStateClaimDetailsNotifie TAKEN_OFFLINE_SDO_NOT_DRAWN.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false)); } @Test @@ -4900,13 +4503,10 @@ void shouldReaturnTakenOfflineSdoNotDrawn_whenCaseDataAtStateClaimAcknowledge() TAKEN_OFFLINE_SDO_NOT_DRAWN.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false)); } @Test @@ -4940,13 +4540,10 @@ void shouldReaturnTakenOfflineSdoNotDrawn_whenCaseDataAtStateClaimAcknowledgeTim NOTIFICATION_ACKNOWLEDGED_TIME_EXTENSION.fullName(), TAKEN_OFFLINE_SDO_NOT_DRAWN.fullName() ); - assertThat(stateFlow.getFlags()).hasSize(5).contains( + assertThat(stateFlow.getFlags()).hasSize(3).contains( entry("ONE_RESPONDENT_REPRESENTATIVE", true), entry(FlowFlag.BULK_CLAIM_ENABLED.name(), false), - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) - ); + entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false)); } @Test @@ -5010,4 +4607,77 @@ void shouldContinueOnline_1v1Spec_whenDefendantIsUnrepresented() { } } + @Nested + class FromPartAdmitRepaymentAgreed { + @Test + void partAdmitRepaymentAgreedSpec() { + CaseData caseData = CaseData.builder() + // spec claim + .caseAccessCategory(SPEC_CLAIM) + // claim submitted + .submittedDate(LocalDateTime.now()) + .respondent1Represented(YES) + // payment successful + .paymentSuccessfulDate(LocalDateTime.now()) + // pending claim issued + .issueDate(LocalDate.now()) + .respondent1OrgRegistered(YES) + // claim issued + .claimNotificationDeadline(LocalDateTime.now()) + // part admit + .respondent1ResponseDate(LocalDateTime.now()) + .caseDataLiP(CaseDataLiP.builder().respondentSignSettlementAgreement(YES) + .applicant1ClaimMediationSpecRequiredLip(ClaimantMediationLip.builder().hasAgreedFreeMediation(MediationDecision.No).build()) + .build()) + .respondent1ClaimResponseTypeForSpec(RespondentResponseTypeSpec.PART_ADMISSION) + .claimNotificationDate(LocalDateTime.now()) + .responseClaimTrack(AllocatedTrack.SMALL_CLAIM.name()) + .applicant1PartAdmitConfirmAmountPaidSpec(YES) + .ccdState(CaseState.All_FINAL_ORDERS_ISSUED) + .applicant1AcceptFullAdmitPaymentPlanSpec(YES) + .build(); + + // When + StateFlow fullState = stateFlowEngine.evaluate(caseData); + + // Then + assertEquals(SIGN_SETTLEMENT_AGREEMENT.fullName(), fullState.getState().getName()); + } + } + + @Nested + class FromFullAdmitRepaymentAgreed { + @Test + void fullAdmitRepaymentAgreedSpec() { + CaseData caseData = CaseData.builder() + // spec claim + .caseAccessCategory(SPEC_CLAIM) + .submittedDate(LocalDateTime.now()) + .respondent1Represented(YES) + // payment successful + .paymentSuccessfulDate(LocalDateTime.now()) + // pending claim issued + .issueDate(LocalDate.now()) + .respondent1OrgRegistered(YES) + // claim issued + .claimNotificationDeadline(LocalDateTime.now()) + // part admit + .respondent1ResponseDate(LocalDateTime.now()) + .caseDataLiP(CaseDataLiP.builder().respondentSignSettlementAgreement(YES) + .applicant1ClaimMediationSpecRequiredLip(ClaimantMediationLip.builder().hasAgreedFreeMediation(MediationDecision.No).build()) + .build()) + .respondent1ClaimResponseTypeForSpec(RespondentResponseTypeSpec.FULL_ADMISSION) + .claimNotificationDate(LocalDateTime.now()) + .responseClaimTrack(AllocatedTrack.SMALL_CLAIM.name()) + .ccdState(CaseState.All_FINAL_ORDERS_ISSUED) + .applicant1AcceptFullAdmitPaymentPlanSpec(YES) + .build(); + + // When + StateFlow fullState = stateFlowEngine.evaluate(caseData); + + // Then + assertEquals(SIGN_SETTLEMENT_AGREEMENT.fullName(), fullState.getState().getName()); + } + } } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/flowstate/StateFlowEngineUnspecTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/flowstate/StateFlowEngineUnspecTest.java index c1491419ecb..c63730aa2ac 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/flowstate/StateFlowEngineUnspecTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/flowstate/StateFlowEngineUnspecTest.java @@ -43,8 +43,6 @@ public class StateFlowEngineUnspecTest { @BeforeEach void setup() { given(featureToggleService.isGeneralApplicationsEnabled()).willReturn(false); - given(featureToggleService.isCertificateOfServiceEnabled()).willReturn(false); - given(featureToggleService.isNoticeOfChangeEnabled()).willReturn(false); } static Stream caseDataStream() { @@ -119,11 +117,9 @@ void shouldContainCommonFlags_whenCaseDataAtStateClaimSubmitted(CaseData caseDat //When StateFlow stateFlow = stateFlowEngine.evaluate(caseData); - // Then Claim will have NOTICE_OF_CHANGE, GENERAL_APPLICATION_ENABLED, CERTIFICATE_OF_SERVICE and RPA_CONTINUOUS_FEED + // Then Claim will have GENERAL_APPLICATION_ENABLED and RPA_CONTINUOUS_FEED assertThat(stateFlow.getFlags()).contains( - entry(FlowFlag.NOTICE_OF_CHANGE.name(), false), - entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false), - entry(FlowFlag.CERTIFICATE_OF_SERVICE.name(), false) + entry(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), false) ); } @@ -137,7 +133,7 @@ void shouldHaveOneRespondentRepresentativeFlagsSet_whenCaseDataAtStateClaimSubmi assertThat(stateFlow.getFlags()).contains( entry(FlowFlag.ONE_RESPONDENT_REPRESENTATIVE.name(), true) ); - assertThat(stateFlow.getFlags()).hasSize(5); // bonus: if this fails, a flag was added/removed but tests were not updated + assertThat(stateFlow.getFlags()).hasSize(3); // bonus: if this fails, a flag was added/removed but tests were not updated } @ParameterizedTest(name = "{index}: The state flow flags ONE_RESPONDENT_REPRESENTATIVE " + @@ -152,7 +148,7 @@ void shouldReturnClaimSubmitted_whenCaseDataAtStateClaimSubmitted1v2DiffSoliBoth entry(FlowFlag.ONE_RESPONDENT_REPRESENTATIVE.name(), false), entry(FlowFlag.TWO_RESPONDENT_REPRESENTATIVES.name(), true) ); - assertThat(stateFlow.getFlags()).hasSize(6); // bonus: if this fails, a flag was added/removed but tests were not updated + assertThat(stateFlow.getFlags()).hasSize(4); // bonus: if this fails, a flag was added/removed but tests were not updated } public interface StubbingFn extends Function> { @@ -160,10 +156,8 @@ public interface StubbingFn extends Function commonFlagNames() { return Stream.of( - arguments(FlowFlag.NOTICE_OF_CHANGE.name(), (StubbingFn)(featureToggleService) -> when(featureToggleService.isNoticeOfChangeEnabled())), - arguments(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), (StubbingFn)(featureToggleService) -> when(featureToggleService.isGeneralApplicationsEnabled())), - arguments(FlowFlag.CERTIFICATE_OF_SERVICE.name(), (StubbingFn)(featureToggleService) -> when(featureToggleService.isCertificateOfServiceEnabled())) - ); + arguments(FlowFlag.GENERAL_APPLICATION_ENABLED.name(), + (StubbingFn)(featureToggleService) -> when(featureToggleService.isGeneralApplicationsEnabled()))); } @ParameterizedTest(name = "{index}: The feature flags are carried to the appropriate state flow flags") diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/robotics/mapper/EventHistoryMapperTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/robotics/mapper/EventHistoryMapperTest.java index b7632f0aad4..2e8789ce5ce 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/robotics/mapper/EventHistoryMapperTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/robotics/mapper/EventHistoryMapperTest.java @@ -132,94 +132,8 @@ void setup() { when(locationRefDataUtil.getPreferredCourtData(any(), any(), eq(true))).thenReturn("121"); } - @Nested - class UnrepresentedDefendant { - - @Test - void shouldPrepareMiscellaneousEvent_whenClaimWith1v1UnrepresentedDefendant() { - CaseData caseData = CaseDataBuilder.builder().atStateClaimIssued1v1UnrepresentedDefendant().build(); - Event expectedEvent = Event.builder() - .eventSequence(1) - .eventCode("999") - .dateReceived(caseData.getSubmittedDate()) - .eventDetailsText("RPA Reason: Unrepresented defendant: Mr. Sole Trader") - .eventDetails(EventDetails.builder() - .miscText("RPA Reason: Unrepresented defendant: Mr. Sole Trader") - .build()) - .build(); - - var eventHistory = mapper.buildEvents(caseData); - - assertThat(eventHistory).isNotNull(); - assertThat(eventHistory) - .extracting("miscellaneous") - .asList() - .containsExactly(expectedEvent); - assertEmptyEvents( - eventHistory, - "acknowledgementOfServiceReceived", - "consentExtensionFilingDefence", - "defenceFiled", - "defenceAndCounterClaim", - "receiptOfPartAdmission", - "receiptOfAdmission", - "replyToDefence", - "directionsQuestionnaireFiled" - ); - } - - @Test - void shouldPrepareMiscellaneousEvent_whenClaimWith2UnrepresentedDefendants() { - CaseData caseData = CaseDataBuilder.builder().atStateClaimIssuedUnrepresentedDefendants().build(); - - Event expectedEvent1 = Event.builder() - .eventSequence(1) - .eventCode("999") - .dateReceived(caseData.getSubmittedDate()) - .eventDetailsText("RPA Reason: [1 of 2 - 2020-08-01] Unrepresented defendant: Mr. Sole Trader") - .eventDetails(EventDetails.builder() - .miscText("RPA Reason: [1 of 2 - 2020-08-01] " - + "Unrepresented defendant: Mr. Sole Trader") - .build()) - .build(); - - Event expectedEvent2 = Event.builder() - .eventSequence(2) - .eventCode("999") - .dateReceived(caseData.getSubmittedDate()) - .eventDetailsText("RPA Reason: [2 of 2 - 2020-08-01] Unrepresented defendant: Mr. John Rambo") - .eventDetails(EventDetails.builder() - .miscText("RPA Reason: [2 of 2 - 2020-08-01] Unrepresented defendant: Mr. John Rambo") - .build()) - .build(); - - var eventHistory = mapper.buildEvents(caseData); - - assertThat(eventHistory).isNotNull(); - assertThat(eventHistory) - .extracting("miscellaneous") - .asList() - .containsExactly(expectedEvent1, expectedEvent2); - assertEmptyEvents( - eventHistory, - "acknowledgementOfServiceReceived", - "consentExtensionFilingDefence", - "defenceFiled", - "defenceAndCounterClaim", - "receiptOfPartAdmission", - "receiptOfAdmission", - "replyToDefence", - "directionsQuestionnaireFiled" - ); - } - } - @Nested class UnregisteredDefendant { - @BeforeEach - public void setup() { - when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(true); - } @Test void shouldPrepareMiscellaneousEvent_whenClaimWith1v1UnregisteredDefendant() { @@ -306,228 +220,10 @@ void shouldPrepareMiscellaneousEvent_whenClaimWith2UnregisteredDefendants() { "directionsQuestionnaireFiled" ); } - - @Nested - class ToBeRemovedAfterNOC { - @BeforeEach - public void setup() { - when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(false); - } - - @Test - void prod_shouldPrepareMiscellaneousEvent_whenClaimWith1v1UnregisteredDefendant() { - CaseData caseData = CaseDataBuilder.builder().atStateProceedsOffline1v1UnregisteredDefendant() - .respondent1OrganisationPolicy(null) - .respondent2OrganisationPolicy(null) - .build(); - Event expectedEvent = Event.builder() - .eventSequence(1) - .eventCode("999") - .dateReceived(caseData.getSubmittedDate()) - .eventDetailsText("RPA Reason: Unregistered defendant solicitor firm: Mr. Sole Trader") - .eventDetails(EventDetails.builder() - .miscText("RPA Reason: Unregistered defendant solicitor firm: Mr. Sole Trader") - .build()) - .build(); - - var eventHistory = mapper.buildEvents(caseData); - - assertThat(eventHistory).isNotNull(); - assertThat(eventHistory) - .extracting("miscellaneous") - .asList() - .containsExactly(expectedEvent); - assertEmptyEvents( - eventHistory, - "acknowledgementOfServiceReceived", - "consentExtensionFilingDefence", - "defenceFiled", - "defenceAndCounterClaim", - "receiptOfPartAdmission", - "receiptOfAdmission", - "replyToDefence", - "directionsQuestionnaireFiled" - ); - } - - @Test - void prod_shouldPrepareMiscellaneousEvent_whenClaimWith2UnregisteredDefendants() { - CaseData caseData = CaseDataBuilder.builder().atStateProceedsOfflineUnregisteredDefendants() - .respondent1OrganisationPolicy(null) - .respondent2OrganisationPolicy(null) - .build(); - Event expectedEvent1 = Event.builder() - .eventSequence(1) - .eventCode("999") - .dateReceived(caseData.getSubmittedDate()) - .eventDetailsText("RPA Reason: [1 of 2 - 2020-08-01] " - + "Unregistered defendant solicitor firm: Mr. Sole Trader") - .eventDetails(EventDetails.builder() - .miscText("RPA Reason: [1 of 2 - 2020-08-01] " - + "Unregistered defendant solicitor firm: Mr. Sole Trader") - .build()) - .build(); - - Event expectedEvent2 = Event.builder() - .eventSequence(2) - .eventCode("999") - .dateReceived(caseData.getSubmittedDate()) - .eventDetailsText("RPA Reason: [2 of 2 - 2020-08-01] " - + "Unregistered defendant solicitor firm: Mr. John Rambo") - .eventDetails(EventDetails.builder() - .miscText("RPA Reason: [2 of 2 - 2020-08-01] " - + "Unregistered defendant solicitor firm: Mr. John Rambo") - .build()) - .build(); - - var eventHistory = mapper.buildEvents(caseData); - - assertThat(eventHistory).isNotNull(); - assertThat(eventHistory) - .extracting("miscellaneous") - .asList() - .containsExactly(expectedEvent1, expectedEvent2); - assertEmptyEvents( - eventHistory, - "acknowledgementOfServiceReceived", - "consentExtensionFilingDefence", - "defenceFiled", - "defenceAndCounterClaim", - "receiptOfPartAdmission", - "receiptOfAdmission", - "replyToDefence", - "directionsQuestionnaireFiled" - ); - } - } } @Nested class UnrepresentedAndUnregisteredDefendant { - @BeforeEach - public void setup() { - when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(true); - } - - // Remove after NOC - @Nested - class ToBeRemovedAfterNOC { - @BeforeEach - public void setup() { - when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(false); - } - - @Test - void prod_shouldPrepareMiscellaneousEvent_whenClaimWithUnrepresentedDefendant1UnregisteredDefendant2() { - CaseData caseData = CaseDataBuilder.builder() - .atStateProceedsOfflineUnrepresentedDefendant1UnregisteredDefendant2() - .respondent1OrganisationPolicy(null) - .respondent2OrganisationPolicy(null) - .build(); - Event expectedEvent1 = Event.builder() - .eventSequence(1) - .eventCode("999") - .dateReceived(caseData.getSubmittedDate()) - .eventDetailsText("RPA Reason: [1 of 2 - 2020-08-01] " - + "Unrepresented defendant and unregistered defendant solicitor firm. " - + "Unrepresented defendant: Mr. Sole Trader") - .eventDetails(EventDetails.builder() - .miscText("RPA Reason: [1 of 2 - 2020-08-01] " - + "Unrepresented defendant and unregistered defendant solicitor firm. " - + "Unrepresented defendant: Mr. Sole Trader") - .build()) - .build(); - - Event expectedEvent2 = Event.builder() - .eventSequence(2) - .eventCode("999") - .dateReceived(caseData.getSubmittedDate()) - .eventDetailsText("RPA Reason: [2 of 2 - 2020-08-01] " - + "Unrepresented defendant and unregistered defendant solicitor firm. " - + "Unregistered defendant solicitor firm: Mr. John Rambo") - .eventDetails(EventDetails.builder() - .miscText("RPA Reason: [2 of 2 - 2020-08-01] " - + "Unrepresented defendant and unregistered defendant solicitor firm. " - + "Unregistered defendant solicitor firm: Mr. John Rambo") - .build()) - .build(); - - var eventHistory = mapper.buildEvents(caseData); - - assertThat(eventHistory).isNotNull(); - assertThat(eventHistory) - .extracting("miscellaneous") - .asList() - .containsExactly(expectedEvent1, expectedEvent2); - assertEmptyEvents( - eventHistory, - "acknowledgementOfServiceReceived", - "consentExtensionFilingDefence", - "defenceFiled", - "defenceAndCounterClaim", - "receiptOfPartAdmission", - "receiptOfAdmission", - "replyToDefence", - "directionsQuestionnaireFiled" - ); - } - - @Test - void prod_shouldPrepareMiscellaneousEvent_whenClaimWithUnregisteredDefendant1UnrepresentedDefendant2() { - CaseData caseData = CaseDataBuilder.builder() - .atStateProceedsOfflineUnregisteredDefendant1UnrepresentedDefendant2() - .respondent1OrganisationPolicy(null) - .respondent2OrganisationPolicy(null) - .build(); - Event expectedEvent1 = Event.builder() - .eventSequence(1) - .eventCode("999") - .dateReceived(caseData.getSubmittedDate()) - .eventDetailsText("RPA Reason: [1 of 2 - 2020-08-01] " - + "Unrepresented defendant and unregistered defendant solicitor firm. " - + "Unrepresented defendant: Mr. John Rambo") - .eventDetails(EventDetails.builder() - .miscText("RPA Reason: [1 of 2 - 2020-08-01] " - + "Unrepresented defendant and unregistered defendant solicitor firm. " - + "Unrepresented defendant: Mr. John Rambo") - .build()) - .build(); - - Event expectedEvent2 = Event.builder() - .eventSequence(2) - .eventCode("999") - .dateReceived(caseData.getSubmittedDate()) - .eventDetailsText("RPA Reason: [2 of 2 - 2020-08-01] " - + "Unrepresented defendant and unregistered defendant solicitor firm. " - + "Unregistered defendant solicitor firm: Mr. Sole Trader") - .eventDetails(EventDetails.builder() - .miscText("RPA Reason: [2 of 2 - 2020-08-01] " - + "Unrepresented defendant and unregistered defendant solicitor firm. " - + "Unregistered defendant solicitor firm: Mr. Sole Trader") - .build()) - .build(); - - var eventHistory = mapper.buildEvents(caseData); - - assertThat(eventHistory).isNotNull(); - assertThat(eventHistory) - .extracting("miscellaneous") - .asList() - .containsExactly(expectedEvent1, expectedEvent2); - assertEmptyEvents( - eventHistory, - "acknowledgementOfServiceReceived", - "consentExtensionFilingDefence", - "defenceFiled", - "defenceAndCounterClaim", - "receiptOfPartAdmission", - "receiptOfAdmission", - "replyToDefence", - "directionsQuestionnaireFiled" - ); - } - - } @Test void shouldPrepareMiscellaneousEvent_whenClaimWithUnrepresentedDefendant1UnregisteredDefendant2() { @@ -7418,56 +7114,6 @@ private void assertEmptyEvents(EventHistory eventHistory, String... eventNames) eventName -> assertThat(eventHistory).extracting(eventName).asList().containsOnly(EMPTY_EVENT)); } - @Test - public void specCaseEvents() { - CaseData caseData = CaseDataBuilder.builder() - .atStateClaimIssued1v2UnrepresentedDefendant() - .defendant1LIPAtClaimIssued(NO) - .defendant2LIPAtClaimIssued(null) - .build().toBuilder() - .caseAccessCategory(SPEC_CLAIM) - .build(); - when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(false); - Event expectedEvent = Event.builder() - .eventSequence(1) - .eventCode("999") - .dateReceived(caseData.getSubmittedDate()) - .eventDetailsText("RPA Reason: [1 of 2 - 2020-08-01] Unrepresented defendant: Mr. Sole Trader") - .eventDetails(EventDetails.builder() - .miscText("RPA Reason: [1 of 2 - 2020-08-01] Unrepresented defendant: Mr. Sole Trader") - .build()) - .build(); - - Event expectedEvent2 = Event.builder() - .eventSequence(2) - .eventCode("999") - .dateReceived(caseData.getSubmittedDate()) - .eventDetailsText("RPA Reason: [2 of 2 - 2020-08-01] Unrepresented defendant: Mr. John Rambo") - .eventDetails(EventDetails.builder() - .miscText("RPA Reason: [2 of 2 - 2020-08-01] Unrepresented defendant: Mr. John Rambo") - .build()) - .build(); - - var eventHistory = mapper.buildEvents(caseData); - - assertThat(eventHistory).isNotNull(); - assertThat(eventHistory) - .extracting("miscellaneous") - .asList() - .containsExactly(expectedEvent, expectedEvent2); - assertEmptyEvents( - eventHistory, - "acknowledgementOfServiceReceived", - "consentExtensionFilingDefence", - "defenceFiled", - "defenceAndCounterClaim", - "receiptOfPartAdmission", - "receiptOfAdmission", - "replyToDefence", - "directionsQuestionnaireFiled" - ); - } - @Test void specShouldPrepareMiscellaneousEvent_whenCaseNoteAdded() { LocalDateTime noteCreatedOn = LocalDateTime.now().plusDays(3); diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/robotics/mapper/RoboticsDataMapperForSpecTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/robotics/mapper/RoboticsDataMapperForSpecTest.java index 19c4436f400..4bf9de10713 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/robotics/mapper/RoboticsDataMapperForSpecTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/robotics/mapper/RoboticsDataMapperForSpecTest.java @@ -5,7 +5,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.Mockito; import org.springframework.test.context.junit.jupiter.SpringExtension; import uk.gov.hmcts.reform.ccd.model.OrganisationPolicy; import uk.gov.hmcts.reform.ccd.model.PreviousOrganisation; @@ -82,7 +81,6 @@ public void whenSpecEnabled_includeBS() { @Test public void shouldMapExpectedNoticeOfChangeData_whenCaseGoesOffline() { - Mockito.when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(true); var app1NocDate = LocalDateTime.parse("2022-01-01T12:00:00.000550439"); var res1NocDate = LocalDateTime.parse("2022-02-01T12:00:00.000550439"); @@ -142,8 +140,6 @@ public void shouldMapExpectedNoticeOfChangeData_whenCaseGoesOffline() { @Test public void shouldMapExpectedNoticeOfChangeData_whenCaseDismissed() { - Mockito.when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(true); - var app1NocDate = LocalDateTime.parse("2022-01-01T12:00:00.000550439"); var res1NocDate = LocalDateTime.parse("2022-02-01T12:00:00.000550439"); var res2NocDate = LocalDateTime.parse("2022-03-01T12:00:00.000550439"); @@ -202,8 +198,6 @@ public void shouldMapExpectedNoticeOfChangeData_whenCaseDismissed() { @Test public void shouldNotPopulateNoticeOfChangeSection_whenCaseIsStillOnline() { - Mockito.when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(true); - CaseData caseData = CaseData.builder() .legacyCaseReference("reference") .submittedDate(LocalDateTime.now().minusDays(14)) diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/robotics/mapper/RoboticsDataMapperTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/robotics/mapper/RoboticsDataMapperTest.java index 230d1ff387c..3c5e2cd108d 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/robotics/mapper/RoboticsDataMapperTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/robotics/mapper/RoboticsDataMapperTest.java @@ -399,8 +399,6 @@ void shouldReturnEmptyStringWhenPreferredCourtCodeisUnavailableFromLocationRefDa @Test void shouldMapExpectedNoticeOfChangeData_whenCaseGoesOffline() { - when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(true); - CaseData caseData = CaseDataBuilder.builder() .atStatePaymentSuccessful() .build().toBuilder() @@ -437,8 +435,6 @@ void shouldMapExpectedNoticeOfChangeData_whenCaseGoesOffline() { @Test void shouldMapExpectedNoticeOfChangeData_whenCaseDismissed() { - when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(true); - CaseData caseData = CaseDataBuilder.builder() .atStatePaymentSuccessful() .build().toBuilder() @@ -475,8 +471,6 @@ void shouldMapExpectedNoticeOfChangeData_whenCaseDismissed() { @Test void shouldNotPopulateNoticeOfChangeSection_whenCaseIsStillOnline() { - when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(true); - var app1NocDate = LocalDateTime.parse("2022-01-01T12:00:00.000550439"); var res1NocDate = LocalDateTime.parse("2022-02-01T12:00:00.000550439"); var res2NocDate = LocalDateTime.parse("2022-03-01T12:00:00.000550439"); diff --git a/src/test/java/uk/gov/hmcts/reform/civil/utils/CaseFlagUtilsTest.java b/src/test/java/uk/gov/hmcts/reform/civil/utils/CaseFlagUtilsTest.java index aae666611d3..e326aebcf25 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/utils/CaseFlagUtilsTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/utils/CaseFlagUtilsTest.java @@ -35,6 +35,7 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.ONE_V_TWO_TWO_LEGAL_REP; import static uk.gov.hmcts.reform.civil.enums.YesOrNo.NO; import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES; import static uk.gov.hmcts.reform.civil.utils.CaseFlagUtils.APPLICANT_SOLICITOR_EXPERT; @@ -49,21 +50,27 @@ import static uk.gov.hmcts.reform.civil.utils.CaseFlagUtils.getAllCaseFlags; import static uk.gov.hmcts.reform.civil.utils.ElementUtils.unwrapElements; import static uk.gov.hmcts.reform.civil.utils.ElementUtils.wrapElements; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_ONE_EXPERTS_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_ONE_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_ONE_LEGAL_REP_INDIVIDUALS_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_ONE_LITIGATION_FRIEND_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_ONE_ORG_INDIVIDUALS_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_ONE_WITNESSES_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_TWO_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_TWO_LITIGATION_FRIEND_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_TWO_ORG_INDIVIDUALS_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_ONE_EXPERTS_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_ONE_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_ONE_LEGAL_REP_INDIVIDUALS_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_ONE_LITIGATION_FRIEND_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_ONE_ORG_INDIVIDUALS_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_ONE_WITNESSES_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_TWO_EXPERTS_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_TWO_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_TWO_LEGAL_REP_INDIVIDUALS_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_TWO_LITIGATION_FRIEND_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_TWO_ORG_INDIVIDUALS_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_TWO_WITNESSES_ID; class CaseFlagUtilsTest { @@ -1339,5 +1346,357 @@ void shouldUpdateFlagName_whenRespondent2OrgIndividualNameUpdated() { assertThat(individual.getPartyID()).isEqualTo("res-2-org-ind-party-id"); } } + + @Nested + class Experts { + + @Test + void shouldCreateFlag_whenClaimantExpertsAdded() { + CaseData caseData = CaseDataBuilder.builder() + .atStateApplicantRespondToDefenceAndProceed() + .updateDetailsForm(UpdateDetailsForm.builder().partyChosenId(CLAIMANT_ONE_EXPERTS_ID).build()) + .build(); + + CaseData.CaseDataBuilder builder = caseData.toBuilder() + .applicantExperts(wrapElements(PartyFlagStructure.builder() + .firstName("Ex").lastName("Pert") + .build())); + + CaseFlagUtils.createOrUpdateFlags(builder, builder.build(), organisationService); + + PartyFlagStructure individual = unwrapElements(builder.build().getApplicantExperts()).get(0); + Flags actualFlags = individual.getFlags(); + Flags expectedFlags = Flags.builder().partyName("Ex Pert") + .details(List.of()) + .roleOnCase("Claimant solicitor expert").build(); + + assertThat(actualFlags).isEqualTo(expectedFlags); + assertThat(individual.getPartyID()).isNotNull(); + } + + @Test + void shouldUpdateFlagName_whenClaimantExpertNameUpdated() { + CaseData caseData = CaseDataBuilder.builder() + .atStateApplicantRespondToDefenceAndProceed() + .addApplicant1ExpertsAndWitnesses() + .updateDetailsForm(UpdateDetailsForm.builder().partyChosenId(CLAIMANT_ONE_EXPERTS_ID).build()) + .build(); + + PartyFlagStructure newParty = unwrapElements(caseData.getApplicantExperts()).get(0); + + CaseData.CaseDataBuilder builder = caseData.toBuilder() + .applicantExperts(wrapElements(newParty.toBuilder() + .flags(Flags.builder() + .partyName("Exxxx Pert") + .roleOnCase("Claimant solicitor expert") + .details(wrapElements(List.of( + FlagDetail.builder().name("flag name").build()))).build()) + .firstName("Ex").lastName("Pert") + .build())); + + CaseFlagUtils.createOrUpdateFlags(builder, builder.build(), organisationService); + + PartyFlagStructure individual = unwrapElements(builder.build().getApplicantExperts()).get(0); + Flags actualFlags = individual.getFlags(); + Flags expectedFlags = Flags.builder().partyName("Ex Pert") + .details(wrapElements(List.of( + FlagDetail.builder().name("flag name").build()))) + .roleOnCase("Claimant solicitor expert").build(); + + assertThat(actualFlags).isEqualTo(expectedFlags); + assertThat(individual.getPartyID()).isEqualTo("app-1-expert-party-id"); + } + + @Test + void shouldCreateFlag_whenRespondent1ExpertsAdded() { + CaseData caseData = CaseDataBuilder.builder() + .atStateApplicantRespondToDefenceAndProceed() + .updateDetailsForm(UpdateDetailsForm.builder().partyChosenId(DEFENDANT_ONE_EXPERTS_ID).build()) + .build(); + + CaseData.CaseDataBuilder builder = caseData.toBuilder() + .respondent1Experts(wrapElements(PartyFlagStructure.builder() + .firstName("Ex").lastName("Pert") + .build())); + + CaseFlagUtils.createOrUpdateFlags(builder, builder.build(), organisationService); + + PartyFlagStructure individual = unwrapElements(builder.build().getRespondent1Experts()).get(0); + Flags actualFlags = individual.getFlags(); + Flags expectedFlags = Flags.builder().partyName("Ex Pert") + .details(List.of()) + .roleOnCase("Defendant solicitor 1 expert").build(); + + assertThat(actualFlags).isEqualTo(expectedFlags); + assertThat(individual.getPartyID()).isNotNull(); + } + + @Test + void shouldUpdateFlagName_whenRespondent1ExpertNameUpdated() { + CaseData caseData = CaseDataBuilder.builder() + .atStateApplicantRespondToDefenceAndProceed() + .addRespondent1ExpertsAndWitnesses() + .updateDetailsForm(UpdateDetailsForm.builder().partyChosenId(DEFENDANT_ONE_EXPERTS_ID).build()) + .build(); + + PartyFlagStructure newParty = unwrapElements(caseData.getRespondent1Experts()).get(0); + + CaseData.CaseDataBuilder builder = caseData.toBuilder() + .respondent1Experts(wrapElements(newParty.toBuilder() + .flags(Flags.builder() + .partyName("Exxxx Pert") + .roleOnCase("Defendant solicitor 1 expert") + .details(wrapElements(List.of( + FlagDetail.builder().name("flag name").build()))).build()) + .firstName("Ex").lastName("Pert") + .build())); + + CaseFlagUtils.createOrUpdateFlags(builder, builder.build(), organisationService); + + PartyFlagStructure individual = unwrapElements(builder.build().getRespondent1Experts()).get(0); + Flags actualFlags = individual.getFlags(); + Flags expectedFlags = Flags.builder().partyName("Ex Pert") + .details(wrapElements(List.of( + FlagDetail.builder().name("flag name").build()))) + .roleOnCase("Defendant solicitor 1 expert").build(); + + assertThat(actualFlags).isEqualTo(expectedFlags); + assertThat(individual.getPartyID()).isEqualTo("res-1-expert-party-id"); + } + + @Test + void shouldCreateFlag_whenRespondent2ExpertsAdded() { + CaseData caseData = CaseDataBuilder.builder() + .atStateApplicantRespondToDefenceAndProceed() + .updateDetailsForm(UpdateDetailsForm.builder().partyChosenId(DEFENDANT_TWO_EXPERTS_ID).build()) + .build(); + + CaseData.CaseDataBuilder builder = caseData.toBuilder() + .respondent2Experts(wrapElements(PartyFlagStructure.builder() + .firstName("Ex").lastName("Pert") + .build())); + + CaseFlagUtils.createOrUpdateFlags(builder, builder.build(), organisationService); + + PartyFlagStructure individual = unwrapElements(builder.build().getRespondent2Experts()).get(0); + Flags actualFlags = individual.getFlags(); + Flags expectedFlags = Flags.builder().partyName("Ex Pert") + .details(List.of()) + .roleOnCase("Defendant solicitor 2 expert").build(); + + assertThat(actualFlags).isEqualTo(expectedFlags); + assertThat(individual.getPartyID()).isNotNull(); + } + + @Test + void shouldUpdateFlagName_whenRespondent2ExpertNameUpdated() { + CaseData caseData = CaseDataBuilder.builder() + .multiPartyClaimTwoDefendantSolicitors() + .atStateApplicantRespondToDefenceAndProceed(ONE_V_TWO_TWO_LEGAL_REP) + .addRespondent2ExpertsAndWitnesses() + .updateDetailsForm(UpdateDetailsForm.builder().partyChosenId(DEFENDANT_TWO_EXPERTS_ID).build()) + .build(); + + PartyFlagStructure newParty = unwrapElements(caseData.getRespondent2Experts()).get(0); + + CaseData.CaseDataBuilder builder = caseData.toBuilder() + .respondent2Experts(wrapElements(newParty.toBuilder() + .flags(Flags.builder() + .partyName("Exxxx Pert") + .roleOnCase("Defendant solicitor 2 expert") + .details(wrapElements(List.of( + FlagDetail.builder().name("flag name").build()))).build()) + .firstName("Ex").lastName("Pert") + .build())); + + CaseFlagUtils.createOrUpdateFlags(builder, builder.build(), organisationService); + + PartyFlagStructure individual = unwrapElements(builder.build().getRespondent2Experts()).get(0); + Flags actualFlags = individual.getFlags(); + Flags expectedFlags = Flags.builder().partyName("Ex Pert") + .details(wrapElements(List.of( + FlagDetail.builder().name("flag name").build()))) + .roleOnCase("Defendant solicitor 2 expert").build(); + + assertThat(actualFlags).isEqualTo(expectedFlags); + assertThat(individual.getPartyID()).isEqualTo("res-2-expert-party-id"); + } + } + + @Nested + class Witnesses { + + @Test + void shouldCreateFlag_whenClaimantWitnessAdded() { + CaseData caseData = CaseDataBuilder.builder() + .atStateApplicantRespondToDefenceAndProceed() + .updateDetailsForm(UpdateDetailsForm.builder().partyChosenId(CLAIMANT_ONE_WITNESSES_ID).build()) + .build(); + + CaseData.CaseDataBuilder builder = caseData.toBuilder() + .applicantWitnesses(wrapElements(PartyFlagStructure.builder() + .firstName("Wit").lastName("Ness") + .build())); + + CaseFlagUtils.createOrUpdateFlags(builder, builder.build(), organisationService); + + PartyFlagStructure individual = unwrapElements(builder.build().getApplicantWitnesses()).get(0); + Flags actualFlags = individual.getFlags(); + Flags expectedFlags = Flags.builder().partyName("Wit Ness") + .details(List.of()) + .roleOnCase("Claimant solicitor witness").build(); + + assertThat(actualFlags).isEqualTo(expectedFlags); + assertThat(individual.getPartyID()).isNotNull(); + } + + @Test + void shouldUpdateFlagName_whenClaimantWitnessNameUpdated() { + CaseData caseData = CaseDataBuilder.builder() + .atStateApplicantRespondToDefenceAndProceed() + .addApplicant1ExpertsAndWitnesses() + .updateDetailsForm(UpdateDetailsForm.builder().partyChosenId(CLAIMANT_ONE_WITNESSES_ID).build()) + .build(); + + PartyFlagStructure newParty = unwrapElements(caseData.getApplicantWitnesses()).get(0); + + CaseData.CaseDataBuilder builder = caseData.toBuilder() + .applicantWitnesses(wrapElements(newParty.toBuilder() + .flags(Flags.builder() + .partyName("Wittyness") + .roleOnCase("Claimant solicitor witness") + .details(wrapElements(List.of( + FlagDetail.builder().name("flag name").build()))).build()) + .firstName("Wit").lastName("Ness") + .build())); + + CaseFlagUtils.createOrUpdateFlags(builder, builder.build(), organisationService); + + PartyFlagStructure individual = unwrapElements(builder.build().getApplicantWitnesses()).get(0); + Flags actualFlags = individual.getFlags(); + Flags expectedFlags = Flags.builder().partyName("Wit Ness") + .details(wrapElements(List.of( + FlagDetail.builder().name("flag name").build()))) + .roleOnCase("Claimant solicitor witness").build(); + + assertThat(actualFlags).isEqualTo(expectedFlags); + assertThat(individual.getPartyID()).isEqualTo("app-1-witness-party-id"); + } + + @Test + void shouldCreateFlag_whenRespondent1WitnessAdded() { + CaseData caseData = CaseDataBuilder.builder() + .atStateApplicantRespondToDefenceAndProceed() + .updateDetailsForm(UpdateDetailsForm.builder().partyChosenId(DEFENDANT_ONE_WITNESSES_ID).build()) + .build(); + + CaseData.CaseDataBuilder builder = caseData.toBuilder() + .respondent1Witnesses(wrapElements(PartyFlagStructure.builder() + .firstName("Wit").lastName("Ness") + .build())); + + CaseFlagUtils.createOrUpdateFlags(builder, builder.build(), organisationService); + + PartyFlagStructure individual = unwrapElements(builder.build().getRespondent1Witnesses()).get(0); + Flags actualFlags = individual.getFlags(); + Flags expectedFlags = Flags.builder().partyName("Wit Ness") + .details(List.of()) + .roleOnCase("Defendant solicitor 1 witness").build(); + + assertThat(actualFlags).isEqualTo(expectedFlags); + assertThat(individual.getPartyID()).isNotNull(); + } + + @Test + void shouldUpdateFlagName_whenRespondent1WitnessNameUpdated() { + CaseData caseData = CaseDataBuilder.builder() + .atStateApplicantRespondToDefenceAndProceed() + .addRespondent1ExpertsAndWitnesses() + .updateDetailsForm(UpdateDetailsForm.builder().partyChosenId(DEFENDANT_ONE_WITNESSES_ID).build()) + .build(); + + PartyFlagStructure newParty = unwrapElements(caseData.getRespondent1Witnesses()).get(0); + + CaseData.CaseDataBuilder builder = caseData.toBuilder() + .respondent1Witnesses(wrapElements(newParty.toBuilder() + .flags(Flags.builder() + .partyName("Wittyness") + .roleOnCase("Defendant solicitor 1 witness") + .details(wrapElements(List.of( + FlagDetail.builder().name("flag name").build()))).build()) + .firstName("Wit").lastName("Ness") + .build())); + + CaseFlagUtils.createOrUpdateFlags(builder, builder.build(), organisationService); + + PartyFlagStructure individual = unwrapElements(builder.build().getRespondent1Witnesses()).get(0); + Flags actualFlags = individual.getFlags(); + Flags expectedFlags = Flags.builder().partyName("Wit Ness") + .details(wrapElements(List.of( + FlagDetail.builder().name("flag name").build()))) + .roleOnCase("Defendant solicitor 1 witness").build(); + + assertThat(actualFlags).isEqualTo(expectedFlags); + assertThat(individual.getPartyID()).isEqualTo("res-1-witness-party-id"); + } + + @Test + void shouldCreateFlag_whenRespondent2WitnessAdded() { + CaseData caseData = CaseDataBuilder.builder() + .atStateApplicantRespondToDefenceAndProceed() + .updateDetailsForm(UpdateDetailsForm.builder().partyChosenId(DEFENDANT_TWO_WITNESSES_ID).build()) + .build(); + + CaseData.CaseDataBuilder builder = caseData.toBuilder() + .respondent2Witnesses(wrapElements(PartyFlagStructure.builder() + .firstName("Wit").lastName("Ness") + .build())); + + CaseFlagUtils.createOrUpdateFlags(builder, builder.build(), organisationService); + + PartyFlagStructure individual = unwrapElements(builder.build().getRespondent2Witnesses()).get(0); + Flags actualFlags = individual.getFlags(); + Flags expectedFlags = Flags.builder().partyName("Wit Ness") + .details(List.of()) + .roleOnCase("Defendant solicitor 2 witness").build(); + + assertThat(actualFlags).isEqualTo(expectedFlags); + assertThat(individual.getPartyID()).isNotNull(); + } + + @Test + void shouldUpdateFlagName_whenRespondent2WitnessNameUpdated() { + CaseData caseData = CaseDataBuilder.builder() + .multiPartyClaimTwoDefendantSolicitors() + .atStateApplicantRespondToDefenceAndProceed(ONE_V_TWO_TWO_LEGAL_REP) + .addRespondent2ExpertsAndWitnesses() + .updateDetailsForm(UpdateDetailsForm.builder().partyChosenId(DEFENDANT_TWO_WITNESSES_ID).build()) + .build(); + + PartyFlagStructure newParty = unwrapElements(caseData.getRespondent2Witnesses()).get(0); + + CaseData.CaseDataBuilder builder = caseData.toBuilder() + .respondent2Witnesses(wrapElements(newParty.toBuilder() + .flags(Flags.builder() + .partyName("Wittyness") + .roleOnCase("Defendant solicitor 2 witness") + .details(wrapElements(List.of( + FlagDetail.builder().name("flag name").build()))).build()) + .firstName("Wit").lastName("Ness") + .build())); + + CaseFlagUtils.createOrUpdateFlags(builder, builder.build(), organisationService); + + PartyFlagStructure individual = unwrapElements(builder.build().getRespondent2Witnesses()).get(0); + Flags actualFlags = individual.getFlags(); + Flags expectedFlags = Flags.builder().partyName("Wit Ness") + .details(wrapElements(List.of( + FlagDetail.builder().name("flag name").build()))) + .roleOnCase("Defendant solicitor 2 witness").build(); + + assertThat(actualFlags).isEqualTo(expectedFlags); + assertThat(individual.getPartyID()).isEqualTo("res-2-witness-party-id"); + } + } } } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/utils/CaseFlagsHearingsUtilsTest.java b/src/test/java/uk/gov/hmcts/reform/civil/utils/CaseFlagsHearingsUtilsTest.java index cd69f72b6b4..e283a982a6d 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/utils/CaseFlagsHearingsUtilsTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/utils/CaseFlagsHearingsUtilsTest.java @@ -187,25 +187,25 @@ void shouldReturnFalse_whenDetainedIndividualFlagDoesNotExists() { } private PartyFlags getRespondent1Flags(CaseData caseData, List> details) { - return getFlagsForParty(caseData.getRespondent1().getPartyName(), "Respondent 1", details, caseData.getRespondent1().getPartyID()); + return getFlagsForParty(caseData.getRespondent1().getPartyName(), "Defendant 1", details, caseData.getRespondent1().getPartyID()); } private PartyFlags getApplicant1Flags(CaseData caseData, List> details) { - return getFlagsForParty(caseData.getApplicant1().getPartyName(), "Applicant 1", details, caseData.getApplicant1().getPartyID()); + return getFlagsForParty(caseData.getApplicant1().getPartyName(), "Claimant 1", details, caseData.getApplicant1().getPartyID()); } private PartyFlags getRespondent1LitFriendFlags(CaseData caseData, List> details) { return getFlagsForParty(caseData.getRespondent1LitigationFriend().getFullName(), - "Respondent 1 Litigation Friend", details, caseData.getRespondent1LitigationFriend().getPartyID()); + "Defendant 1 Litigation Friend", details, caseData.getRespondent1LitigationFriend().getPartyID()); } private PartyFlags getRespondent1WitnessFlags(CaseData caseData, List> details) { - return getFlagsForParty("W First W Last", "Respondent 1 Witness", details, + return getFlagsForParty("W First W Last", "Defendant 1 Witness", details, "res-1-witness-party-id"); } private PartyFlags getRespondent1ExpertsFlags(CaseData caseData, List> details) { - return getFlagsForParty("E First E Last", "Respondent 1 Expert", details, + return getFlagsForParty("E First E Last", "Defendant 1 Expert", details, "res-1-expert-party-id"); } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/utils/CaseFlagsInitialiserTest.java b/src/test/java/uk/gov/hmcts/reform/civil/utils/CaseFlagsInitialiserTest.java index 334bb719764..9259720273c 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/utils/CaseFlagsInitialiserTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/utils/CaseFlagsInitialiserTest.java @@ -76,19 +76,19 @@ void shouldInitialiseCaseFlagsForCreateClaimEvent() { applicant1.toBuilder().flags( Flags.builder() .partyName("Mr. John Rambo") - .roleOnCase("Applicant 1") + .roleOnCase("Claimant 1") .details(List.of()).build()).build()) .applicant2( applicant2.toBuilder().flags( Flags.builder() .partyName("Company ltd") - .roleOnCase("Applicant 2") + .roleOnCase("Claimant 2") .details(List.of()).build()).build()) .applicant1LitigationFriend( applicant1LitFriend.toBuilder().flags( Flags.builder() .partyName("Jason Wilson") - .roleOnCase("Applicant 1 Litigation Friend") + .roleOnCase("Claimant 1 Litigation Friend") .details(List.of()).build()) .build() ) @@ -96,20 +96,20 @@ void shouldInitialiseCaseFlagsForCreateClaimEvent() { applicant2LitFriend.toBuilder().flags( Flags.builder() .partyName("Jenny Carter") - .roleOnCase("Applicant 2 Litigation Friend") + .roleOnCase("Claimant 2 Litigation Friend") .details(List.of()).build()) .build()) .respondent1( respondent1.toBuilder().flags( Flags.builder() .partyName("Mr. Sole Trader") - .roleOnCase("Respondent 1") + .roleOnCase("Defendant 1") .details(List.of()).build()).build()) .respondent2( respondent2.toBuilder().flags( Flags.builder() .partyName("The Organisation") - .roleOnCase("Respondent 2") + .roleOnCase("Defendant 2") .details(List.of()).build()).build()) .build(); @@ -136,7 +136,7 @@ void shouldInitialiseCaseFlagsForAddLitigationFriendEvent() { respondent1LitFriend.toBuilder().flags( Flags.builder() .partyName("Jason Wilson") - .roleOnCase("Respondent 1 Litigation Friend") + .roleOnCase("Defendant 1 Litigation Friend") .details(List.of()).build()) .build() ) @@ -144,7 +144,7 @@ void shouldInitialiseCaseFlagsForAddLitigationFriendEvent() { respondent2LitFriend.toBuilder().flags( Flags.builder() .partyName("Jenny Carter") - .roleOnCase("Respondent 2 Litigation Friend") + .roleOnCase("Defendant 2 Litigation Friend") .details(List.of()).build()) .build()) .build(); @@ -228,19 +228,19 @@ void shouldReinitialiseMissingCaseFlags() { applicant1.toBuilder().flags( Flags.builder() .partyName("Mr. John Rambo") - .roleOnCase("Applicant 1") + .roleOnCase("Claimant 1") .details(List.of()).build()).build()) .applicant2( applicant2.toBuilder().flags( Flags.builder() .partyName("Company ltd") - .roleOnCase("Applicant 2") + .roleOnCase("Claimant 2") .details(List.of()).build()).build()) .applicant1LitigationFriend( applicant1LitFriend.toBuilder().flags( Flags.builder() .partyName("Jason Wilson") - .roleOnCase("Applicant 1 Litigation Friend") + .roleOnCase("Claimant 1 Litigation Friend") .details(List.of()).build()) .build() ) @@ -248,14 +248,14 @@ void shouldReinitialiseMissingCaseFlags() { applicant2LitFriend.toBuilder().flags( Flags.builder() .partyName("Jenny Carter") - .roleOnCase("Applicant 2 Litigation Friend") + .roleOnCase("Claimant 2 Litigation Friend") .details(List.of()).build()) .build()) .respondent1( respondent1.toBuilder().flags( Flags.builder() .partyName("Mr. Sole Trader") - .roleOnCase("Respondent 1") + .roleOnCase("Defendant 1") .details(List.of()).build()).build()) .applicantWitnesses(wrapElements(List.of( PartyFlagStructure.builder() @@ -418,19 +418,19 @@ void shouldNotReinitialiseCaseFlagsForRespondentDQ_whenRespondent1DQFlagsExist() applicant1.toBuilder().flags( Flags.builder() .partyName("Mr. John Rambo") - .roleOnCase("Applicant 1") + .roleOnCase("Claimant 1") .details(List.of()).build()).build()) .applicant2( applicant2.toBuilder().flags( Flags.builder() .partyName("Company ltd") - .roleOnCase("Applicant 2") + .roleOnCase("Claimant 2") .details(List.of()).build()).build()) .applicant1LitigationFriend( applicant1LitFriend.toBuilder().flags( Flags.builder() .partyName("Jason Wilson") - .roleOnCase("Applicant 1 Litigation Friend") + .roleOnCase("Claimant 1 Litigation Friend") .details(List.of()).build()) .build() ) @@ -438,20 +438,20 @@ void shouldNotReinitialiseCaseFlagsForRespondentDQ_whenRespondent1DQFlagsExist() applicant2LitFriend.toBuilder().flags( Flags.builder() .partyName("Jenny Carter") - .roleOnCase("Applicant 2 Litigation Friend") + .roleOnCase("Claimant 2 Litigation Friend") .details(List.of()).build()) .build()) .respondent1( respondent1.toBuilder().flags( Flags.builder() .partyName("Mr. Sole Trader") - .roleOnCase("Respondent 1") + .roleOnCase("Defendant 1") .details(List.of()).build()).build()) .respondent2( respondent2.toBuilder().flags( Flags.builder() .partyName("The Organisation") - .roleOnCase("Respondent 2") + .roleOnCase("Defendant 2") .details(List.of()).build()).build()) .applicantWitnesses(wrapElements(List.of( PartyFlagStructure.builder() @@ -720,19 +720,19 @@ void shouldNotReinitialiseCaseFlagsForApplicantDQ_whenApplicantDQFlagsExist() { applicant1.toBuilder().flags( Flags.builder() .partyName("Mr. John Rambo") - .roleOnCase("Applicant 1") + .roleOnCase("Claimant 1") .details(List.of()).build()).build()) .applicant2( applicant2.toBuilder().flags( Flags.builder() .partyName("Company ltd") - .roleOnCase("Applicant 2") + .roleOnCase("Claimant 2") .details(List.of()).build()).build()) .applicant1LitigationFriend( applicant1LitFriend.toBuilder().flags( Flags.builder() .partyName("Jason Wilson") - .roleOnCase("Applicant 1 Litigation Friend") + .roleOnCase("Claimant 1 Litigation Friend") .details(List.of()).build()) .build() ) @@ -740,20 +740,20 @@ void shouldNotReinitialiseCaseFlagsForApplicantDQ_whenApplicantDQFlagsExist() { applicant2LitFriend.toBuilder().flags( Flags.builder() .partyName("Jenny Carter") - .roleOnCase("Applicant 2 Litigation Friend") + .roleOnCase("Claimant 2 Litigation Friend") .details(List.of()).build()) .build()) .respondent1( respondent1.toBuilder().flags( Flags.builder() .partyName("Mr. Sole Trader") - .roleOnCase("Respondent 1") + .roleOnCase("Defendant 1") .details(List.of()).build()).build()) .respondent2( respondent2.toBuilder().flags( Flags.builder() .partyName("The Organisation") - .roleOnCase("Respondent 2") + .roleOnCase("Defendant 2") .details(List.of()).build()).build()) .applicantWitnesses(wrapElements(List.of( PartyFlagStructure.builder() diff --git a/src/test/java/uk/gov/hmcts/reform/civil/utils/CaseNameUtilsTest.java b/src/test/java/uk/gov/hmcts/reform/civil/utils/CaseNameUtilsTest.java index e11e64e2c49..067bd4020c1 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/utils/CaseNameUtilsTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/utils/CaseNameUtilsTest.java @@ -6,8 +6,11 @@ import uk.gov.hmcts.reform.civil.model.CaseData; import uk.gov.hmcts.reform.civil.model.LitigationFriend; import uk.gov.hmcts.reform.civil.model.Party; +import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; +import static uk.gov.hmcts.reform.civil.utils.CaseNameUtils.buildCaseNameInternal; class CaseNameUtilsTest { @@ -214,4 +217,43 @@ void shouldReturnExpectedCaseName_with2v1PartyData_bothAppsLiFriend() { "v 'Respondent One'", actual); } } + + @Nested + class BuildCaseNameInternal { + + @Test + void shouldReturnCaseName_when1v1() { + CaseData caseData = CaseDataBuilder.builder() + .atStateApplicantRespondToDefenceAndProceed() + .build(); + + String actual = buildCaseNameInternal(caseData); + + assertThat(actual).isEqualTo("Mr. John Rambo v Mr. Sole Trader"); + } + + @Test + void shouldReturnCaseName_when1v2() { + CaseData caseData = CaseDataBuilder.builder() + .atStateApplicantRespondToDefenceAndProceed() + .multiPartyClaimTwoDefendantSolicitors() + .build(); + + String actual = buildCaseNameInternal(caseData); + + assertThat(actual).isEqualTo("Mr. John Rambo v Mr. Sole Trader and Mr. John Rambo"); + } + + @Test + void shouldReturnCaseName_when2v1() { + CaseData caseData = CaseDataBuilder.builder() + .atStateApplicantRespondToDefenceAndProceed() + .multiPartyClaimTwoApplicants() + .build(); + + String actual = buildCaseNameInternal(caseData); + + assertThat(actual).isEqualTo("Mr. John Rambo and Mr. Jason Rambo v Mr. Sole Trader"); + } + } } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/utils/HmcDataUtilsTest.java b/src/test/java/uk/gov/hmcts/reform/civil/utils/HmcDataUtilsTest.java index 25c701014df..55f9c09758b 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/utils/HmcDataUtilsTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/utils/HmcDataUtilsTest.java @@ -2,6 +2,11 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import uk.gov.hmcts.reform.civil.referencedata.LocationRefDataService; +import uk.gov.hmcts.reform.civil.referencedata.model.LocationRefData; import uk.gov.hmcts.reform.hmc.model.hearing.Attendees; import uk.gov.hmcts.reform.hmc.model.hearing.CaseDetailsHearing; import uk.gov.hmcts.reform.hmc.model.hearing.HearingDaySchedule; @@ -20,10 +25,13 @@ import java.util.ArrayList; import java.util.List; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.when; import static uk.gov.hmcts.reform.civil.utils.HmcDataUtils.includesVideoHearing; import static uk.gov.hmcts.reform.hmc.model.hearing.HearingSubChannel.INTER; import static uk.gov.hmcts.reform.hmc.model.hearing.HearingSubChannel.VIDCVP; @@ -947,4 +955,40 @@ void shouldReturnTrue_IfVideoHearingsExistOneDayWithinMultipleDays() { assertTrue(actual); } } + + @Nested + @ExtendWith(SpringExtension.class) + class GetHearingLocation { + + @MockBean + private LocationRefDataService locationRefDataService; + + @Test + void shouldReturnLocation_whenInvoked() { + List locations = List.of(LocationRefData.builder().epimmsId("venue").build()); + when(locationRefDataService.getCourtLocationsForDefaultJudgments("authToken")) + .thenReturn(locations); + LocationRefData locationRefData = HmcDataUtils.getLocationRefData( + "HER123", + "venue", + "authToken", + locationRefDataService + ); + + assertThat(locationRefData).isEqualTo(LocationRefData.builder().epimmsId("venue").build()); + } + + @Test + void shouldThrowException_whenLocationIsNull() { + when(locationRefDataService.getCourtLocationsForDefaultJudgments("abc")) + .thenReturn(null); + assertThrows( + IllegalArgumentException.class, + () -> HmcDataUtils.getLocationRefData( + "HER123", + "abc", + "authToken", + locationRefDataService)); + } + } } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/utils/ManageContactInformationUtilsTest.java b/src/test/java/uk/gov/hmcts/reform/civil/utils/ManageContactInformationUtilsTest.java index ac5effba420..cb5efa6da20 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/utils/ManageContactInformationUtilsTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/utils/ManageContactInformationUtilsTest.java @@ -1,7 +1,11 @@ package uk.gov.hmcts.reform.civil.utils; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; +import org.mockito.MockedStatic; +import org.mockito.Mockito; import uk.gov.hmcts.reform.civil.model.CaseData; import uk.gov.hmcts.reform.civil.model.Party; import uk.gov.hmcts.reform.civil.model.UpdatePartyDetailsForm; @@ -15,6 +19,7 @@ import java.util.List; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mockStatic; import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.ONE_V_TWO_TWO_LEGAL_REP; import static uk.gov.hmcts.reform.civil.enums.RespondentResponseType.FULL_DEFENCE; import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES; @@ -40,8 +45,24 @@ import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.mapUpdatePartyDetailsFormToDQExperts; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.mapUpdatePartyDetailsFormToDQWitnesses; +@SuppressWarnings("unchecked") class ManageContactInformationUtilsTest { + private static final String PARTY_ID = "party-id"; + private static MockedStatic partyIdMock; + + @BeforeAll + static void setupSuite() { + partyIdMock = mockStatic(PartyUtils.class, Mockito.CALLS_REAL_METHODS); + partyIdMock.when(PartyUtils::createPartyId).thenReturn(PARTY_ID); + } + + @AfterAll + static void tearDown() { + partyIdMock.reset(); + partyIdMock.close(); + } + @Test void shouldAddCorrectOptions_forClaimant1AsLegalRep() { CaseData caseDataWithExpertsAndWitnesses = CaseDataBuilder.builder() @@ -312,12 +333,12 @@ void shouldEditExperts() { void shouldAddExperts() { Expert expectedExpert1 = Expert.builder().firstName("Lewis").lastName("John") .eventAdded("Manage Contact Information Event").dateAdded(LocalDate.now()) - .partyID(null) //change this for CIV-10382 + .partyID(PARTY_ID) .build(); Expert expectedExpert2 = Expert.builder().firstName("Second").lastName("expert").fieldOfExpertise("field") .eventAdded("Manage Contact Information Event").dateAdded(LocalDate.now()).phoneNumber("1") .emailAddress("expertemail") - .partyID(null) //change this for CIV-10382 + .partyID(PARTY_ID) .build(); assertThat(mapUpdatePartyDetailsFormToDQExperts(null, wrapElements(party, party2))) @@ -331,7 +352,7 @@ void shouldAddExpertsWithExistingExperts() { Expert expectedExpert2 = Expert.builder().firstName("Second").lastName("expert").fieldOfExpertise("field") .eventAdded("Manage Contact Information Event").dateAdded(LocalDate.now()).phoneNumber("1") .emailAddress("expertemail") - .partyID(null) //change this for CIV-10382 + .partyID(PARTY_ID) .build(); assertThat(mapUpdatePartyDetailsFormToDQExperts(wrapElements(expert1), wrapElements(party, party2))) @@ -370,11 +391,11 @@ void shouldEditWitnesses() { void shouldAddWitnesses() { Witness expectedWitness1 = Witness.builder().firstName("Lewis").lastName("John") .eventAdded("Manage Contact Information Event").dateAdded(LocalDate.now()) - .partyID(null).build(); // CIV-10382 + .partyID(PARTY_ID).build(); Witness expectedWitness2 = Witness.builder().firstName("Second").lastName("witness") .eventAdded("Manage Contact Information Event").dateAdded(LocalDate.now()).phoneNumber("1") .emailAddress("witnessemail") - .partyID(null).build(); // CIV-10382 + .partyID(PARTY_ID).build(); assertThat(mapUpdatePartyDetailsFormToDQWitnesses(null, wrapElements(party, party2))) .isEqualTo(wrapElements(expectedWitness1, expectedWitness2)); @@ -393,7 +414,7 @@ void shouldAddWitnessesWithExistingWitnesses() { Witness expectedWitness2 = Witness.builder().firstName("Second").lastName("witness") .eventAdded("Manage Contact Information Event").dateAdded(LocalDate.now()).phoneNumber("1") .emailAddress("witnessemail") - .partyID(null) //change this for CIV-10382 + .partyID(PARTY_ID) .build(); assertThat(mapUpdatePartyDetailsFormToDQWitnesses(wrapElements(witness1), wrapElements(party, party2)))