Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PUB-2498 Update email summary generation to remove bullet point formatting #642

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
Expand Up @@ -260,7 +260,7 @@ void testGenerateArtefactSummaryCrownDailyList() throws Exception {

String responseContent = response.getResponse().getContentAsString();
assertTrue(responseContent.contains("Defendant - Surname 1, Forename 1"), CONTENT_MISMATCH_ERROR);
assertTrue(responseContent.contains("Prosecutor - Pro_Auth"), CONTENT_MISMATCH_ERROR);
assertTrue(responseContent.contains("Prosecuting authority - Pro_Auth"), CONTENT_MISMATCH_ERROR);
assertTrue(responseContent.contains("Case reference - 1234"), CONTENT_MISMATCH_ERROR);
assertTrue(
responseContent.contains(HEARING_TYPE_FIELD),
Expand All @@ -280,7 +280,7 @@ void testGenerateArtefactSummaryCrownFirmList() throws Exception {

String responseContent = response.getResponse().getContentAsString();
assertTrue(responseContent.contains("Defendant - Surname 1, Forename 1"), CONTENT_MISMATCH_ERROR);
assertTrue(responseContent.contains("Prosecutor - Prosecutor org"), CONTENT_MISMATCH_ERROR);
assertTrue(responseContent.contains("Prosecuting authority - Prosecutor org"), CONTENT_MISMATCH_ERROR);
assertTrue(responseContent.contains("Case reference - 1234"), CONTENT_MISMATCH_ERROR);
assertTrue(responseContent.contains(HEARING_TYPE_FIELD), CONTENT_MISMATCH_ERROR);
}
Expand All @@ -297,7 +297,7 @@ void testGenerateArtefactSummaryCrownWarnedList() throws Exception {

String responseContent = response.getResponse().getContentAsString();
assertTrue(responseContent.contains("Defendant - Surname, Forenames"), CONTENT_MISMATCH_ERROR);
assertTrue(responseContent.contains("Prosecutor - OrganisationName2"), CONTENT_MISMATCH_ERROR);
assertTrue(responseContent.contains("Prosecuting authority - OrganisationName2"), CONTENT_MISMATCH_ERROR);
assertTrue(responseContent.contains(CASE_REFERENCE_FIELD), CONTENT_MISMATCH_ERROR);
assertTrue(responseContent.contains("Hearing date - 21/07/2024"), CONTENT_MISMATCH_ERROR);
}
Expand Down Expand Up @@ -368,7 +368,7 @@ void testGenerateArtefactSummaryImmigrationAndAsylumChamberDailyList(ListType li
String responseContent = response.getResponse().getContentAsString();
assertTrue(responseContent.contains("Bail List"), CONTENT_MISMATCH_ERROR);
assertTrue(
responseContent.contains("Appellant - Surname"),
responseContent.contains("Appellant/Applicant - Surname"),
CONTENT_MISMATCH_ERROR
);
assertTrue(responseContent.contains("Prosecuting authority - Authority surname"), CONTENT_MISMATCH_ERROR);
Expand All @@ -387,7 +387,7 @@ void testGenerateArtefactSummaryMagistratesPublicList() throws Exception {

String responseContent = response.getResponse().getContentAsString();
assertTrue(responseContent.contains("Defendant - Surname, Forename"), CONTENT_MISMATCH_ERROR);
assertTrue(responseContent.contains("Prosecutor - Authority org name"), CONTENT_MISMATCH_ERROR);
assertTrue(responseContent.contains("Prosecuting authority - Authority org name"), CONTENT_MISMATCH_ERROR);
assertTrue(responseContent.contains(CASE_REFERENCE_FIELD), CONTENT_MISMATCH_ERROR);
assertTrue(
responseContent.contains(HEARING_TYPE_FIELD),
Expand All @@ -406,7 +406,7 @@ void testGenerateArtefactSummaryMagistratesStandardList() throws Exception {
.andExpect(status().isOk()).andReturn();
String responseContent = response.getResponse().getContentAsString();
assertTrue(responseContent.contains("Defendant - Surname1, Forename1"), CONTENT_MISMATCH_ERROR);
assertTrue(responseContent.contains("Prosecutor - Test1234"), CONTENT_MISMATCH_ERROR);
assertTrue(responseContent.contains("Prosecuting authority - Test1234"), CONTENT_MISMATCH_ERROR);
assertTrue(responseContent.contains("Case reference - 45684548"), CONTENT_MISMATCH_ERROR);
assertTrue(responseContent.contains("Hearing type - mda"), CONTENT_MISMATCH_ERROR);
assertTrue(responseContent.contains("Offence - drink driving, Assault by beating"), CONTENT_MISMATCH_ERROR);
Expand Down Expand Up @@ -473,7 +473,7 @@ void testGenerateArtefactSummarySscsDailyList(ListType listType) throws Exceptio
assertTrue(responseContent.contains("Appellant - Surname"), CONTENT_MISMATCH_ERROR);
assertTrue(responseContent.contains("Respondent - Respondent Organisation, Respondent Organisation 2"),
CONTENT_MISMATCH_ERROR);
assertTrue(responseContent.contains("Appeal reference - 12341235"), CONTENT_MISMATCH_ERROR);
assertTrue(responseContent.contains("Case reference - 12341235"), CONTENT_MISMATCH_ERROR);
}

@Test
Expand All @@ -489,7 +489,8 @@ void testGenerateArtefactSummaryOpaPressList() throws Exception {
String responseContent = response.getResponse().getContentAsString();
assertTrue(responseContent.contains("Defendant - Surname, Forename MiddleName"),
CONTENT_MISMATCH_ERROR);
assertTrue(responseContent.contains("Prosecuting authority ref"), CONTENT_MISMATCH_ERROR);
assertTrue(responseContent.contains("Prosecuting authority - Prosecuting authority ref"),
CONTENT_MISMATCH_ERROR);
assertTrue(responseContent.contains("Postcode - BB1 1BB"), CONTENT_MISMATCH_ERROR);
assertTrue(responseContent.contains("Case reference - URN8888"), CONTENT_MISMATCH_ERROR);
assertTrue(responseContent.contains("Offence - Offence title 2"), CONTENT_MISMATCH_ERROR);
Expand All @@ -507,7 +508,7 @@ void testGenerateArtefactSummaryOpaPublicList() throws Exception {

String responseContent = response.getResponse().getContentAsString();
assertTrue(
responseContent.contains("Defendant - individualFirstName individualMiddleName IndividualSurname"),
responseContent.contains("Name - individualFirstName individualMiddleName IndividualSurname"),
CONTENT_MISMATCH_ERROR
);
assertTrue(responseContent.contains("Prosecutor - Prosecution Authority ref 1"), CONTENT_MISMATCH_ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,22 @@ public String generate(Map<String, List<Map<String, String>>> data) {
if (summarySection.getKey() == null) {
summarySection.getValue().forEach(
summaryCase -> output
.append("---")
.append("---\n")
.append(formatSummaryField(summaryCase))
.append("\n\n")
);
} else {
output
.append("---\n\n##")
.append("---\n##")
.append(summarySection.getKey())
.append('\n');

summarySection.getValue()
.forEach(summaryCase -> output.append(formatSummaryField(summaryCase)));
.forEach(
summaryCase -> output
.append(formatSummaryField(summaryCase))
.append("\n\n")
);
}
});

Expand All @@ -44,8 +49,6 @@ public String generate(Map<String, List<Map<String, String>>> data) {

private String formatSummaryField(Map<String, String> summaryCase) {
StringBuilder summaryFields = new StringBuilder(20);
summaryFields.append("\n•");

summaryCase.entrySet().forEach(
field -> summaryFields
.append(field.getKey())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private Map<String, List<Map<String, String>>> processCrownDailyList(JsonNode no
Map<String, String> fields = ImmutableMap.of(
"Defendant",
GeneralHelper.findAndReturnNodeText(hearingCase, "defendant"),
"Prosecutor",
"Prosecuting authority",
GeneralHelper.findAndReturnNodeText(hearingCase, "prosecutingAuthority"),
"Case reference",
GeneralHelper.findAndReturnNodeText(hearingCase, "caseNumber"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private Map<String, List<Map<String, String>>> processCrownFirmList(JsonNode nod
Map<String, String> fields = ImmutableMap.of(
"Defendant",
GeneralHelper.findAndReturnNodeText(hearingCase, "defendant"),
"Prosecutor",
"Prosecuting authority",
GeneralHelper.findAndReturnNodeText(hearingCase, "prosecutingAuthority"),
"Case reference",
GeneralHelper.findAndReturnNodeText(hearingCase, "caseReference"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public Map<String, List<Map<String, String>>> get(JsonNode payload) {
.forEach(row -> {
Map<String, String> fields = ImmutableMap.of(
"Defendant", row.getDefendant(),
"Prosecutor", row.getProsecutingAuthority(),
"Prosecuting authority", row.getProsecutingAuthority(),
"Case reference", row.getCaseReference(),
"Hearing date", row.getHearingDate()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public Map<String, List<Map<String, String>>> get(JsonNode payload) {
PartyRoleHelper.findAndManipulatePartyInformation(hearingCase, false);

Map<String, String> fields = ImmutableMap.of(
"Appellant",
"Appellant/Applicant",
GeneralHelper.findAndReturnNodeText(hearingCase, "claimant"),
"Prosecuting authority",
GeneralHelper.findAndReturnNodeText(hearingCase, "prosecutingAuthority"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public Map<String, List<Map<String, String>>> processMagistratesPublicList(JsonN
Map<String, String> fields = ImmutableMap.of(
"Defendant",
GeneralHelper.findAndReturnNodeText(hearingCase, "defendant"),
"Prosecutor",
"Prosecuting authority",
GeneralHelper.findAndReturnNodeText(hearingCase, "prosecutingAuthority"),
"Case reference",
GeneralHelper.findAndReturnNodeText(hearingCase, "caseNumber"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public Map<String, List<Map<String, String>>> get(JsonNode payload) {

Map<String, String> fields = ImmutableMap.of(
"Defendant", sitting.getDefendantInfo().getName(),
"Prosecutor", caseInfo.getProsecutingAuthorityCode(),
"Prosecuting authority", caseInfo.getProsecutingAuthorityCode(),
"Case reference", caseInfo.getCaseNumber(),
"Hearing type", caseInfo.getHearingType(),
"Offence", offenceTitles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public Map<String, List<Map<String, String>>> get(JsonNode payload) {

Map<String, String> fields = ImmutableMap.of(
"Defendant", item.getDefendantInfo().getName(),
"Prosecutor", item.getDefendantInfo().getProsecutor(),
"Prosecuting authority", item.getDefendantInfo().getProsecutor(),
"Postcode", item.getDefendantInfo().getPostcode(),
"Case reference", item.getCaseInfo().getUrn(),
"Offence", offenceTitles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public Map<String, List<Map<String, String>>> get(JsonNode payload) {
.collect(Collectors.joining(", "));

Map<String, String> fields = ImmutableMap.of(
"Defendant", item.getDefendant().getName(),
"Name", item.getDefendant().getName(),
"Prosecutor", item.getDefendant().getProsecutor(),
"Case reference", item.getCaseInfo().getUrn(),
"Offence", offenceTitles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private void addFieldsToCases(Hearing hearing, List<Map<String, String>> summary
Map<String, String> fields = ImmutableMap.of(
"Appellant", hearingCase.getAppellant(),
"Respondent", hearingCase.getRespondent(),
"Appeal reference", hearingCase.getAppealRef()
"Case reference", hearingCase.getAppealRef()
);
summaryCases.add(fields);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ void testPublicationSummaryGenerationWithoutSectionHeading() {
.as(SUMMARY_MESSAGE)
.containsExactly(
LINE_SEPARATOR,
"key1 - value1",
"key1 - value1",
"key2 - value2",
"key3 - value3",
LINE_SEPARATOR,
"key1 - value4",
"key1 - value4",
"key2 - value5",
"key3 - value6",
LINE_SEPARATOR,
"key1 - value7",
"key1 - value7",
"key2 - value8",
"key3 - value9"
);
Expand All @@ -86,15 +86,15 @@ void testPublicationSummaryGenerationWithSectionHeading() {
.containsExactly(
LINE_SEPARATOR,
"##heading1",
"key1 - value1",
"key1 - value1",
"key2 - value2",
"key3 - value3",
LINE_SEPARATOR,
"##heading2",
"key1 - value4",
"key1 - value4",
"key2 - value5",
"key3 - value6",
"key1 - value7",
"key1 - value7",
"key2 - value8",
"key3 - value9"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private void assertSummaryFieldKeys(SoftAssertions softly, Map<String, String> s

softly.assertThat(keys.get(1))
.as(SUMMARY_FIELD_KEY_MESSAGE)
.isEqualTo("Prosecutor");
.isEqualTo("Prosecuting authority");

softly.assertThat(keys.get(2))
.as(SUMMARY_FIELD_KEY_MESSAGE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private void assertSummaryFieldKeys(SoftAssertions softly, Map<String, String> s

softly.assertThat(keys.get(1))
.as(SUMMARY_FIELD_KEY_MESSAGE)
.isEqualTo("Prosecutor");
.isEqualTo("Prosecuting authority");

softly.assertThat(keys.get(2))
.as(SUMMARY_FIELD_KEY_MESSAGE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private void assertSummaryFieldKeys(SoftAssertions softly, Map<String, String> s

softly.assertThat(keys.get(1))
.as(SUMMARY_FIELD_KEY_MESSAGE)
.isEqualTo("Prosecutor");
.isEqualTo("Prosecuting authority");

softly.assertThat(keys.get(2))
.as(SUMMARY_FIELD_KEY_MESSAGE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private void assertSummaryFieldKeys(SoftAssertions softly, Map<String, String> s

softly.assertThat(keys.get(0))
.as(SUMMARY_FIELD_KEY_MESSAGE)
.isEqualTo("Appellant");
.isEqualTo("Appellant/Applicant");

softly.assertThat(keys.get(1))
.as(SUMMARY_FIELD_KEY_MESSAGE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private void assertSummaryFieldKeys(SoftAssertions softly, Map<String, String> s

softly.assertThat(keys.get(1))
.as(SUMMARY_FIELD_KEY_MESSAGE)
.isEqualTo("Prosecutor");
.isEqualTo("Prosecuting authority");

softly.assertThat(keys.get(2))
.as(SUMMARY_FIELD_KEY_MESSAGE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private void assertSummaryFieldKeys(SoftAssertions softly, Map<String, String> s

softly.assertThat(keys.get(1))
.as(SUMMARY_FIELD_KEY_MESSAGE)
.isEqualTo("Prosecutor");
.isEqualTo("Prosecuting authority");

softly.assertThat(keys.get(2))
.as(SUMMARY_FIELD_KEY_MESSAGE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private void assertSummaryFieldKeys(SoftAssertions softly, Map<String, String> s

softly.assertThat(keys.get(1))
.as(SUMMARY_FIELD_KEY_MESSAGE)
.isEqualTo("Prosecutor");
.isEqualTo("Prosecuting authority");

softly.assertThat(keys.get(2))
.as(SUMMARY_FIELD_KEY_MESSAGE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private void assertSummaryFieldKeys(SoftAssertions softly, Map<String, String> s

softly.assertThat(keys.get(0))
.as(SUMMARY_FIELD_KEY_MESSAGE)
.isEqualTo("Defendant");
.isEqualTo("Name");

softly.assertThat(keys.get(1))
.as(SUMMARY_FIELD_KEY_MESSAGE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private void assertSummaryFieldKeys(SoftAssertions softly, Map<String, String> s

softly.assertThat(keys.get(2))
.as(SUMMARY_FIELD_KEY_MESSAGE)
.isEqualTo("Appeal reference");
.isEqualTo("Case reference");
}

private void assertSummaryFieldValues(SoftAssertions softly, Map<String, String> summaryFields) {
Expand Down