-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Justerte mock data, log debug for sikkerhet
- Loading branch information
1 parent
f1df7f6
commit 7f2e4bd
Showing
7 changed files
with
104 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 0 additions & 87 deletions
87
apps/bekreftelse-api/src/main/kotlin/no/nav/paw/bekreftelse/api/services/MockData.kt
This file was deleted.
Oops, something went wrong.
62 changes: 62 additions & 0 deletions
62
apps/bekreftelse-api/src/main/kotlin/no/nav/paw/bekreftelse/api/services/MockDataService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package no.nav.paw.bekreftelse.api.services | ||
|
||
import no.nav.paw.bekreftelse.api.model.TilgjengeligBekreftelse | ||
import no.nav.paw.bekreftelse.api.model.TilgjengeligBekreftelserResponse | ||
import no.nav.paw.config.hoplite.loadConfigFromProvidedResource | ||
import java.time.Duration | ||
import java.time.Instant | ||
import java.util.* | ||
|
||
data class MockBekreftelse( | ||
val id: UUID | ||
) | ||
|
||
data class MockPeriode( | ||
val id: UUID, | ||
val bekreftelser: List<MockBekreftelse> | ||
) | ||
|
||
data class MockPerson( | ||
val ident: String, | ||
val perioder: List<MockPeriode> | ||
) | ||
|
||
data class MockData( | ||
val personer: List<MockPerson> | ||
) | ||
|
||
// TODO Fjern når vi har ferdig Kafka-logikk | ||
class MockDataService { | ||
|
||
private var mockData = loadConfigFromProvidedResource<MockData>("/test/mock-data.toml") | ||
private var tilgjengeligBekreftelser = mutableMapOf<String, TilgjengeligBekreftelserResponse>() | ||
|
||
init { | ||
mockData.personer.forEach { person -> | ||
person.perioder.forEach { periode -> | ||
val bekreftelser = periode.bekreftelser.map { bekreftelse -> | ||
val days = Random().nextLong(1, 13) | ||
val gjelderFra = Instant.now().minus(Duration.ofDays(days)) | ||
val gjelserTil = gjelderFra.plus(Duration.ofDays(14)) | ||
TilgjengeligBekreftelse(periode.id, bekreftelse.id, gjelderFra, gjelserTil) | ||
} | ||
tilgjengeligBekreftelser[person.ident] = bekreftelser | ||
} | ||
} | ||
} | ||
|
||
fun finnTilgjengeligBekreftelser(identitetsnummer: String): TilgjengeligBekreftelserResponse { | ||
return tilgjengeligBekreftelser[identitetsnummer] ?: emptyList() | ||
} | ||
|
||
fun mottaBekreftelse( | ||
identitetsnummer: String, | ||
bekreftelseId: UUID | ||
) { | ||
val eksisterende = tilgjengeligBekreftelser[identitetsnummer] | ||
if (eksisterende != null) { | ||
val oppdatert = eksisterende.filter { it.bekreftelseId != bekreftelseId } | ||
tilgjengeligBekreftelser[identitetsnummer] = oppdatert | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
apps/bekreftelse-api/src/main/resources/test/mock-data.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
[[personer]] | ||
ident = "17830348441" | ||
[[personer.perioder]] | ||
id = "84201f96-363b-4aab-a589-89fa4b9b1feb" | ||
[[personer.perioder.bekreftelser]] | ||
id = "f45ffbf3-e4d5-49fd-b5b7-17aaee478dfc" | ||
|
||
[[personer]] | ||
ident = "19519238708" | ||
[[personer.perioder]] | ||
id = "ec6b5a10-b67c-42c1-b6e7-a642c36bd78e" | ||
[[personer.perioder.bekreftelser]] | ||
id = "0cae8890-5500-4f5f-8fc1-9a0aae3b35a0" | ||
|
||
[[personer]] | ||
ident = "02837797848" | ||
[[personer.perioder]] | ||
id = "44a4375c-b7ab-40ea-83f5-0eb9869925eb" | ||
[[personer.perioder.bekreftelser]] | ||
id = "4f5e7f5c-1fe3-4b27-a07b-34ff9f4ea23f" | ||
|
||
[[personer]] | ||
ident = "16868598968" | ||
[[personer.perioder]] | ||
id = "bbf3e9eb-6d7b-465b-bf79-ae6c82cf1ddd" | ||
[[personer.perioder.bekreftelser]] | ||
id = "47e5c02d-abab-4e75-951c-db6c985901e4" | ||
[[personer.perioder.bekreftelser]] | ||
id = "77322685-80db-41db-b79f-86915a9a5d9a" | ||
|
||
[[personer]] | ||
ident = "28878098821" | ||
[[personer.perioder]] | ||
id = "6ea57aec-353c-4df5-935f-9bead8afb221" | ||
[[personer.perioder.bekreftelser]] | ||
id = "992d5363-bab4-4b1d-987e-3e8eb4db3f64" | ||
[[personer.perioder.bekreftelser]] | ||
id = "9777408c-938d-41e6-b9fd-5177120695d6" |