Skip to content

Commit

Permalink
CIV-12084 Map lip defendant registered email to partyEmail field (#5760)
Browse files Browse the repository at this point in the history
* CIV-15716 Map lip defendant registered email to partyEmail field

* checkstyle fix
  • Loading branch information
sankaviv1 authored Nov 4, 2024
1 parent d77f5e9 commit 8ab9aac
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import uk.gov.hmcts.reform.civil.helpers.CaseDetailsConverter;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.model.IdamUserDetails;
import uk.gov.hmcts.reform.civil.model.Party;
import uk.gov.hmcts.reform.civil.service.UserService;
import uk.gov.hmcts.reform.civil.service.citizen.events.CaseEventService;
import uk.gov.hmcts.reform.civil.service.citizen.events.EventSubmissionParams;
Expand Down Expand Up @@ -54,13 +55,18 @@ public void addLipDefendantToCaseDefendantUserDetails(String authorisation, Stri
.build();
Map<String, Object> data = new HashMap<>();
data.put("defendantUserDetails", defendantUserDetails);
if (caseFlagsLoggingEnabled && caseDetails.isPresent()) {
if (caseDetails.isPresent()) {
CaseData caseData = caseDetailsConverter.toCaseData(caseDetails.get());
log.info(
"case id: {}, respondent flags start of event submission: {}",
caseId,
caseData.getRespondent1().getFlags()
);
Party respondent1 = caseData.getRespondent1();
respondent1 = respondent1.toBuilder().partyEmail(defendantIdamUserDetails.getEmail()).build();
data.put("respondent1", respondent1);
if (caseFlagsLoggingEnabled) {
log.info(
"case id: {}, respondent flags start of event submission: {}",
caseId,
respondent1.getFlags()
);
}
}
if (caseRole.isPresent() && caseRole.get() == CaseRole.DEFENDANT && caseDetails.isPresent()) {
Map<String, Object> pinPostData = defendantPinToPostLRspecService.removePinInPostData(caseDetails.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,17 @@ void shouldAddDefendantDetails_whenLipVLipFlagIsEnabled() {
//Given
given(featureToggleService.isLipVLipEnabled()).willReturn(true);
given(userService.getUserDetails(anyString())).willReturn(UserDetails.builder().id(USER_ID).email(EMAIL).build());
CaseData caseData = CaseDataBuilder.builder().atStateClaimIssued().build();
Party respondent1 = caseData.getRespondent1()
.toBuilder().partyEmail(EMAIL).build();
IdamUserDetails defendantUserDetails = IdamUserDetails.builder()
.id(USER_ID)
.email(EMAIL)
.build();
Map<String, Object> data = Map.of("defendantUserDetails", defendantUserDetails);
Map<String, Object> data = Map.of("defendantUserDetails", defendantUserDetails,
"respondent1", respondent1);

when(caseDetailsConverter.toCaseData((CaseDetails) any())).thenReturn(caseData);
EventSubmissionParams params = EventSubmissionParams.builder()
.caseId(CASE_ID)
.userId(USER_ID)
Expand All @@ -88,7 +94,9 @@ void shouldAddDefendantDetails_whenLipVLipFlagIsEnabled() {
AUTHORIZATION,
CASE_ID,
Optional.empty(),
Optional.empty()
Optional.of(CaseDetailsBuilder.builder()
.data(caseData)
.build())
);
//Then
verify(userService).getUserDetails(AUTHORIZATION);
Expand Down Expand Up @@ -122,13 +130,14 @@ void shouldRemovePinPostDetails_whenLipVLipFlagIsEnabled() {
.type(Party.Type.INDIVIDUAL)
.build())
.build();
Optional<CaseDetails> caseDetails = Optional.of(CaseDetailsBuilder.builder().data(caseData).build());
IdamUserDetails defendantUserDetails = IdamUserDetails.builder()
.id(USER_ID)
.email(EMAIL)
.build();
data.put("defendantUserDetails", defendantUserDetails);
data.put("respondent1", caseData.getRespondent1().toBuilder().partyEmail(EMAIL).build());
ReflectionTestUtils.setField(lipDefendantCaseAssignmentService, "caseFlagsLoggingEnabled", true);
Optional<CaseDetails> caseDetails = Optional.of(CaseDetailsBuilder.builder().data(caseData).build());
when(caseDetailsConverter.toCaseData(caseDetails.get())).thenReturn(caseData);
EventSubmissionParams params = EventSubmissionParams.builder()
.caseId(CASE_ID)
Expand Down

0 comments on commit 8ab9aac

Please sign in to comment.