Skip to content

Commit 2a0bc9f

Browse files
committed
Parse tom dato-streng til null
1 parent 5d6444b commit 2a0bc9f

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

src/main/kotlin/no/nav/hjelpemidler/Application.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ fun main() {
9191
return@post
9292
}
9393

94-
if (ordrelinje.hjelpemiddeltype != "Hjelpemiddel") {
94+
if (ordrelinje.hjelpemiddeltype != "Hjelpemiddel" ||
95+
ordrelinje.hjelpemiddeltype != "Individstyrt hjelpemiddel"
96+
) {
9597
logg.info("Mottok melding fra oebs med hjelpemiddeltype ${ordrelinje.hjelpemiddeltype}.")
9698
call.respond(HttpStatusCode.OK)
9799
return@post

src/main/kotlin/no/nav/hjelpemidler/model/Statusinfo.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ data class Statusinfo(
2020
@JsonProperty("IncidentSoknadType")
2121
valknadstype: String,
2222

23+
// N.B.: Viss dato er "" i meldinga blir den til null under deserialisering og forblir null under serialisering (utgåande JSON)
2324
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
2425
@JsonProperty("IncidentVedtakDato")
25-
val vedtaksdato: LocalDate,
26+
val vedtaksdato: LocalDate?,
2627

2728
@JsonProperty("IncidentSoknad")
2829
valknad: String,

src/test/kotlin/no/nav/hjelpemidler/DateTimeTest.kt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,42 @@ internal class DateTimeTest {
4848
assertEquals(LocalDate.of(2021, 4, 5), result.sistOppdatert)
4949
println(mapper.writeValueAsString(result))
5050
}
51+
52+
@ExperimentalTime
53+
@Test
54+
fun `Parse tom dato-streng til LocalDate`() {
55+
val mapper = jacksonObjectMapper()
56+
mapper.registerModule(JavaTimeModule())
57+
58+
val result: Statusinfo = mapper.readValue(
59+
"""
60+
{
61+
"System": "DIGIHOT",
62+
"IncidentNummer":21072339,
63+
"IncidentStatus": "Open",
64+
"IncidentType": "Vedtak Infotrygd",
65+
"IncidentSoknadType": "HJDAAN",
66+
"IncidentVedtakDato": "",
67+
"IncidentSoknad": "S",
68+
"IncidentResultat": "I",
69+
"IncidentRef": "A01",
70+
"OrdreNumber":7068818,
71+
"LineNumber":1,
72+
"ShipmentNumber":1,
73+
"Description": "Rullator 4hjul Topro Olympos M b71 h79-95 sh60 sml",
74+
"CategoryDescription": "",
75+
"OrderedItem":149305,
76+
"User_ItemType": "Hjelpemiddel",
77+
"Quantity":1,
78+
"AccountNumber": "XXXXXXXXXXX",
79+
"LastUpdateDate": "2021-04-05"
80+
}
81+
""".trimIndent()
82+
)
83+
84+
println(result.toString())
85+
assertEquals(null, result.vedtaksdato)
86+
assertEquals(LocalDate.of(2021, 4, 5), result.sistOppdatert)
87+
println(mapper.writeValueAsString(result))
88+
}
5189
}

0 commit comments

Comments
 (0)