-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added changes for claimant response cui event. (#3376)
Co-authored-by: sankhajuria <[email protected]> Co-authored-by: Raja Mani <[email protected]>
- Loading branch information
1 parent
19ce3fe
commit 959219d
Showing
6 changed files
with
204 additions
and
13 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
...munda/notification/ClaimantResponseConfirmsToProceedLiPRespondentNotificationHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
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.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 java.util.Objects; | ||
|
||
import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; | ||
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_LIP_RESPONDENT_CLAIMANT_CONFIRM_TO_PROCEED; | ||
import static uk.gov.hmcts.reform.civil.utils.PartyUtils.getPartyNameBasedOnType; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class ClaimantResponseConfirmsToProceedLiPRespondentNotificationHandler extends CallbackHandler | ||
implements NotificationData { | ||
|
||
private static final List<CaseEvent> EVENTS = List.of(NOTIFY_LIP_RESPONDENT_CLAIMANT_CONFIRM_TO_PROCEED); | ||
public static final String TASK_ID = "NotifyLiPRespondentClaimantConfirmToProceed"; | ||
private static final String REFERENCE_TEMPLATE = "claimant-confirms-to-proceed-respondent-notification-%s"; | ||
private final NotificationService notificationService; | ||
private final NotificationsProperties notificationsProperties; | ||
private final Map<String, Callback> callbackMap = Map.of( | ||
callbackKey(ABOUT_TO_SUBMIT), | ||
this::notifyRespondentForClaimantConfirmsToProceed | ||
); | ||
|
||
private CallbackResponse notifyRespondentForClaimantConfirmsToProceed(CallbackParams callbackParams) { | ||
CaseData caseData = callbackParams.getCaseData(); | ||
if (Objects.nonNull(caseData.getRespondent1().getPartyEmail())) { | ||
notificationService.sendMail( | ||
caseData.getRespondent1().getPartyEmail(), | ||
notificationsProperties.getRespondent1LipClaimUpdatedTemplate(), | ||
addProperties(caseData), | ||
String.format(REFERENCE_TEMPLATE, caseData.getLegacyCaseReference()) | ||
); | ||
} | ||
return AboutToStartOrSubmitCallbackResponse.builder().build(); | ||
} | ||
|
||
@Override | ||
protected Map<String, Callback> callbacks() { | ||
return callbackMap; | ||
} | ||
|
||
@Override | ||
public String camundaActivityId(CallbackParams callbackParams) { | ||
return TASK_ID; | ||
} | ||
|
||
@Override | ||
public List<CaseEvent> handledEvents() { | ||
return EVENTS; | ||
} | ||
|
||
@Override | ||
public Map<String, String> addProperties(CaseData caseData) { | ||
return Map.of( | ||
CLAIM_REFERENCE_NUMBER, caseData.getLegacyCaseReference(), | ||
RESPONDENT_NAME, getPartyNameBasedOnType(caseData.getRespondent1()) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
...a/notification/ClaimantResponseConfirmsToProceedLiPRespondentNotificationHandlerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package uk.gov.hmcts.reform.civil.handler.callback.camunda.notification; | ||
|
||
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.callback.CaseEvent; | ||
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.handler.callback.camunda.notification.ClaimantResponseConfirmsToProceedLiPRespondentNotificationHandler.TASK_ID; | ||
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.RESPONDENT_NAME; | ||
import static uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder.LEGACY_CASE_REFERENCE; | ||
|
||
@SpringBootTest(classes = { | ||
ClaimantResponseConfirmsToProceedLiPRespondentNotificationHandler.class, | ||
JacksonAutoConfiguration.class | ||
}) | ||
public class ClaimantResponseConfirmsToProceedLiPRespondentNotificationHandlerTest extends BaseCallbackHandlerTest { | ||
|
||
@MockBean | ||
private NotificationService notificationService; | ||
@MockBean | ||
private NotificationsProperties notificationsProperties; | ||
@Autowired | ||
private ClaimantResponseConfirmsToProceedLiPRespondentNotificationHandler handler; | ||
|
||
@Nested | ||
class AboutToSubmitCallback { | ||
|
||
private static final String RESPONDENT_EMAIL_TEMPLATE = "template-id-respondent"; | ||
private static final String RESPONDENT_EMAIL_ID = "[email protected]"; | ||
private static final String REFERENCE_NUMBER = "claimant-confirms-to-proceed-respondent-notification-000DC001"; | ||
private static final String DEFENDANT = "Mr. Sole Trader"; | ||
|
||
@BeforeEach | ||
void setup() { | ||
when(notificationsProperties.getRespondent1LipClaimUpdatedTemplate()).thenReturn( | ||
RESPONDENT_EMAIL_TEMPLATE); | ||
} | ||
|
||
@Test | ||
void shouldNotifyLipRespondent_whenInvoked() { | ||
CaseData caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified().build(); | ||
CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).request( | ||
CallbackRequest.builder().eventId(CaseEvent.NOTIFY_LIP_RESPONDENT_CLAIMANT_CONFIRM_TO_PROCEED.name()) | ||
.build()).build(); | ||
|
||
handler.handle(params); | ||
|
||
verify(notificationService).sendMail( | ||
RESPONDENT_EMAIL_ID, | ||
RESPONDENT_EMAIL_TEMPLATE, | ||
getNotificationDataMap(caseData), | ||
REFERENCE_NUMBER | ||
); | ||
} | ||
|
||
private Map<String, String> getNotificationDataMap(CaseData caseData) { | ||
return Map.of( | ||
CLAIM_REFERENCE_NUMBER, LEGACY_CASE_REFERENCE, | ||
RESPONDENT_NAME, DEFENDANT | ||
); | ||
} | ||
|
||
@Test | ||
void shouldReturnCorrectCamundaActivityId_whenInvoked() { | ||
assertThat(handler.camundaActivityId(CallbackParamsBuilder.builder().request(CallbackRequest.builder().eventId( | ||
CaseEvent.NOTIFY_LIP_RESPONDENT_CLAIMANT_CONFIRM_TO_PROCEED.name()).build()).build())).isEqualTo(TASK_ID); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters