Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
ee30d9f
Update completed SJP case (multiple offences) - BDF (#50)
sajanchandran Feb 17, 2026
08ca5b6
New 17.103.165-SNAPSHOT
Feb 17, 2026
93f27c1
DD-41687 Add indexes to defendant and employer table (#57)
sevketarisu Feb 25, 2026
2a39ce0
updating poms for 17.103.164 branch with snapshot versions
Feb 25, 2026
60776e9
updating poms for 17.103.165-SNAPSHOT development
Feb 25, 2026
db723b2
updating poms for branch'dev/release-17.103.164' with non-snapshot ve…
Feb 25, 2026
8ba1632
Merge branch 'dev/release-17.103.164' into dev/release
Feb 25, 2026
dd48205
updating develop poms to master versions to avoid merge conflicts
Feb 25, 2026
e09d6e1
Merge branch 'dev/release' into main
Feb 25, 2026
9be8660
Updating develop poms back to pre merge state
Feb 25, 2026
fedc54f
SNI-8214 New BDF endpoint to complete the case
sajanchandran Mar 5, 2026
4ceede8
Merge branch 'main' into dev/sni-8214-main
sajanchandran Mar 5, 2026
61f474f
Merge pull request #61 from hmcts/dev/sni-8214-main
ozturkmenb Mar 6, 2026
80596f7
updating poms for 17.103.166-SNAPSHOT development
Mar 6, 2026
5bc4a4e
Updated reference data version
sajanchandran Mar 6, 2026
2e033ca
Merge branch 'main' into dev/sni-8214-main
sajanchandran Mar 6, 2026
4168d9a
Merge pull request #62 from hmcts/dev/sni-8214-main
ozturkmenb Mar 6, 2026
90c3c0b
updating poms for 17.103.166 branch with snapshot versions
Mar 6, 2026
fc2af07
updating poms for 17.103.167-SNAPSHOT development
Mar 6, 2026
e5c4346
updating poms for branch'dev/release-17.103.166' with non-snapshot ve…
Mar 6, 2026
739449f
Merge branch 'dev/release-17.103.166' into dev/release
Mar 6, 2026
f6902f4
updating develop poms to master versions to avoid merge conflicts
Mar 6, 2026
7115394
Merge branch 'dev/release' into main
Mar 6, 2026
bf8b0cf
Updating develop poms back to pre merge state
Mar 6, 2026
d317a8a
CHD-2236 core domain update (#69)
aykutdanisman Apr 2, 2026
9dd9402
updating poms for 17.103.167 branch with snapshot versions
Apr 2, 2026
506d88e
updating poms for 17.103.168-SNAPSHOT development
Apr 2, 2026
d9e2f17
updating poms for branch'dev/release-17.103.167' with non-snapshot ve…
Apr 2, 2026
c4229a4
Merge branch 'dev/release-17.103.167' into dev/release
Apr 2, 2026
03b92df
updating develop poms to master versions to avoid merge conflicts
Apr 2, 2026
57915a7
Merge branch 'dev/release' into main
Apr 2, 2026
3856970
Updating develop poms back to pre merge state
Apr 2, 2026
a2d3982
Dev/cct 2473 main (#82)
erolkurelihmcts Apr 24, 2026
3d8d014
updating poms for 17.103.168 branch with snapshot versions
Apr 24, 2026
f4823f7
updating poms for 17.103.169-SNAPSHOT development
Apr 24, 2026
1f1e83c
updating poms for branch'dev/release-17.103.168' with non-snapshot ve…
Apr 24, 2026
6c47853
Merge branch 'dev/release-17.103.168' into dev/release
Apr 24, 2026
f1ece3d
updating develop poms to master versions to avoid merge conflicts
Apr 24, 2026
5879d3f
Merge branch 'dev/release' into main
Apr 24, 2026
d0e6705
Updating develop poms back to pre merge state
Apr 24, 2026
3777f27
CCT-2473 Code Merge (#83)
erolkurelihmcts Apr 24, 2026
72f4a59
updating poms for 17.103.169 branch with snapshot versions
Apr 24, 2026
01c5057
updating poms for 17.103.170-SNAPSHOT development
Apr 24, 2026
b2f76bb
updating poms for branch'dev/release-17.103.169' with non-snapshot ve…
Apr 24, 2026
b28436f
Merge branch 'dev/release-17.103.169' into dev/release
Apr 24, 2026
04d668b
updating develop poms to master versions to avoid merge conflicts
Apr 24, 2026
e00b23f
Merge branch 'dev/release' into main
Apr 24, 2026
f9be385
Updating develop poms back to pre merge state
Apr 24, 2026
74a4c71
[DD-42429] - Updated progression and core domain version
habibulrahaman May 5, 2026
cf820fa
Merge pull request #88 from hmcts/dev/DD-42429
habibulrahaman May 5, 2026
80822ba
updating poms for 17.103.170 branch with snapshot versions
May 5, 2026
cd8602e
updating poms for 17.103.171-SNAPSHOT development
May 5, 2026
fb617e1
updating poms for branch'dev/release-17.103.170' with non-snapshot ve…
May 5, 2026
eb368fc
Merge branch 'dev/release-17.103.170' into dev/release
May 5, 2026
41745c3
updating develop poms to master versions to avoid merge conflicts
May 5, 2026
0b4fba2
Merge branch 'dev/release' into main
May 5, 2026
9ca0665
Updating develop poms back to pre merge state
May 5, 2026
7c3f3e1
Dev/rel 3rd line 2612 (#95)
sajanchandran May 15, 2026
f3f43ed
updating poms for 17.103.171 branch with snapshot versions
May 15, 2026
af4075e
updating poms for 17.103.172-SNAPSHOT development
May 15, 2026
12b917b
updating poms for branch'dev/release-17.103.171' with non-snapshot ve…
May 15, 2026
e88c59c
Merge branch 'dev/release-17.103.171' into dev/release
May 15, 2026
c5f463d
updating develop poms to master versions to avoid merge conflicts
May 15, 2026
16fad98
Merge branch 'dev/release' into main
May 15, 2026
a1c6da1
Updating develop poms back to pre merge state
May 15, 2026
445e4f5
CCT-2411 Code merge (#103)
yilmazsaritemur2 May 28, 2026
5f8b409
updating poms for 17.103.172 branch with snapshot versions
May 28, 2026
b07f860
updating poms for 17.103.173-SNAPSHOT development
May 28, 2026
a03789b
updating poms for branch'dev/release-17.103.172' with non-snapshot ve…
May 28, 2026
3486533
Merge branch 'dev/release-17.103.172' into dev/release
May 28, 2026
4ab9f96
updating develop poms to master versions to avoid merge conflicts
May 28, 2026
9c19e78
Merge branch 'dev/release' into main
May 28, 2026
f0d1f81
Updating develop poms back to pre merge state
May 28, 2026
80d2eda
updating poms for 17.103.174-SNAPSHOT development
May 29, 2026
eef3b03
updating poms for 17.103.174 branch with snapshot versions
May 29, 2026
19bea27
updating poms for 17.103.175-SNAPSHOT development
May 29, 2026
7b271eb
updating poms for branch'dev/release-17.103.174' with non-snapshot ve…
May 29, 2026
89a3cd1
Merge branch 'dev/release-17.103.174' into dev/release
May 29, 2026
7a3f63d
updating develop poms to master versions to avoid merge conflicts
May 29, 2026
6090a41
Merge branch 'dev/release' into main
May 29, 2026
8412b1a
Updating develop poms back to pre merge state
May 29, 2026
993a41b
CHD-1784 | Merge to main (#111)
sahil-arora-hmcts Jun 16, 2026
94fbfd1
updating poms for 17.104.176-SNAPSHOT development
Jun 16, 2026
d43eb3e
updating poms for 17.104.177-SNAPSHOT development
Jun 16, 2026
e8cb3af
updating poms for 17.104.178-SNAPSHOT development
Jun 16, 2026
fe45f3c
updating poms for 17.104.179-SNAPSHOT development
Jun 17, 2026
e60bce3
Updating refdata version in main (#115)
sahil-arora-hmcts Jun 17, 2026
e90629f
updating poms for 17.104.179 branch with snapshot versions
Jun 17, 2026
1dd7480
updating poms for 17.104.180-SNAPSHOT development
Jun 17, 2026
df94d7b
updating poms for branch'dev/release-17.104.179' with non-snapshot ve…
Jun 17, 2026
a807d21
Merge branch 'dev/release-17.104.179' into dev/release
Jun 17, 2026
3977e5d
updating develop poms to master versions to avoid merge conflicts
Jun 17, 2026
c9bd0a3
Merge branch 'dev/release' into main
Jun 17, 2026
f1275b7
Updating develop poms back to pre merge state
Jun 17, 2026
dc59528
updating poms for 17.104.180 branch with snapshot versions
Jun 17, 2026
1b35cff
updating poms for 17.104.181-SNAPSHOT development
Jun 17, 2026
45940f5
updating poms for branch'dev/release-17.104.180' with non-snapshot ve…
Jun 17, 2026
bbca8c7
Merge branch 'dev/release-17.104.180' into dev/release
Jun 17, 2026
58a9d4b
updating develop poms to master versions to avoid merge conflicts
Jun 17, 2026
0d4e923
Merge branch 'dev/release' into main
Jun 17, 2026
e538d1e
Updating develop poms back to pre merge state
Jun 17, 2026
d1dd430
Dev/release 2617 (#117)
kumarsajan1983 Jul 2, 2026
db5c164
updating poms for 17.104.181 branch with snapshot versions
Jul 2, 2026
8211740
updating poms for 17.104.182-SNAPSHOT development
Jul 2, 2026
991b149
updating poms for branch'dev/release-17.104.181' with non-snapshot ve…
Jul 2, 2026
d3d621e
Merge branch 'dev/release-17.104.181' into dev/release
Jul 2, 2026
5eac466
updating develop poms to master versions to avoid merge conflicts
Jul 2, 2026
7316694
Merge branch 'dev/release' into main
Jul 2, 2026
f385820
Updating develop poms back to pre merge state
Jul 2, 2026
ecd792e
CAD-767 civil tranche 1 toggle off merge
sriniJavaGit Jul 30, 2026
e361014
CAD-767 civil tranche 1 toggle off merge
sriniJavaGit Jul 30, 2026
4652d36
CAD-767 civil tranche 1 toggle off merge
sriniJavaGit Jul 30, 2026
a0bee45
CAD-767 civil tranche 1 toggle off merge
sriniJavaGit Jul 30, 2026
8b7a939
Merge pull request #128 from hmcts/dev/CAD-1575
rajkumarmeena Jul 30, 2026
8ad4066
updating poms for 17.104.183-SNAPSHOT development
Jul 30, 2026
141dd17
updating poms for 17.104.183 branch with snapshot versions
Jul 31, 2026
40aaff8
updating poms for 17.104.184-SNAPSHOT development
Jul 31, 2026
1ab5ab5
updating poms for branch'dev/release-17.104.183' with non-snapshot ve…
Jul 31, 2026
ed09804
Merge branch 'dev/release-17.104.183' into dev/release
Jul 31, 2026
0f3fabd
updating develop poms to master versions to avoid merge conflicts
Jul 31, 2026
a7a50be
Merge branch 'dev/release' into main
Jul 31, 2026
7cb2afe
Updating develop poms back to pre merge state
Jul 31, 2026
2ab1283
version update for fresh build
rajkumarmeena Jul 31, 2026
3d7f502
Merge pull request #129 from hmcts/versionupdate
rajkumarmeena Jul 31, 2026
8148268
updating poms for 17.104.186-SNAPSHOT development
Jul 31, 2026
3778054
CIMD-3915 : merge to main
Jul 31, 2026
961ce24
updating poms for 17.104.187-SNAPSHOT development
Jul 31, 2026
3af01e3
Merge branch 'main' into dev/CIMD-3915-merge
erolkurelihmcts Jul 31, 2026
44414f3
Merge pull request #130 from hmcts/dev/CIMD-3915-merge
erolkurelihmcts Jul 31, 2026
3c49b13
updating poms for 17.104.188-SNAPSHOT development
Jul 31, 2026
6d79749
updating poms for 17.104.189-SNAPSHOT development
Jul 31, 2026
f86c009
updating poms for 17.104.190-SNAPSHOT development
Jul 31, 2026
f266237
updating poms for 17.104.191-SNAPSHOT development
Jul 31, 2026
091536d
updating poms for 17.104.192-SNAPSHOT development
Jul 31, 2026
81b2910
updating poms for 17.104.192 branch with snapshot versions
Jul 31, 2026
55b3337
updating poms for 17.104.193-SNAPSHOT development
Jul 31, 2026
bb8475c
updating poms for branch'dev/release-17.104.192' with non-snapshot ve…
Jul 31, 2026
826fd1d
Merge branch 'dev/release-17.104.192' into dev/release
Jul 31, 2026
e7e682f
updating develop poms to master versions to avoid merge conflicts
Jul 31, 2026
d50a0df
Merge branch 'dev/release' into main
Jul 31, 2026
5fd8f3b
Updating develop poms back to pre merge state
Jul 31, 2026
cbbf9a5
Merge branch 'main' into team/DD-41592
aliyksel Aug 6, 2026
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
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
<access-control-sjp-providers.version>4.1.4-ATCM</access-control-sjp-providers.version>
<material.version>17.0.57</material.version>
<notification.notify.version>17.0.1</notification.notify.version>
<referencedata.version>17.103.133</referencedata.version>
<referencedata.offences.version>17.0.38</referencedata.offences.version>
<referencedata.version>17.104.137</referencedata.version>
<referencedata.offences.version>17.104.52</referencedata.offences.version>
<scheduling.version>17.0.11</scheduling.version>
<authorisation.service.version>0.1.49</authorisation.service.version>
<usersgroups.version>17.104.48</usersgroups.version>
<progression.version>17.0.262</progression.version>
<progression.version>17.0.286</progression.version>
<prosecutioncasefile.version>17.0.66</prosecutioncasefile.version>
<access-control-sjp-providers.version>4.1.4-ATCM</access-control-sjp-providers.version>
<cpp.framework.action.mapping.enabled>true</cpp.framework.action.mapping.enabled>
Expand All @@ -65,7 +65,7 @@
<apache.pdfbox.version>2.0.11</apache.pdfbox.version>
<argLine>-Djava.locale.providers=CLDR</argLine>
<elasticsearch-maven-plugin.version>6.13</elasticsearch-maven-plugin.version>
<elasticsearch.embedded.version>9.2.2</elasticsearch.embedded.version>
<elasticsearch.embedded.version>7.16.2</elasticsearch.embedded.version>
<stagingenforcement.version>17.104.81</stagingenforcement.version>
<unifiedsearch.version>17.104.4-DD-41592-SNAPSHOT</unifiedsearch.version>
<jsonassert.version>1.5.0</jsonassert.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static java.lang.System.lineSeparator;
import static java.util.UUID.fromString;
import static java.util.stream.Collectors.joining;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import static uk.gov.justice.core.courts.JudicialResult.judicialResult;

import uk.gov.justice.core.courts.JudicialResult;
Expand Down Expand Up @@ -65,6 +66,7 @@ public class JudicialResultHelper {
"I", "INTERMEDIARY");

public static final String Y = "Y";
public static final String DURATION = "duration";


private JudicialResultHelper() {
Expand Down Expand Up @@ -93,13 +95,21 @@ public static JudicialResultPrompt.Builder populatePromptDefinitionAttributesBas
resultDefinition.getJsonArray("prompts")
.getValuesAs(JsonObject.class)
.stream()
.filter(prompt -> prompt.getString("id").equals(jsPrompt.getId().toString())
&& duration.equals(prompt.getString("duration")))
.filter(prompt -> prompt.getString("id").equals(jsPrompt.getId().toString()))
.filter(prompt -> prompt.containsKey(DURATION))
.filter(prompt -> isNotBlank(prompt.getString(DURATION)) && isNotBlank(duration))
.filter(prompt -> isDurationStringMatchesPromptValue(duration, prompt))
.findFirst();

return populatePrompt(jsPrompt, promptJson);
}

private static boolean isDurationStringMatchesPromptValue(final String duration, final JsonObject prompt) {
final String alphaOnlyPattern = "[^a-zA-Z]";
final String promptValue = prompt.getString(DURATION).replaceAll(alphaOnlyPattern, "");
return duration.equals(promptValue) || duration.toUpperCase().contains(promptValue.toUpperCase()) || promptValue.toUpperCase().contains(duration.toUpperCase());
}

@SuppressWarnings("squid:S00112")
private static JudicialResultPrompt.Builder populatePrompt(final JPrompt jsPrompt,
final Optional<JsonObject> promptJson) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import uk.gov.justice.services.messaging.JsonEnvelope;
import uk.gov.moj.cpp.sjp.domain.decision.Dismiss;
import uk.gov.moj.cpp.sjp.domain.decision.OffenceDecision;
import uk.gov.moj.cpp.sjp.event.processor.results.converter.ConvictionInfo;
import uk.gov.moj.cpp.sjp.event.processor.results.converter.judicialresult.JCachedReferenceData;
import uk.gov.moj.cpp.sjp.event.processor.results.converter.judicialresult.DecisionAggregate;

Expand Down Expand Up @@ -49,6 +50,13 @@ public void aggregate(final OffenceDecision offenceDecision,

setFinalOffence(decisionAggregate, offenceId, judicialResults);

// conviction information - a dismissal carries the FOUND_NOT_GUILTY verdict dated on the
// resulting date but has no convicting court
decisionAggregate.putConvictionInfo(offenceId,
new ConvictionInfo(offenceId,
dismissOffenceDecision.getOffenceDecisionInformation().getVerdict(),
resultedOn.toLocalDate(),
null));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import uk.gov.moj.cpp.sjp.event.processor.results.converter.judicialresult.DecisionAggregate;
import uk.gov.moj.cpp.sjp.event.processor.results.converter.judicialresult.JCachedReferenceData;

import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -160,7 +161,8 @@ private void populateCourtTimingDetails(final JsonObject resultDefinition,
.withJudicialResultPromptTypeId(NHMC_DURATION_IN_MINUTES.getId())
.withValue(caseOffenceListedInCriminalCourts.getHearingDays().get(0).getListedDurationMinutes().toString()).build());

final ZonedDateTime sittingDateTime = caseOffenceListedInCriminalCourts.getHearingDays().get(0).getSittingDay();
final ZonedDateTime sittingDateTime = caseOffenceListedInCriminalCourts.getHearingDays().get(0).getSittingDay()
.withZoneSameInstant(ZoneId.of("Europe/London"));

judicialResultPrompts.add(getPrompt(NHMC_HOUSE_HEARING_TIME, resultDefinition)
.withJudicialResultPromptTypeId(NHMC_HOUSE_HEARING_TIME.getId())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
package uk.gov.moj.cpp.sjp.event.processor.results.converter.judicialresult;

import static java.util.UUID.fromString;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static uk.gov.moj.cpp.sjp.event.processor.results.converter.judicialresult.JPrompt.DDP_DISQUALIFICATION_PERIOD;
import static uk.gov.moj.cpp.sjp.event.processor.utils.FileUtil.getFileContentAsJson;

import uk.gov.justice.core.courts.JudicialResultPrompt;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.UUID;

import javax.json.Json;
import javax.json.JsonObject;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class JudicialResultHelperTest {

private static final String RESULT_DEFINITION_FILE = "ddq-result-definition.json";
private static final UUID DISQUALIFICATION_PERIOD_PROMPT_ID = fromString("2bf54447-328c-4c1b-a123-341adbd52172");

private JsonObject resultDefinition;

@BeforeEach
public void setUp() {
resultDefinition = getFileContentAsJson(RESULT_DEFINITION_FILE, new HashMap<>());
}

@Test
public void shouldPopulatePromptDefinitionAttributesForYearsDuration() {
final JudicialResultPrompt.Builder builder = JudicialResultHelper.populatePromptDefinitionAttributesBasedOnDuration(
DDP_DISQUALIFICATION_PERIOD, resultDefinition, "Years");

final JudicialResultPrompt prompt = builder.build();

assertThat(prompt.getJudicialResultPromptTypeId(), is(DISQUALIFICATION_PERIOD_PROMPT_ID));
assertThat(prompt.getLabel(), is("Disqualification period"));
assertThat(prompt.getWelshLabel(), is("Cyfnod gwahardd"));
assertThat(prompt.getPromptReference(), is("disqualificationPeriod"));
assertThat(prompt.getType(), is("INTM"));
assertThat(prompt.getCourtExtract(), is("Y"));
assertThat(prompt.getDurationSequence(), is(1));
assertThat(prompt.getPromptSequence(), is(new BigDecimal(100)));
assertThat(prompt.getIsFinancialImposition(), is(false));
}

@Test
public void shouldPopulatePromptDefinitionAttributesForMonthsDuration() {
final JudicialResultPrompt.Builder builder = JudicialResultHelper.populatePromptDefinitionAttributesBasedOnDuration(
DDP_DISQUALIFICATION_PERIOD, resultDefinition, "Months");

final JudicialResultPrompt prompt = builder.build();

assertThat(prompt.getJudicialResultPromptTypeId(), is(DISQUALIFICATION_PERIOD_PROMPT_ID));
assertThat(prompt.getLabel(), is("Disqualification period"));
assertThat(prompt.getWelshLabel(), is("Cyfnod gwahardd"));
assertThat(prompt.getPromptReference(), is("disqualificationPeriod"));
assertThat(prompt.getType(), is("INTM"));
assertThat(prompt.getCourtExtract(), is("Y"));
assertThat(prompt.getDurationSequence(), is(1));
assertThat(prompt.getPromptSequence(), is(new BigDecimal(100)));
assertThat(prompt.getIsFinancialImposition(), is(false));
}

@Test
public void shouldPopulatePromptDefinitionAttributesForDaysDuration() {
final JudicialResultPrompt.Builder builder = JudicialResultHelper.populatePromptDefinitionAttributesBasedOnDuration(
DDP_DISQUALIFICATION_PERIOD, resultDefinition, "Days");

final JudicialResultPrompt prompt = builder.build();

assertThat(prompt.getJudicialResultPromptTypeId(), is(DISQUALIFICATION_PERIOD_PROMPT_ID));
assertThat(prompt.getLabel(), is("Disqualification period"));
assertThat(prompt.getWelshLabel(), is("Cyfnod gwahardd"));
assertThat(prompt.getPromptReference(), is("disqualificationPeriod"));
assertThat(prompt.getType(), is("INTM"));
assertThat(prompt.getCourtExtract(), is("Y"));
assertThat(prompt.getDurationSequence(), is(1));
assertThat(prompt.getPromptSequence(), is(new BigDecimal(100)));
assertThat(prompt.getIsFinancialImposition(), is(false));
}

@Test
public void shouldPopulatePromptDefinitionAttributesWhenDurationDiffersOnlyByCase() {
final JudicialResultPrompt.Builder builder = JudicialResultHelper.populatePromptDefinitionAttributesBasedOnDuration(
DDP_DISQUALIFICATION_PERIOD, resultDefinition, "months");

final JudicialResultPrompt prompt = builder.build();

assertThat(prompt.getJudicialResultPromptTypeId(), is(DISQUALIFICATION_PERIOD_PROMPT_ID));
assertThat(prompt.getPromptReference(), is("disqualificationPeriod"));
}

@Test
public void shouldPopulatePromptDefinitionAttributesWhenDurationIsSingularFormOfPromptValue() {
final JudicialResultPrompt.Builder builder = JudicialResultHelper.populatePromptDefinitionAttributesBasedOnDuration(
DDP_DISQUALIFICATION_PERIOD, resultDefinition, "Year");

final JudicialResultPrompt prompt = builder.build();

assertThat(prompt.getJudicialResultPromptTypeId(), is(DISQUALIFICATION_PERIOD_PROMPT_ID));
assertThat(prompt.getPromptReference(), is("disqualificationPeriod"));
}

@Test
public void shouldPopulatePromptDefinitionAttributesWhenPromptValueIsSubstringOfDuration() {
final JudicialResultPrompt.Builder builder = JudicialResultHelper.populatePromptDefinitionAttributesBasedOnDuration(
DDP_DISQUALIFICATION_PERIOD, resultDefinition, "CalendarDays");

final JudicialResultPrompt prompt = builder.build();

assertThat(prompt.getJudicialResultPromptTypeId(), is(DISQUALIFICATION_PERIOD_PROMPT_ID));
assertThat(prompt.getPromptReference(), is("disqualificationPeriod"));
}

@Test
public void shouldThrowRuntimeExceptionWhenPromptNotFoundForDuration() {
assertThrows(RuntimeException.class, () ->
JudicialResultHelper.populatePromptDefinitionAttributesBasedOnDuration(
JPrompt.AMOUNT_OF_FINE, resultDefinition, "Years"));
}

@Test
public void shouldThrowRuntimeExceptionWhenDurationDoesNotMatchAnyPromptValue() {
assertThrows(RuntimeException.class, () ->
JudicialResultHelper.populatePromptDefinitionAttributesBasedOnDuration(
DDP_DISQUALIFICATION_PERIOD, resultDefinition, "Weeks"));
}

@Test
public void shouldThrowRuntimeExceptionWhenDurationIsBlank() {
assertThrows(RuntimeException.class, () ->
JudicialResultHelper.populatePromptDefinitionAttributesBasedOnDuration(
DDP_DISQUALIFICATION_PERIOD, resultDefinition, ""));
}

@Test
public void shouldThrowRuntimeExceptionWhenDurationIsNull() {
assertThrows(RuntimeException.class, () ->
JudicialResultHelper.populatePromptDefinitionAttributesBasedOnDuration(
DDP_DISQUALIFICATION_PERIOD, resultDefinition, null));
}

@Test
public void shouldThrowRuntimeExceptionWhenMatchingPromptHasBlankDurationValue() {
final JsonObject resultDefinitionWithBlankDuration = Json.createObjectBuilder()
.add("prompts", Json.createArrayBuilder()
.add(Json.createObjectBuilder()
.add("id", DISQUALIFICATION_PERIOD_PROMPT_ID.toString())
.add("duration", "")))
.build();

assertThrows(RuntimeException.class, () ->
JudicialResultHelper.populatePromptDefinitionAttributesBasedOnDuration(
DDP_DISQUALIFICATION_PERIOD, resultDefinitionWithBlankDuration, "Years"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
import static org.hamcrest.Matchers.hasProperty;
import static org.hamcrest.MatcherAssert.assertThat;
import static uk.gov.moj.cpp.sjp.domain.decision.OffenceDecisionInformation.createOffenceDecisionInformation;
import static uk.gov.moj.cpp.sjp.domain.verdict.VerdictType.FOUND_GUILTY;
import static uk.gov.moj.cpp.sjp.domain.verdict.VerdictType.FOUND_NOT_GUILTY;
import static uk.gov.moj.cpp.sjp.event.processor.results.converter.judicialresult.JCaseResultsConstants.DATE_FORMAT;

import uk.gov.moj.cpp.sjp.domain.decision.Dismiss;
import uk.gov.moj.cpp.sjp.event.processor.results.converter.ConvictionInfo;
import uk.gov.moj.cpp.sjp.event.processor.results.converter.judicialresult.DecisionAggregate;

import org.hamcrest.Matchers;
Expand All @@ -37,7 +38,7 @@ public void setUp() {
@Test
public void shouldPopulateResultWithRightPrompts() {
final Dismiss offenceDecision
= new Dismiss(null, createOffenceDecisionInformation(offence1Id, FOUND_GUILTY));
= new Dismiss(null, createOffenceDecisionInformation(offence1Id, FOUND_NOT_GUILTY));

aggregator.aggregate(offenceDecision, sjpSessionEnvelope, resultsAggregate, resultedOn);

Expand All @@ -49,4 +50,19 @@ public void shouldPopulateResultWithRightPrompts() {
hasProperty("judicialResultPrompts", is(nullValue()))))));
assertThat(resultsAggregate.getFinalOffence(offenceDecision.getOffenceIds().get(0)),Matchers.is(true));
}

@Test
public void shouldPopulateConvictionInfoWithFoundNotGuiltyVerdict() {
final Dismiss offenceDecision
= new Dismiss(null, createOffenceDecisionInformation(offence1Id, FOUND_NOT_GUILTY));

aggregator.aggregate(offenceDecision, sjpSessionEnvelope, resultsAggregate, resultedOn);

final ConvictionInfo convictionInfo = resultsAggregate.getConvictionInfo(offence1Id);
assertThat(convictionInfo, is(Matchers.notNullValue()));
assertThat(convictionInfo.getOffenceId(), Matchers.is(offence1Id));
assertThat(convictionInfo.getVerdictType(), Matchers.is(FOUND_NOT_GUILTY));
assertThat(convictionInfo.getConvictionDate(), is(resultedOn.toLocalDate()));
assertThat(convictionInfo.getConvictingCourt(), is(nullValue()));
}
}
Loading
Loading