Skip to content

Commit 33692bf

Browse files
authored
Merge branch 'master' into DFPL-2864
2 parents 372ae72 + 2d3f14c commit 33692bf

File tree

3 files changed

+76
-1
lines changed

3 files changed

+76
-1
lines changed

service/src/main/java/uk/gov/hmcts/reform/fpl/controllers/support/MigrateCaseController.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ public class MigrateCaseController extends CallbackController {
3232
"DFPL-log", this::runLog,
3333
"DFPL-3080", this::run3080,
3434
"DFPL-3048", this::run3048,
35-
"DFPL-3047", this::run3047
35+
"DFPL-3047", this::run3047,
36+
"DFPL-3085", this::run3085
3637
);
3738

3839
@PostMapping("/about-to-submit")
@@ -92,4 +93,15 @@ private void run3047(CaseDetails caseDetails) {
9293
caseDetails.getData().putAll(migrateCaseService
9394
.updateRespondentPolicy(getCaseData(caseDetails), orgId, null, 0));
9495
}
96+
97+
private void run3085(CaseDetails caseDetails) {
98+
final String migrationId = "DFPL-3085";
99+
final long expectedCaseId = 1767953928694083L;
100+
101+
Long caseId = caseDetails.getId();
102+
migrateCaseService.doCaseIdCheck(caseId, expectedCaseId, migrationId);
103+
104+
caseDetails.getData().putAll(migrateCaseService.removeStatementOfService(migrationId, getCaseData(caseDetails),
105+
"483e196a-6206-4d09-8172-7f56dc72d32d"));
106+
}
95107
}

service/src/main/java/uk/gov/hmcts/reform/fpl/service/MigrateCaseService.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import uk.gov.hmcts.reform.fpl.model.PositionStatementChild;
3131
import uk.gov.hmcts.reform.fpl.model.PositionStatementRespondent;
3232
import uk.gov.hmcts.reform.fpl.model.Proceeding;
33+
import uk.gov.hmcts.reform.fpl.model.Recipients;
3334
import uk.gov.hmcts.reform.fpl.model.Respondent;
3435
import uk.gov.hmcts.reform.fpl.model.SentDocuments;
3536
import uk.gov.hmcts.reform.fpl.model.SkeletonArgument;
@@ -1422,4 +1423,26 @@ public List<Element<HearingBooking>> replaceHearingJudgeEmailAddress(String migr
14221423

14231424
return hearings;
14241425
}
1426+
1427+
public Map<String, Object> removeStatementOfService(String migrationId, CaseData caseData,
1428+
String statementIdToBeRemoved) {
1429+
1430+
List<Element<Recipients>> statementOfService = caseData.getStatementOfService();
1431+
if (isEmpty(statementOfService)) {
1432+
throw new AssertionError(format("Migration {id = %s, case reference = %s}, statement of service not found",
1433+
migrationId, caseData.getId()));
1434+
}
1435+
1436+
List<Element<Recipients>> statementOfServiceAfter = ElementUtils.removeElementWithUUID(statementOfService,
1437+
UUID.fromString(statementIdToBeRemoved));
1438+
1439+
if (statementOfServiceAfter.size() == statementOfService.size()) {
1440+
throw new AssertionError(format(
1441+
"Migration {id = %s, case reference = %s}, statement of service element not found",
1442+
migrationId, caseData.getId()));
1443+
}
1444+
1445+
return Map.of("statementOfService", statementOfServiceAfter);
1446+
1447+
}
14251448
}

service/src/test/java/uk/gov/hmcts/reform/fpl/service/MigrateCaseServiceTest.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import uk.gov.hmcts.reform.fpl.model.PositionStatementChild;
5353
import uk.gov.hmcts.reform.fpl.model.PositionStatementRespondent;
5454
import uk.gov.hmcts.reform.fpl.model.Proceeding;
55+
import uk.gov.hmcts.reform.fpl.model.Recipients;
5556
import uk.gov.hmcts.reform.fpl.model.Respondent;
5657
import uk.gov.hmcts.reform.fpl.model.RespondentParty;
5758
import uk.gov.hmcts.reform.fpl.model.RespondentPolicyData;
@@ -3797,4 +3798,43 @@ void shouldFixJudgeEmailOnSpecifiedHearingBooking() {
37973798
assertThat(fixedHearingBookings.contains(element(hearingId, expectedHearingBooking))).isTrue();
37983799
}
37993800
}
3801+
3802+
@Nested
3803+
class RemoveStatementOfService {
3804+
@Test
3805+
void shouldRemoveStatementOfService() {
3806+
Element<Recipients> statementOfService =
3807+
element(Recipients.builder().email("recipient@test.com").name("Recipient").build());
3808+
Element<Recipients> statementOfServiceToBeRemoved =
3809+
element(Recipients.builder().email("removed@test.com").name("Removed").build());
3810+
3811+
CaseData caseData = CaseData.builder()
3812+
.statementOfService(List.of(statementOfService, statementOfServiceToBeRemoved))
3813+
.build();
3814+
3815+
Map<String, Object> result = underTest.removeStatementOfService(MIGRATION_ID, caseData,
3816+
statementOfServiceToBeRemoved.getId().toString());
3817+
3818+
assertThat(result).containsExactlyEntriesOf(Map.of("statementOfService", List.of(statementOfService)));
3819+
}
3820+
3821+
@Test
3822+
void shouldThrowExceptionIfNoStatementOfService() {
3823+
CaseData caseData = CaseData.builder()
3824+
.build();
3825+
3826+
assertThrows(AssertionError.class, () ->
3827+
underTest.removeStatementOfService(MIGRATION_ID, caseData, UUID.randomUUID().toString()));
3828+
}
3829+
3830+
@Test
3831+
void shouldThrowExceptionIfNoStatementOfServiceRemoved() {
3832+
CaseData caseData = CaseData.builder()
3833+
.statementOfService(wrapElementsWithUUIDs(Recipients.builder().build()))
3834+
.build();
3835+
3836+
assertThrows(AssertionError.class, () ->
3837+
underTest.removeStatementOfService(MIGRATION_ID, caseData, UUID.randomUUID().toString()));
3838+
}
3839+
}
38003840
}

0 commit comments

Comments
 (0)