Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,33 +1,21 @@
package uk.gov.hmcts.reform.civil.service.dashboardnotifications.trialarrangementsnotifyotherparty;

import org.springframework.stereotype.Service;
import uk.gov.hmcts.reform.civil.enums.YesOrNo;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.service.dashboardnotifications.DashboardNotificationsParamsMapper;
import uk.gov.hmcts.reform.civil.service.dashboardnotifications.DashboardScenarioService;
import uk.gov.hmcts.reform.dashboard.services.DashboardNotificationService;
import uk.gov.hmcts.reform.dashboard.services.DashboardScenariosService;
import uk.gov.hmcts.reform.dashboard.services.TaskListService;

import java.util.Collections;
import java.util.List;

import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_CP_TRIAL_ARRANGEMENTS_NOTIFY_OTHER_PARTY_CLAIMANT;
import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_CP_TRIAL_ARRANGEMENTS_NOTIFY_OTHER_PARTY_LR_CLAIMANT;

@Service
public class TrialArrangementsNotifyOtherPartyClaimantDashboardService extends DashboardScenarioService {

private final DashboardNotificationService dashboardNotificationService;
private final TaskListService taskListService;
private static final List<String> TRIAL_TEMPLATE_NAMES = Collections.singletonList("Hearing.Arrangements.Add");

public TrialArrangementsNotifyOtherPartyClaimantDashboardService(DashboardScenariosService dashboardScenariosService,
DashboardNotificationService dashboardNotificationService,
DashboardNotificationsParamsMapper mapper,
TaskListService taskListService) {
DashboardNotificationsParamsMapper mapper) {
super(dashboardScenariosService, mapper);
this.dashboardNotificationService = dashboardNotificationService;
this.taskListService = taskListService;
}

public void notifyTrialArrangementsNotifyOtherParty(CaseData caseData, String authToken) {
Expand All @@ -42,19 +30,11 @@ protected String getScenario(CaseData caseData) {
}

@Override
protected void beforeRecordScenario(CaseData caseData, String authToken) {
if (caseData.isApplicantNotRepresented()) {
final String caseId = String.valueOf(caseData.getCcdCaseReference());
dashboardNotificationService.deleteByReferenceAndCitizenRole(
caseId,
CLAIMANT_ROLE
);

taskListService.makeSelectedProgressAbleTasksInactiveForCaseIdentifierAndRole(
caseId,
CLAIMANT_ROLE,
TRIAL_TEMPLATE_NAMES
);
}
public boolean shouldRecordScenario(CaseData caseData) {
// This service is called via the registry when the claimant confirms trial arrangements
// (APPLICANT_TRIAL_READY_NOTIFY_OTHERS BPMN). The claimant should NOT receive
// a "the other party confirmed" notification about their own confirmation.
// Only notify the claimant when the defendant has confirmed trial arrangements.
return YesOrNo.YES.equals(caseData.getTrialReadyRespondent1());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,16 @@
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.service.dashboardnotifications.DashboardNotificationsParamsMapper;
import uk.gov.hmcts.reform.civil.service.dashboardnotifications.DashboardScenarioService;
import uk.gov.hmcts.reform.dashboard.services.DashboardNotificationService;
import uk.gov.hmcts.reform.dashboard.services.DashboardScenariosService;
import uk.gov.hmcts.reform.dashboard.services.TaskListService;

import java.util.Collections;
import java.util.List;

import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_CP_TRIAL_ARRANGEMENTS_NOTIFY_OTHER_PARTY_DEFENDANT;

@Service
public class TrialArrangementsNotifyOtherPartyDefendantDashboardService extends DashboardScenarioService {

private final DashboardNotificationService dashboardNotificationService;
private final TaskListService taskListService;
private static final List<String> TRIAL_TEMPLATE_NAMES = Collections.singletonList("Hearing.Arrangements.Add");

public TrialArrangementsNotifyOtherPartyDefendantDashboardService(DashboardScenariosService dashboardScenariosService,
DashboardNotificationService dashboardNotificationService,
DashboardNotificationsParamsMapper mapper,
TaskListService taskListService) {
DashboardNotificationsParamsMapper mapper) {
super(dashboardScenariosService, mapper);
this.dashboardNotificationService = dashboardNotificationService;
this.taskListService = taskListService;
}

public void notifyTrialArrangementsNotifyOtherParty(CaseData caseData, String authToken) {
Expand All @@ -43,18 +30,4 @@ public boolean shouldRecordScenario(CaseData caseData) {
return caseData.isRespondent1NotRepresented();
}

@Override
protected void beforeRecordScenario(CaseData caseData, String authToken) {
final String caseId = String.valueOf(caseData.getCcdCaseReference());
dashboardNotificationService.deleteByReferenceAndCitizenRole(
caseId,
DEFENDANT_ROLE
);

taskListService.makeSelectedProgressAbleTasksInactiveForCaseIdentifierAndRole(
caseId,
DEFENDANT_ROLE,
TRIAL_TEMPLATE_NAMES
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@
import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder;
import uk.gov.hmcts.reform.civil.service.dashboardnotifications.DashboardNotificationsParamsMapper;
import uk.gov.hmcts.reform.dashboard.data.ScenarioRequestParams;
import uk.gov.hmcts.reform.dashboard.services.DashboardNotificationService;
import uk.gov.hmcts.reform.dashboard.services.DashboardScenariosService;
import uk.gov.hmcts.reform.dashboard.services.TaskListService;

import java.util.Collections;
import java.util.HashMap;

import static org.mockito.ArgumentMatchers.any;
Expand All @@ -33,10 +30,6 @@ class TrialArrangementsNotifyOtherPartyClaimantDashboardServiceTest {
@Mock
private DashboardScenariosService dashboardScenariosService;
@Mock
private DashboardNotificationService dashboardNotificationService;
@Mock
private TaskListService taskListService;
@Mock
private DashboardNotificationsParamsMapper mapper;

@InjectMocks
Expand All @@ -48,15 +41,14 @@ void setUp() {
}

@Test
void shouldNotifyClaimantWhenTrialArrangementsNotifyOtherPartyAndUnrepresented() {
void shouldNotifyClaimantWhenDefendantConfirmedAndClaimantUnrepresented() {
CaseData caseData = CaseDataBuilder.builder().build();
caseData.setApplicant1Represented(YesOrNo.NO);
caseData.setTrialReadyRespondent1(YesOrNo.YES);
caseData.setCcdCaseReference(1234L);

service.notifyTrialArrangementsNotifyOtherParty(caseData, AUTH_TOKEN);

verify(dashboardNotificationService).deleteByReferenceAndCitizenRole("1234", "CLAIMANT");
verify(taskListService).makeSelectedProgressAbleTasksInactiveForCaseIdentifierAndRole("1234", "CLAIMANT", Collections.singletonList("Hearing.Arrangements.Add"));
verify(dashboardScenariosService).recordScenarios(
AUTH_TOKEN,
SCENARIO_AAA6_CP_TRIAL_ARRANGEMENTS_NOTIFY_OTHER_PARTY_CLAIMANT.getScenario(),
Expand All @@ -66,54 +58,43 @@ void shouldNotifyClaimantWhenTrialArrangementsNotifyOtherPartyAndUnrepresented()
}

@Test
void shouldUseClaimantScenarioWhenUnrepresented() {
void shouldUseLRClaimantScenarioWhenDefendantConfirmedAndClaimantRepresented() {
CaseData caseData = CaseDataBuilder.builder().build();
caseData.setApplicant1Represented(YesOrNo.NO);
caseData.setCcdCaseReference(5678L);
caseData.setApplicant1Represented(YesOrNo.YES);
caseData.setTrialReadyRespondent1(YesOrNo.YES);
caseData.setCcdCaseReference(9012L);

service.notifyTrialArrangementsNotifyOtherParty(caseData, AUTH_TOKEN);

verify(dashboardScenariosService).recordScenarios(
AUTH_TOKEN,
SCENARIO_AAA6_CP_TRIAL_ARRANGEMENTS_NOTIFY_OTHER_PARTY_CLAIMANT.getScenario(),
"5678",
SCENARIO_AAA6_CP_TRIAL_ARRANGEMENTS_NOTIFY_OTHER_PARTY_LR_CLAIMANT.getScenario(),
"9012",
new ScenarioRequestParams(new HashMap<>())
);
}

@Test
void shouldUseLRClaimantScenarioWhenRepresented() {
void shouldNotNotifyClaimantWhenDefendantHasNotConfirmed() {
CaseData caseData = CaseDataBuilder.builder().build();
caseData.setApplicant1Represented(YesOrNo.YES);
caseData.setCcdCaseReference(9012L);
caseData.setApplicant1Represented(YesOrNo.NO);
caseData.setTrialReadyRespondent1(null);
caseData.setCcdCaseReference(5678L);

service.notifyTrialArrangementsNotifyOtherParty(caseData, AUTH_TOKEN);

verify(dashboardScenariosService).recordScenarios(
AUTH_TOKEN,
SCENARIO_AAA6_CP_TRIAL_ARRANGEMENTS_NOTIFY_OTHER_PARTY_LR_CLAIMANT.getScenario(),
"9012",
new ScenarioRequestParams(new HashMap<>())
);
verifyNoInteractions(dashboardNotificationService);
verifyNoInteractions(taskListService);
verifyNoInteractions(dashboardScenariosService);
}

@Test
void shouldRecordScenarioButNotDeleteOrMakeInactiveWhenRepresented() {
void shouldNotNotifyClaimantWhenDefendantSaidNo() {
CaseData caseData = CaseDataBuilder.builder().build();
caseData.setApplicant1Represented(YesOrNo.YES);
caseData.setApplicant1Represented(YesOrNo.NO);
caseData.setTrialReadyRespondent1(YesOrNo.NO);
caseData.setCcdCaseReference(3456L);

service.notifyTrialArrangementsNotifyOtherParty(caseData, AUTH_TOKEN);

verify(dashboardScenariosService).recordScenarios(
AUTH_TOKEN,
SCENARIO_AAA6_CP_TRIAL_ARRANGEMENTS_NOTIFY_OTHER_PARTY_LR_CLAIMANT.getScenario(),
"3456",
new ScenarioRequestParams(new HashMap<>())
);
verifyNoInteractions(dashboardNotificationService);
verifyNoInteractions(taskListService);
verifyNoInteractions(dashboardScenariosService);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@
import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder;
import uk.gov.hmcts.reform.civil.service.dashboardnotifications.DashboardNotificationsParamsMapper;
import uk.gov.hmcts.reform.dashboard.data.ScenarioRequestParams;
import uk.gov.hmcts.reform.dashboard.services.DashboardNotificationService;
import uk.gov.hmcts.reform.dashboard.services.DashboardScenariosService;
import uk.gov.hmcts.reform.dashboard.services.TaskListService;

import java.util.Collections;
import java.util.HashMap;

import static org.mockito.ArgumentMatchers.any;
Expand All @@ -32,10 +29,6 @@ class TrialArrangementsNotifyOtherPartyDefendantDashboardServiceTest {
@Mock
private DashboardScenariosService dashboardScenariosService;
@Mock
private DashboardNotificationService dashboardNotificationService;
@Mock
private TaskListService taskListService;
@Mock
private DashboardNotificationsParamsMapper mapper;

@InjectMocks
Expand All @@ -47,15 +40,13 @@ void setUp() {
}

@Test
void shouldNotifyDefendantWhenTrialArrangementsNotifyOtherPartyAndUnrepresented() {
void shouldNotifyDefendantWhenUnrepresented() {
CaseData caseData = CaseDataBuilder.builder().build();
caseData.setRespondent1Represented(YesOrNo.NO);
caseData.setCcdCaseReference(1234L);

service.notifyTrialArrangementsNotifyOtherParty(caseData, AUTH_TOKEN);

verify(dashboardNotificationService).deleteByReferenceAndCitizenRole("1234", "DEFENDANT");
verify(taskListService).makeSelectedProgressAbleTasksInactiveForCaseIdentifierAndRole("1234", "DEFENDANT", Collections.singletonList("Hearing.Arrangements.Add"));
verify(dashboardScenariosService).recordScenarios(
AUTH_TOKEN,
SCENARIO_AAA6_CP_TRIAL_ARRANGEMENTS_NOTIFY_OTHER_PARTY_DEFENDANT.getScenario(),
Expand All @@ -65,31 +56,13 @@ void shouldNotifyDefendantWhenTrialArrangementsNotifyOtherPartyAndUnrepresented(
}

@Test
void shouldUseDefendantScenarioWhenUnrepresented() {
CaseData caseData = CaseDataBuilder.builder().build();
caseData.setRespondent1Represented(YesOrNo.NO);
caseData.setCcdCaseReference(5678L);

service.notifyTrialArrangementsNotifyOtherParty(caseData, AUTH_TOKEN);

verify(dashboardScenariosService).recordScenarios(
AUTH_TOKEN,
SCENARIO_AAA6_CP_TRIAL_ARRANGEMENTS_NOTIFY_OTHER_PARTY_DEFENDANT.getScenario(),
"5678",
new ScenarioRequestParams(new HashMap<>())
);
}

@Test
void shouldNotNotifyDefendantWhenRepresentedYes() {
void shouldNotNotifyDefendantWhenRepresented() {
CaseData caseData = CaseDataBuilder.builder().build();
caseData.setRespondent1Represented(YesOrNo.YES);
caseData.setCcdCaseReference(3456L);

service.notifyTrialArrangementsNotifyOtherParty(caseData, AUTH_TOKEN);

verifyNoInteractions(dashboardNotificationService);
verifyNoInteractions(taskListService);
verifyNoInteractions(dashboardScenariosService);
}
}
Loading