Skip to content

Commit 4b9950b

Browse files
committed
Add source to offences
Added systemSource and serviceSource to offences and additional offences models as well as updating smoke and unit tests for these changes
1 parent 835e7e0 commit 4b9950b

File tree

8 files changed

+87
-38
lines changed

8 files changed

+87
-38
lines changed

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/Offence.kt

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps
33
import java.time.LocalDate
44

55
data class Offence(
6+
val serviceSource: UpstreamApi,
7+
val systemSource: SystemSource,
68
val cjsCode: String? = null,
79
val hoCode: String? = null,
810
val courtDates: List<LocalDate?> = listOf(),

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/ndelius/NDeliusAdditionalOffence.kt

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.ndelius
22

33
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Offence
4+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.SystemSource
5+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApi
46
import java.time.LocalDate
57

68
data class NDeliusAdditionalOffence(
@@ -9,6 +11,8 @@ data class NDeliusAdditionalOffence(
911
val date: String? = null,
1012
) {
1113
fun toOffence(courtDates: List<LocalDate>): Offence = Offence(
14+
serviceSource = UpstreamApi.NDELIUS,
15+
systemSource = SystemSource.PROBATION_SYSTEMS,
1216
cjsCode = null,
1317
hoCode = this.code,
1418
courtDates = courtDates,

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/ndelius/NDeliusMainOffence.kt

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.ndelius
22

33
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Offence
4+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.SystemSource
5+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApi
46
import java.time.LocalDate
57

68
data class NDeliusMainOffence(
@@ -9,6 +11,8 @@ data class NDeliusMainOffence(
911
val date: String? = null,
1012
) {
1113
fun toOffence(courtDates: List<LocalDate>): Offence = Offence(
14+
serviceSource = UpstreamApi.NDELIUS,
15+
systemSource = SystemSource.PROBATION_SYSTEMS,
1216
cjsCode = null,
1317
hoCode = this.code,
1418
courtDates = courtDates,

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/nomis/NomisOffenceHistoryDetail.kt

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.nomis
22

33
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Offence
4+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.SystemSource
5+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApi
46
import java.time.LocalDate
57

68
data class NomisOffenceHistoryDetail(
@@ -12,6 +14,8 @@ data class NomisOffenceHistoryDetail(
1214
val statuteCode: String,
1315
) {
1416
fun toOffence(): Offence = Offence(
17+
serviceSource = UpstreamApi.NOMIS,
18+
systemSource = SystemSource.PRISON_SYSTEMS,
1519
cjsCode = this.offenceCode,
1620
courtDates = listOf(this.courtDate).filterNotNull(),
1721
description = this.offenceDescription,

src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/controllers/v1/person/OffencesControllerTest.kt

+7-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ import org.springframework.test.context.ActiveProfiles
1616
import org.springframework.test.web.servlet.MockMvc
1717
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.extensions.removeWhitespaceAndNewlines
1818
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.helpers.IntegrationAPIMockMvc
19-
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Offence
20-
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Response
21-
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApi
22-
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApiError
19+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.*
2320
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.services.GetOffencesForPersonService
2421
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.services.internal.AuditService
2522
import java.net.URLEncoder
@@ -47,6 +44,8 @@ internal class OffencesControllerTest(
4744
Response(
4845
data = listOf(
4946
Offence(
47+
serviceSource = UpstreamApi.NDELIUS,
48+
systemSource = SystemSource.PROBATION_SYSTEMS,
5049
cjsCode = "RR99999",
5150
hoCode = "05800",
5251
courtDates = listOf(LocalDate.parse("2023-03-03")),
@@ -79,6 +78,8 @@ internal class OffencesControllerTest(
7978
"""
8079
"data": [
8180
{
81+
"serviceSource": "NDELIUS",
82+
"systemSource": "PROBATION_SYSTEMS",
8283
"cjsCode": "RR99999",
8384
"hoCode": "05800",
8485
"courtDates": ["2023-03-03"],
@@ -138,6 +139,8 @@ internal class OffencesControllerTest(
138139
data =
139140
List(20) {
140141
Offence(
142+
serviceSource = UpstreamApi.NDELIUS,
143+
systemSource = SystemSource.PROBATION_SYSTEMS,
141144
cjsCode = "RR99999",
142145
courtDates = listOf(LocalDate.parse("2023-03-03")),
143146
description = "This is a description of an offence.",

src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/helpers/OffenceHelper.kt

+6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.helpers
22

33
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Offence
4+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.SystemSource
5+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApi
46
import java.time.LocalDate
57

68
fun generateTestOffence(
9+
serviceSource: UpstreamApi = UpstreamApi.NDELIUS,
10+
systemSource: SystemSource = SystemSource.PROBATION_SYSTEMS,
711
cjsCode: String? = "RR12345",
812
hoCode: String? = "05800",
913
description: String? = "Some description",
@@ -12,6 +16,8 @@ fun generateTestOffence(
1216
courtDates: List<LocalDate?> = listOf(LocalDate.parse("2020-04-03")),
1317
statuteCode: String? = "RR12",
1418
): Offence = Offence(
19+
serviceSource = serviceSource,
20+
systemSource = systemSource,
1521
cjsCode = cjsCode,
1622
hoCode = hoCode,
1723
description = description,

src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/ndelius/SupervisionsTest.kt

+20
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,32 @@ class SupervisionsTest : DescribeSpec(
3737
integrationApiOffences.shouldBe(
3838
listOf(
3939
Offence(
40+
serviceSource = UpstreamApi.NDELIUS,
41+
systemSource = SystemSource.PROBATION_SYSTEMS,
4042
description = "foobar",
4143
hoCode = "05800",
4244
courtDates = listOf(LocalDate.parse("2009-07-07")),
4345
startDate = LocalDate.parse("2000-01-02"),
4446
),
4547
Offence(
48+
serviceSource = UpstreamApi.NDELIUS,
49+
systemSource = SystemSource.PROBATION_SYSTEMS,
4650
description = "additionalFoo",
4751
hoCode = "12345",
4852
courtDates = listOf(LocalDate.parse("2009-07-07")),
4953
startDate = LocalDate.parse("2001-01-01"),
5054
),
5155
Offence(
56+
serviceSource = UpstreamApi.NDELIUS,
57+
systemSource = SystemSource.PROBATION_SYSTEMS,
5258
description = "barbaz",
5359
hoCode = "05800",
5460
courtDates = listOf(LocalDate.parse("2010-07-07")),
5561
startDate = LocalDate.parse("2003-03-03"),
5662
),
5763
Offence(
64+
serviceSource = UpstreamApi.NDELIUS,
65+
systemSource = SystemSource.PROBATION_SYSTEMS,
5866
description = "additionalFoo2",
5967
hoCode = "98765",
6068
courtDates = listOf(LocalDate.parse("2010-07-07")),
@@ -80,12 +88,16 @@ class SupervisionsTest : DescribeSpec(
8088
integrationApiOffences.shouldBe(
8189
listOf(
8290
Offence(
91+
serviceSource = UpstreamApi.NDELIUS,
92+
systemSource = SystemSource.PROBATION_SYSTEMS,
8393
description = "foobar",
8494
hoCode = "05800",
8595
courtDates = listOf(LocalDate.parse("2009-07-07")),
8696
startDate = LocalDate.parse("2000-01-02"),
8797
),
8898
Offence(
99+
serviceSource = UpstreamApi.NDELIUS,
100+
systemSource = SystemSource.PROBATION_SYSTEMS,
89101
description = "additionalFoo",
90102
hoCode = "12345",
91103
courtDates = listOf(LocalDate.parse("2009-07-07")),
@@ -112,12 +124,16 @@ class SupervisionsTest : DescribeSpec(
112124
integrationApiOffences.shouldBe(
113125
listOf(
114126
Offence(
127+
serviceSource = UpstreamApi.NDELIUS,
128+
systemSource = SystemSource.PROBATION_SYSTEMS,
115129
description = "foobar",
116130
hoCode = "05800",
117131
courtDates = listOf(LocalDate.parse("2009-07-07")),
118132
startDate = LocalDate.parse("2000-01-02"),
119133
),
120134
Offence(
135+
serviceSource = UpstreamApi.NDELIUS,
136+
systemSource = SystemSource.PROBATION_SYSTEMS,
121137
description = "additionalFoo",
122138
hoCode = "12345",
123139
courtDates = listOf(LocalDate.parse("2009-07-07")),
@@ -152,12 +168,16 @@ class SupervisionsTest : DescribeSpec(
152168
integrationApiOffences.shouldBe(
153169
listOf(
154170
Offence(
171+
serviceSource = UpstreamApi.NDELIUS,
172+
systemSource = SystemSource.PROBATION_SYSTEMS,
155173
description = "foobar",
156174
hoCode = "05800",
157175
courtDates = listOf(LocalDate.parse("2009-07-07")),
158176
startDate = LocalDate.parse("2019-09-09"),
159177
),
160178
Offence(
179+
serviceSource = UpstreamApi.NDELIUS,
180+
systemSource = SystemSource.PROBATION_SYSTEMS,
161181
description = "barbaz",
162182
hoCode = "05800",
163183
courtDates = listOf(LocalDate.parse("2010-07-07")),

src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/smoke/person/OffencesSmokeTest.kt

+40-34
Original file line numberDiff line numberDiff line change
@@ -24,40 +24,46 @@ class OffencesSmokeTest : DescribeSpec(
2424
"""
2525
{
2626
"data": [
27-
{
28-
"cjsCode": "RR84070",
29-
"hoCode": null,
30-
"courtDates": [
31-
"2018-02-10"
32-
],
33-
"description": "Commit an act / series of acts with intent to pervert the course of public justice",
34-
"endDate": "2018-03-10",
35-
"startDate": "2018-02-10",
36-
"statuteCode": "RR84"
37-
},
38-
{
39-
"cjsCode": null,
40-
"hoCode": "string",
41-
"courtDates": [
42-
"2019-08-24"
43-
],
44-
"description": "string",
45-
"endDate": null,
46-
"startDate": "2019-08-24",
47-
"statuteCode": null
48-
},
49-
{
50-
"cjsCode": null,
51-
"hoCode": "string",
52-
"courtDates": [
53-
"2019-08-24"
54-
],
55-
"description": "string",
56-
"endDate": null,
57-
"startDate": "2019-08-24",
58-
"statuteCode": null
59-
}
60-
],
27+
{
28+
"serviceSource": "NOMIS",
29+
"systemSource": "PRISON_SYSTEMS",
30+
"cjsCode": "RR84070",
31+
"hoCode": null,
32+
"courtDates": [
33+
"2018-02-10"
34+
],
35+
"description": "Commit an act / series of acts with intent to pervert the course of public justice",
36+
"endDate": "2018-03-10",
37+
"startDate": "2018-02-10",
38+
"statuteCode": "RR84"
39+
},
40+
{
41+
"serviceSource": "NDELIUS",
42+
"systemSource": "PROBATION_SYSTEMS",
43+
"cjsCode": null,
44+
"hoCode": "string",
45+
"courtDates": [
46+
"2019-08-24"
47+
],
48+
"description": "string",
49+
"endDate": null,
50+
"startDate": "2019-08-24",
51+
"statuteCode": null
52+
},
53+
{
54+
"serviceSource": "NDELIUS",
55+
"systemSource": "PROBATION_SYSTEMS",
56+
"cjsCode": null,
57+
"hoCode": "string",
58+
"courtDates": [
59+
"2019-08-24"
60+
],
61+
"description": "string",
62+
"endDate": null,
63+
"startDate": "2019-08-24",
64+
"statuteCode": null
65+
}
66+
],
6167
"pagination": {
6268
"isLastPage": true,
6369
"count": 3,

0 commit comments

Comments
 (0)