diff --git a/pom.xml b/pom.xml
index a855a61e..412fd764 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,7 +30,7 @@
17.0.38
0.0.3
17.0.42
- 17.0.262
+ 17.0.279
17.0.87
${coredomain.version}
17.0.24
diff --git a/prosecutioncasefile-domain/prosecutioncasefile-domain-event-processor/pom.xml b/prosecutioncasefile-domain/prosecutioncasefile-domain-event-processor/pom.xml
index b3929ba6..2e5c5193 100644
--- a/prosecutioncasefile-domain/prosecutioncasefile-domain-event-processor/pom.xml
+++ b/prosecutioncasefile-domain/prosecutioncasefile-domain-event-processor/pom.xml
@@ -245,6 +245,17 @@
+
+ uk.gov.moj.cpp.progression
+ progression-datatypes-common
+ ${progression.version}
+
+
+ *
+ *
+
+
+
uk.gov.moj.cpp.core.domain
criminal-court-public-model
diff --git a/prosecutioncasefile-event/prosecutioncasefile-event-processor/src/main/java/uk/gov/moj/cpp/prosecution/casefile/event/processor/converter/ProsecutionCaseFileDefendantToCCDefendantConverter.java b/prosecutioncasefile-event/prosecutioncasefile-event-processor/src/main/java/uk/gov/moj/cpp/prosecution/casefile/event/processor/converter/ProsecutionCaseFileDefendantToCCDefendantConverter.java
index 6d4d8fb5..27a65362 100644
--- a/prosecutioncasefile-event/prosecutioncasefile-event-processor/src/main/java/uk/gov/moj/cpp/prosecution/casefile/event/processor/converter/ProsecutionCaseFileDefendantToCCDefendantConverter.java
+++ b/prosecutioncasefile-event/prosecutioncasefile-event-processor/src/main/java/uk/gov/moj/cpp/prosecution/casefile/event/processor/converter/ProsecutionCaseFileDefendantToCCDefendantConverter.java
@@ -69,7 +69,7 @@ public List convert(final List getGender(final uk.gov.moj.cpp.prosecution.casefile.jso
}
}
+ private static Integer nonNegativeOrNull(final Integer value) {
+ return value == null || value < 0 ? null : value;
+ }
+
private Address buildAddress(final ParentGuardianInformation parentGuardianInformation) {
if (null != parentGuardianInformation.getPersonalInformation() && null != parentGuardianInformation.getPersonalInformation().getAddress()) {
diff --git a/prosecutioncasefile-event/prosecutioncasefile-event-processor/src/test/java/uk/gov/moj/cpp/prosecution/casefile/event/processor/converter/ProsecutionCaseFileDefendantToCCDefendantConverterTest.java b/prosecutioncasefile-event/prosecutioncasefile-event-processor/src/test/java/uk/gov/moj/cpp/prosecution/casefile/event/processor/converter/ProsecutionCaseFileDefendantToCCDefendantConverterTest.java
index 7f4969b0..17a4ccfc 100644
--- a/prosecutioncasefile-event/prosecutioncasefile-event-processor/src/test/java/uk/gov/moj/cpp/prosecution/casefile/event/processor/converter/ProsecutionCaseFileDefendantToCCDefendantConverterTest.java
+++ b/prosecutioncasefile-event/prosecutioncasefile-event-processor/src/test/java/uk/gov/moj/cpp/prosecution/casefile/event/processor/converter/ProsecutionCaseFileDefendantToCCDefendantConverterTest.java
@@ -105,4 +105,61 @@ private void assertAliasMiddleNameValues(final List defendants = prosecutionWithReferenceData.getProsecution().getDefendants();
+ defendants.forEach(d -> ReflectionUtil.setField(d, "numPreviousConvictions", -1));
+
+ final ParamsVO paramsVO = new ParamsVO();
+ paramsVO.setCaseId(prosecutionWithReferenceData.getProsecution().getCaseDetails().getCaseId());
+ paramsVO.setReferenceDataVO(prosecutionWithReferenceData.getReferenceDataVO());
+ paramsVO.setInitiationCode("J");
+
+ when(referenceDataQueryService.retrieveAlcoholLevelMethods()).thenReturn(asList(alcoholLevelMethodReferenceData().withMethodCode("A").withMethodDescription("Blood").build(),
+ alcoholLevelMethodReferenceData().withMethodCode("B").withMethodDescription("Breath").build()));
+
+ final List courtsDefendants = converter.convert(defendants, paramsVO);
+
+ assertThat(courtsDefendants.get(0).getNumberOfPreviousConvictionsCited(), is(nullValue()));
+ }
+
+ @Test
+ public void convertNonNegativeNumPreviousConvictionsShouldBePreserved() {
+ final ProsecutionWithReferenceData prosecutionWithReferenceData = buildProsecutionWithReferenceData(EITHER_WAY);
+ final List defendants = prosecutionWithReferenceData.getProsecution().getDefendants();
+ defendants.forEach(d -> ReflectionUtil.setField(d, "numPreviousConvictions", 0));
+
+ final ParamsVO paramsVO = new ParamsVO();
+ paramsVO.setCaseId(prosecutionWithReferenceData.getProsecution().getCaseDetails().getCaseId());
+ paramsVO.setReferenceDataVO(prosecutionWithReferenceData.getReferenceDataVO());
+ paramsVO.setInitiationCode("J");
+
+ when(referenceDataQueryService.retrieveAlcoholLevelMethods()).thenReturn(asList(alcoholLevelMethodReferenceData().withMethodCode("A").withMethodDescription("Blood").build(),
+ alcoholLevelMethodReferenceData().withMethodCode("B").withMethodDescription("Breath").build()));
+
+ final List courtsDefendants = converter.convert(defendants, paramsVO);
+
+ assertThat(courtsDefendants.get(0).getNumberOfPreviousConvictionsCited(), is(0));
+ }
+
+ @Test
+ public void convertNullNumPreviousConvictionsShouldRemainNull() {
+ final ProsecutionWithReferenceData prosecutionWithReferenceData = buildProsecutionWithReferenceData(EITHER_WAY);
+ final List defendants = prosecutionWithReferenceData.getProsecution().getDefendants();
+ defendants.forEach(d -> ReflectionUtil.setField(d, "numPreviousConvictions", null));
+
+ final ParamsVO paramsVO = new ParamsVO();
+ paramsVO.setCaseId(prosecutionWithReferenceData.getProsecution().getCaseDetails().getCaseId());
+ paramsVO.setReferenceDataVO(prosecutionWithReferenceData.getReferenceDataVO());
+ paramsVO.setInitiationCode("J");
+
+ when(referenceDataQueryService.retrieveAlcoholLevelMethods()).thenReturn(asList(alcoholLevelMethodReferenceData().withMethodCode("A").withMethodDescription("Blood").build(),
+ alcoholLevelMethodReferenceData().withMethodCode("B").withMethodDescription("Breath").build()));
+
+ final List courtsDefendants = converter.convert(defendants, paramsVO);
+
+ assertThat(courtsDefendants.get(0).getNumberOfPreviousConvictionsCited(), is(nullValue()));
+ }
}
\ No newline at end of file