Skip to content

Commit 2f84092

Browse files
WIP - adding courtname (#422)
* WIP - adding courtname * Open api * smoke * Fix smoke
1 parent 6bc0cb1 commit 2f84092

File tree

12 files changed

+51
-11
lines changed

12 files changed

+51
-11
lines changed

openapi.yml

+4
Original file line numberDiff line numberDiff line change
@@ -1671,6 +1671,10 @@ components:
16711671
example:
16721672
- "2018-02-10"
16731673
- "2019-02-10"
1674+
courtName:
1675+
type: string
1676+
description: The court name
1677+
example: "London Magistrates Court"
16741678
description:
16751679
type: string
16761680
example: Commit an act / series of acts with intent to pervert the course of public justice

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

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ data class Offence(
88
val cjsCode: String? = null,
99
val hoCode: String? = null,
1010
val courtDates: List<LocalDate?> = listOf(),
11+
val courtName: String? = null,
1112
val description: String? = null,
1213
val endDate: LocalDate? = null,
1314
val startDate: LocalDate? = null,

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@ data class NDeliusAdditionalOffence(
1010
val code: String? = null,
1111
val date: String? = null,
1212
) {
13-
fun toOffence(courtDates: List<LocalDate>): Offence =
13+
fun toOffence(
14+
courtDates: List<LocalDate>,
15+
courtName: String?,
16+
): Offence =
1417
Offence(
1518
serviceSource = UpstreamApi.NDELIUS,
1619
systemSource = SystemSource.PROBATION_SYSTEMS,
1720
cjsCode = null,
1821
hoCode = this.code,
1922
courtDates = courtDates,
23+
courtName = courtName,
2024
endDate = null,
2125
startDate = if (!this.date.isNullOrEmpty()) LocalDate.parse(this.date) else null,
2226
statuteCode = null,

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

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

33
data class NDeliusCourtAppearance(
44
val date: CharSequence? = null,
5+
val court: String? = null,
56
)

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@ data class NDeliusMainOffence(
1010
val code: String? = null,
1111
val date: String? = null,
1212
) {
13-
fun toOffence(courtDates: List<LocalDate>): Offence =
13+
fun toOffence(
14+
courtDates: List<LocalDate>,
15+
courtName: String?,
16+
): Offence =
1417
Offence(
1518
serviceSource = UpstreamApi.NDELIUS,
1619
systemSource = SystemSource.PROBATION_SYSTEMS,
1720
cjsCode = null,
1821
hoCode = this.code,
1922
courtDates = courtDates,
23+
courtName = courtName,
2024
endDate = null,
2125
startDate = LocalDate.parse(this.date),
2226
statuteCode = null,

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ data class NDeliusSupervision(
1717
) {
1818
fun toOffences(): List<Offence> {
1919
val courtDates = this.courtAppearances.mapNotNull { LocalDate.parse(it.date, DateTimeFormatter.ISO_OFFSET_DATE_TIME) }
20-
return listOf(this.mainOffence.toOffence(courtDates)) + this.additionalOffences.map { it.toOffence(courtDates) }
20+
val courtName = this.courtAppearances.firstOrNull()?.court
21+
val mainOffence = this.mainOffence.toOffence(courtDates, courtName)
22+
val additionalOffences = this.additionalOffences.map { it.toOffence(courtDates, courtName) }
23+
return listOf(mainOffence) + additionalOffences
2124
}
2225

2326
fun toSentence(): Sentence {

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

+3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ internal class OffencesControllerTest(
5656
cjsCode = "RR99999",
5757
hoCode = "05800",
5858
courtDates = listOf(LocalDate.parse("2023-03-03")),
59+
courtName = "Llandudno Magistrates Court",
5960
description = "This is a description of an offence.",
6061
endDate = LocalDate.parse("2023-02-01"),
6162
startDate = LocalDate.parse("2023-01-01"),
@@ -90,6 +91,7 @@ internal class OffencesControllerTest(
9091
"cjsCode": "RR99999",
9192
"hoCode": "05800",
9293
"courtDates": ["2023-03-03"],
94+
"courtName": "Llandudno Magistrates Court",
9395
"description": "This is a description of an offence.",
9496
"endDate":"2023-02-01",
9597
"startDate": "2023-01-01",
@@ -154,6 +156,7 @@ internal class OffencesControllerTest(
154156
systemSource = SystemSource.PROBATION_SYSTEMS,
155157
cjsCode = "RR99999",
156158
courtDates = listOf(LocalDate.parse("2023-03-03")),
159+
courtName = "Llandudno Magistrates Court",
157160
description = "This is a description of an offence.",
158161
endDate = LocalDate.parse("2023-02-01"),
159162
startDate = LocalDate.parse("2023-01-01"),

src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/ndelius/GetOffencesForPersonTest.kt

+5
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class GetOffencesForPersonTest(
7373
LocalDate.parse("2009-07-07"),
7474
LocalDate.parse("2009-07-07"),
7575
),
76+
courtName = "Llandudno Magistrates Court",
7677
description = "Common assault and battery - 10501",
7778
endDate = null,
7879
startDate = LocalDate.parse("2009-03-31"),
@@ -86,6 +87,7 @@ class GetOffencesForPersonTest(
8687
LocalDate.parse("2009-07-07"),
8788
LocalDate.parse("2009-07-07"),
8889
),
90+
courtName = "Llandudno Magistrates Court",
8991
description = "Other Criminal Damage (including causing explosion) - 05800",
9092
endDate = null,
9193
startDate = LocalDate.parse("2009-03-31"),
@@ -99,6 +101,7 @@ class GetOffencesForPersonTest(
99101
LocalDate.parse("2009-09-01"),
100102
LocalDate.parse("2009-08-11"),
101103
),
104+
courtName = "Llandudno Magistrates Court",
102105
description = "Threatening behaviour, fear or provocation of violence (Public Order Act 1986) - 12511",
103106
endDate = null,
104107
startDate = LocalDate.parse("2009-07-31"),
@@ -112,6 +115,7 @@ class GetOffencesForPersonTest(
112115
LocalDate.parse("2009-09-01"),
113116
LocalDate.parse("2009-08-11"),
114117
),
118+
courtName = "Llandudno Magistrates Court",
115119
description = "Stealing from the person of another - 03900",
116120
endDate = null,
117121
startDate = LocalDate.parse("2009-08-14"),
@@ -125,6 +129,7 @@ class GetOffencesForPersonTest(
125129
LocalDate.parse("2009-09-01"),
126130
LocalDate.parse("2009-08-11"),
127131
),
132+
courtName = "Llandudno Magistrates Court",
128133
description = "Migrated Breach Offences",
129134
endDate = null,
130135
startDate = LocalDate.parse("1900-01-01"),

src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/ndelius/fixtures/GetSupervisionsResponse.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@
139139
{
140140
"type": "Sentence",
141141
"date": "2009-09-01T00:00:00+01:00",
142-
"court": "Rhuddlan Magistrates Court",
142+
"court": "Llandudno Magistrates Court",
143143
"plea": "Guilty"
144144
},
145145
{
146146
"type": "Trial/Adjournment",
147147
"date": "2009-08-11T00:00:00+01:00",
148-
"court": "Rhuddlan Magistrates Court",
148+
"court": "Llandudno Magistrates Court",
149149
"plea": "Guilty"
150150
}
151151
]

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

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ fun generateTestOffence(
1414
startDate: LocalDate? = LocalDate.parse("2020-02-03"),
1515
endDate: LocalDate? = LocalDate.parse("2020-03-03"),
1616
courtDates: List<LocalDate?> = listOf(LocalDate.parse("2020-04-03")),
17+
courtName: String? = "Llandudno Magistrates Court",
1718
statuteCode: String? = "RR12",
1819
): Offence =
1920
Offence(
@@ -25,5 +26,6 @@ fun generateTestOffence(
2526
startDate = startDate,
2627
endDate = endDate,
2728
courtDates = courtDates,
29+
courtName = courtName,
2830
statuteCode = statuteCode,
2931
)

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

+16-6
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class SupervisionsTest : DescribeSpec(
2828
listOf(
2929
NDeliusAdditionalOffence(description = "additionalFoo", code = "12345", date = "2001-01-01"),
3030
),
31-
courtAppearances = listOf(NDeliusCourtAppearance(date = "2009-07-07T00:00:00+01:00")),
31+
courtAppearances = listOf(NDeliusCourtAppearance(date = "2009-07-07T00:00:00+01:00", court = "London Magistrates Court")),
3232
),
3333
NDeliusSupervision(
3434
custodial = true,
@@ -37,7 +37,7 @@ class SupervisionsTest : DescribeSpec(
3737
listOf(
3838
NDeliusAdditionalOffence(description = "additionalFoo2", code = "98765", date = "2001-02-02"),
3939
),
40-
courtAppearances = listOf(NDeliusCourtAppearance(date = "2010-07-07T00:00:00+01:00")),
40+
courtAppearances = listOf(NDeliusCourtAppearance(date = "2010-07-07T00:00:00+01:00", court = "London Magistrates Court")),
4141
),
4242
),
4343
)
@@ -52,6 +52,7 @@ class SupervisionsTest : DescribeSpec(
5252
description = "foobar",
5353
hoCode = "05800",
5454
courtDates = listOf(LocalDate.parse("2009-07-07")),
55+
courtName = "London Magistrates Court",
5556
startDate = LocalDate.parse("2000-01-02"),
5657
),
5758
Offence(
@@ -60,6 +61,7 @@ class SupervisionsTest : DescribeSpec(
6061
description = "additionalFoo",
6162
hoCode = "12345",
6263
courtDates = listOf(LocalDate.parse("2009-07-07")),
64+
courtName = "London Magistrates Court",
6365
startDate = LocalDate.parse("2001-01-01"),
6466
),
6567
Offence(
@@ -68,6 +70,7 @@ class SupervisionsTest : DescribeSpec(
6870
description = "barbaz",
6971
hoCode = "05800",
7072
courtDates = listOf(LocalDate.parse("2010-07-07")),
73+
courtName = "London Magistrates Court",
7174
startDate = LocalDate.parse("2003-03-03"),
7275
),
7376
Offence(
@@ -76,6 +79,7 @@ class SupervisionsTest : DescribeSpec(
7679
description = "additionalFoo2",
7780
hoCode = "98765",
7881
courtDates = listOf(LocalDate.parse("2010-07-07")),
82+
courtName = "London Magistrates Court",
7983
startDate = LocalDate.parse("2001-02-02"),
8084
),
8185
),
@@ -92,7 +96,7 @@ class SupervisionsTest : DescribeSpec(
9296
custodial = true,
9397
mainOffence = NDeliusMainOffence(description = "foobar", code = "05800", date = "2000-01-02"),
9498
additionalOffences = listOf(NDeliusAdditionalOffence(description = "additionalFoo", code = "12345")),
95-
courtAppearances = listOf(NDeliusCourtAppearance(date = "2009-07-07T00:00:00+01:00")),
99+
courtAppearances = listOf(NDeliusCourtAppearance(date = "2009-07-07T00:00:00+01:00", court = "London Magistrates Court")),
96100
),
97101
),
98102
)
@@ -107,6 +111,7 @@ class SupervisionsTest : DescribeSpec(
107111
description = "foobar",
108112
hoCode = "05800",
109113
courtDates = listOf(LocalDate.parse("2009-07-07")),
114+
courtName = "London Magistrates Court",
110115
startDate = LocalDate.parse("2000-01-02"),
111116
),
112117
Offence(
@@ -115,6 +120,7 @@ class SupervisionsTest : DescribeSpec(
115120
description = "additionalFoo",
116121
hoCode = "12345",
117122
courtDates = listOf(LocalDate.parse("2009-07-07")),
123+
courtName = "London Magistrates Court",
118124
startDate = null,
119125
),
120126
),
@@ -135,7 +141,7 @@ class SupervisionsTest : DescribeSpec(
135141
listOf(
136142
NDeliusAdditionalOffence(description = "additionalFoo", code = "12345", date = "2001-01-01"),
137143
),
138-
courtAppearances = listOf(NDeliusCourtAppearance(date = "2009-07-07T00:00:00+01:00")),
144+
courtAppearances = listOf(NDeliusCourtAppearance(date = "2009-07-07T00:00:00+01:00", court = "London Magistrates Court")),
139145
),
140146
),
141147
)
@@ -150,6 +156,7 @@ class SupervisionsTest : DescribeSpec(
150156
description = "foobar",
151157
hoCode = "05800",
152158
courtDates = listOf(LocalDate.parse("2009-07-07")),
159+
courtName = "London Magistrates Court",
153160
startDate = LocalDate.parse("2000-01-02"),
154161
),
155162
Offence(
@@ -158,6 +165,7 @@ class SupervisionsTest : DescribeSpec(
158165
description = "additionalFoo",
159166
hoCode = "12345",
160167
courtDates = listOf(LocalDate.parse("2009-07-07")),
168+
courtName = "London Magistrates Court",
161169
startDate = LocalDate.parse("2001-01-01"),
162170
),
163171
),
@@ -177,13 +185,13 @@ class SupervisionsTest : DescribeSpec(
177185
custodial = true,
178186
mainOffence = NDeliusMainOffence(description = "foobar", code = "05800", date = "2019-09-09"),
179187
additionalOffences = emptyList(),
180-
courtAppearances = listOf(NDeliusCourtAppearance(date = "2009-07-07T00:00:00+01:00")),
188+
courtAppearances = listOf(NDeliusCourtAppearance(date = "2009-07-07T00:00:00+01:00", court = "London Magistrates Court")),
181189
),
182190
NDeliusSupervision(
183191
custodial = true,
184192
mainOffence = NDeliusMainOffence(description = "barbaz", code = "05800", date = "2020-02-03"),
185193
additionalOffences = emptyList(),
186-
courtAppearances = listOf(NDeliusCourtAppearance(date = "2010-07-07T00:00:00+01:00")),
194+
courtAppearances = listOf(NDeliusCourtAppearance(date = "2010-07-07T00:00:00+01:00", court = "London Magistrates Court")),
187195
),
188196
),
189197
)
@@ -198,6 +206,7 @@ class SupervisionsTest : DescribeSpec(
198206
description = "foobar",
199207
hoCode = "05800",
200208
courtDates = listOf(LocalDate.parse("2009-07-07")),
209+
courtName = "London Magistrates Court",
201210
startDate = LocalDate.parse("2019-09-09"),
202211
),
203212
Offence(
@@ -206,6 +215,7 @@ class SupervisionsTest : DescribeSpec(
206215
description = "barbaz",
207216
hoCode = "05800",
208217
courtDates = listOf(LocalDate.parse("2010-07-07")),
218+
courtName = "London Magistrates Court",
209219
startDate = LocalDate.parse("2020-02-03"),
210220
),
211221
),

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

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class OffencesSmokeTest : DescribeSpec(
3232
"courtDates": [
3333
"2018-02-10"
3434
],
35+
"courtName": null,
3536
"description": "Commit an act / series of acts with intent to pervert the course of public justice",
3637
"endDate": "2018-03-10",
3738
"startDate": "2018-02-10",
@@ -45,6 +46,7 @@ class OffencesSmokeTest : DescribeSpec(
4546
"courtDates": [
4647
"2019-08-24"
4748
],
49+
"courtName": "string",
4850
"description": "string",
4951
"endDate": null,
5052
"startDate": "2019-08-24",
@@ -58,6 +60,7 @@ class OffencesSmokeTest : DescribeSpec(
5860
"courtDates": [
5961
"2019-08-24"
6062
],
63+
"courtName": "string",
6164
"description": "string",
6265
"endDate": null,
6366
"startDate": "2019-08-24",

0 commit comments

Comments
 (0)