-
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.
Lagar test for import og fikser alt som ikkje fungerer
Co-authored-by: Per-Christian Nielsen <per-christian.nielsen@nav.no> Co-authored-by: Christian Klem <christian.klem@nav.no> Co-authored-by: Thomas Dufourd <thomas.dufourd@nav.no> Co-authored-by: Nima Jimale <nima.jimale@nav.no>
- Loading branch information
1 parent
866c3c0
commit f589222
Showing
9 changed files
with
103 additions
and
1 deletion.
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
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
15 changes: 15 additions & 0 deletions
15
src/main/resources/db/migration/V49__sykefravar_statistikk_bransje_tabell.sql
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,15 @@ | ||
create table sykefravar_statistikk_bransje | ||
( | ||
id serial primary key, | ||
arstall smallint not null, | ||
kvartal smallint not null, | ||
bransje varchar not null, | ||
antall_personer decimal not null, | ||
tapte_dagsverk decimal not null, | ||
mulige_dagsverk decimal not null, | ||
prosent decimal not null, | ||
maskert boolean not null, | ||
opprettet timestamp default current_timestamp, | ||
constraint bransje_periode unique (bransje, arstall, kvartal) | ||
); | ||
create index idx_bransje_sykefravar_statistikk_bransje on sykefravar_statistikk_bransje(bransje); |
75 changes: 75 additions & 0 deletions
75
...dia/container/sykefraversstatistikk/importering/SykefraversstatistikkBransjeImportTest.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,75 @@ | ||
package no.nav.lydia.container.sykefraversstatistikk.importering | ||
|
||
import no.nav.lydia.Kafka | ||
import no.nav.lydia.container.sykefraversstatistikk.importering.SykefraversstatistikkImportTestUtils.Companion.KVARTAL_2023_1 | ||
import no.nav.lydia.container.sykefraversstatistikk.importering.SykefraversstatistikkImportTestUtils.Companion.cleanUpStatistikkSiste4KvartalTable | ||
import no.nav.lydia.container.sykefraversstatistikk.importering.SykefraversstatistikkImportTestUtils.Companion.cleanUpStatistikkTable | ||
import no.nav.lydia.container.sykefraversstatistikk.importering.SykefraversstatistikkImportTestUtils.Companion.hentStatistikkGjeldendeKvartal | ||
import no.nav.lydia.container.sykefraversstatistikk.importering.SykefraversstatistikkImportTestUtils.Companion.hentStatistikkSiste4Kvartal | ||
import no.nav.lydia.container.sykefraversstatistikk.importering.SykefraversstatistikkImportTestUtils.Companion.shouldBeEqual | ||
import no.nav.lydia.container.sykefraversstatistikk.importering.SykefraversstatistikkImportTestUtils.JsonMelding | ||
import no.nav.lydia.helper.KafkaContainerHelper | ||
import no.nav.lydia.helper.TestContainerHelper | ||
import no.nav.lydia.helper.TestData | ||
import no.nav.lydia.sykefraversstatistikk.import.Kategori.BRANSJE | ||
import no.nav.lydia.sykefraversstatistikk.import.Siste4Kvartal | ||
import no.nav.lydia.sykefraversstatistikk.import.SistePubliserteKvartal | ||
import kotlin.test.BeforeTest | ||
import kotlin.test.Test | ||
|
||
|
||
class SykefraversstatistikkBransjeImportTest { | ||
private val kafkaContainer = TestContainerHelper.kafkaContainerHelper | ||
|
||
private val sistePubliserteKvartal: SistePubliserteKvartal = | ||
SistePubliserteKvartal( | ||
årstall = KVARTAL_2023_1.årstall, | ||
kvartal = KVARTAL_2023_1.kvartal, | ||
tapteDagsverk = 504339.8, | ||
muligeDagsverk = 10104849.1, | ||
prosent = 6.0, | ||
erMaskert = false, | ||
antallPersoner = 3000001 | ||
) | ||
private val siste4Kvartal: Siste4Kvartal = | ||
Siste4Kvartal( | ||
tapteDagsverk = 31505774.2, | ||
muligeDagsverk = 578099000.3, | ||
prosent = 5.4, | ||
erMaskert = false, | ||
kvartaler = listOf(KVARTAL_2023_1) | ||
) | ||
|
||
@BeforeTest | ||
fun cleanUp() { | ||
cleanUpStatistikkTable(BRANSJE, TestData.BRANSJE_BARNEHAGE) | ||
cleanUpStatistikkSiste4KvartalTable(BRANSJE, TestData.BRANSJE_BARNEHAGE) | ||
} | ||
|
||
@Test | ||
fun `vi lagrer sykefraværsstatistikk for kategori BRANSJE (både siste kvartal OG siste 4 kvartaler)`() { | ||
val kafkaMelding = JsonMelding( | ||
kategori = BRANSJE, | ||
kode = TestData.BRANSJE_BARNEHAGE, | ||
kvartal = KVARTAL_2023_1, | ||
sistePubliserteKvartal = sistePubliserteKvartal, | ||
siste4Kvartal = siste4Kvartal | ||
) | ||
|
||
kafkaContainer.sendOgVentTilKonsumert( | ||
nøkkel = kafkaMelding.toJsonKey(), | ||
melding = kafkaMelding.toJsonValue(), | ||
topic = KafkaContainerHelper.statistikkBransjeTopic, | ||
konsumentGruppeId = Kafka.statistikkPerKategoriGroupId | ||
) | ||
|
||
kafkaMelding shouldBeEqual | ||
hentStatistikkGjeldendeKvartal( | ||
BRANSJE, | ||
TestData.BRANSJE_BARNEHAGE, | ||
KVARTAL_2023_1 | ||
).sistePubliserteKvartal | ||
kafkaMelding shouldBeEqual | ||
hentStatistikkSiste4Kvartal(BRANSJE, TestData.BRANSJE_BARNEHAGE).siste4Kvartal | ||
} | ||
} |
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