Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Commit

Permalink
Swap out kotest for junit
Browse files Browse the repository at this point in the history
  • Loading branch information
MikAoJk committed Nov 8, 2023
1 parent 43c25e7 commit 8d91eb2
Show file tree
Hide file tree
Showing 12 changed files with 350 additions and 339 deletions.
5 changes: 3 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
val kluentVersion = "1.73"
val kotlinVersion = "1.9.20"
val kotestVersion = "5.8.0"
val junitJupiterVersion = "5.10.0"
val javaVersion = JavaVersion.VERSION_17

repositories {
Expand Down Expand Up @@ -30,7 +30,8 @@ subprojects {
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")

testImplementation("io.kotest:kotest-runner-junit5:$kotestVersion")
testImplementation("org.junit.jupiter:junit-jupiter:$junitJupiterVersion")

testImplementation("org.amshove.kluent:kluent:$kluentVersion")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package no.nav.syfo.sm

import org.amshove.kluent.shouldBeGreaterThan
import org.junit.jupiter.api.Test

internal class DiagnosekodeTest {
@Test
fun `ICPC2 should be loaded`() {
Diagnosekoder.icpc2.size shouldBeGreaterThan 100
}


@Test
fun `ICD10 should be loaded`() {
Diagnosekoder.icd10.size shouldBeGreaterThan 100
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package no.nav.syfo.model

import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
import com.fasterxml.jackson.module.kotlin.readValue
import com.fasterxml.jackson.module.kotlin.registerKotlinModule
import org.amshove.kluent.shouldBeEqualTo
import org.amshove.kluent.shouldNotBe
import org.junit.jupiter.api.Test
import java.time.LocalDateTime
import java.time.Month

internal class ReceivedSykmeldingTest {
val objectMapper = ObjectMapper()
.registerKotlinModule()
.registerModule(JavaTimeModule())
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)

@Test
fun `Maksimal gyldig ReceivedSykmelding skal validere ok`() {
val receivedSykmelding: ReceivedSykmelding = objectMapper.readValue(
ReceivedSykmelding::class.java.getResourceAsStream("/gyldig-receivedsykmelding-maksimal.json")
.readBytes().toString(Charsets.UTF_8)
)

receivedSykmelding.mottattDato shouldBeEqualTo LocalDateTime.of(2020, Month.JANUARY, 1, 12, 28, 40)
receivedSykmelding.sykmelding.id shouldBeEqualTo "b5e84795-43a8-4adb-ac1d-4b2e1e0c5fb7"
receivedSykmelding.sykmelding.arbeidsgiver shouldBeEqualTo Arbeidsgiver(
harArbeidsgiver = HarArbeidsgiver.EN_ARBEIDSGIVER,
navn = "Min Bedrift",
yrkesbetegnelse = "Konsulent",
stillingsprosent = 100
)
receivedSykmelding.sykmelding.utdypendeOpplysninger["6.3"] shouldNotBe null
}

@Test
fun `Minimal gyldig ReceivedSykmelding skal validere ok`() {
val receivedSykmelding: ReceivedSykmelding = objectMapper.readValue(
ReceivedSykmelding::class.java.getResourceAsStream("/gyldig-receivedsykmelding-minimal.json")
.readBytes().toString(Charsets.UTF_8)
)

receivedSykmelding.msgId shouldBeEqualTo "A24A4DD6-AE61-493B-A0C9-46FD45F859DB"
receivedSykmelding.legekontorOrgNr shouldBeEqualTo null
receivedSykmelding.sykmelding.behandler.etternavn shouldBeEqualTo "Superlege"
receivedSykmelding.sykmelding.kontaktMedPasient.begrunnelseIkkeKontakt shouldBeEqualTo null
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package no.nav.syfo.model

import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
import com.fasterxml.jackson.module.kotlin.readValue
import com.fasterxml.jackson.module.kotlin.registerKotlinModule
import org.amshove.kluent.shouldBeEqualTo
import org.junit.jupiter.api.Test

internal class ValidationResultTest {
val objectMapper: ObjectMapper = ObjectMapper()
.registerKotlinModule()
.registerModule(JavaTimeModule())
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)

@Test
fun `Gyldig ValidationResult med resultat OK skal validere ok`() {
val validationResult: ValidationResult = objectMapper.readValue(
ValidationResult::class.java.getResourceAsStream("/gyldig-validationresult-ok.json").readBytes()
.toString(Charsets.UTF_8)
)

validationResult.status shouldBeEqualTo Status.OK
validationResult.ruleHits.size shouldBeEqualTo 0
}

@Test
fun `Gyldig ValidationResult med resultat MANUAL_PROCESSING skal validere ok`() {
val validationResult: ValidationResult = objectMapper.readValue(
ValidationResult::class.java.getResourceAsStream("/gyldig-validationresult-manuell.json").readBytes()
.toString(Charsets.UTF_8)
)

validationResult.status shouldBeEqualTo Status.MANUAL_PROCESSING
validationResult.ruleHits.size shouldBeEqualTo 1
validationResult.ruleHits[0] shouldBeEqualTo RuleInfo(
ruleName = "TILBAKEDATERT_MED_BEGRUNNELSE_FORLENGELSE",
messageForSender = "Sykmeldingen er tilbakedatert og felt 11.2 (begrunnelseIkkeKontakt) er utfylt",
messageForUser = "Sykmeldingen er tilbakedatert og årsak for tilbakedatering er angitt",
ruleStatus = Status.MANUAL_PROCESSING
)
}

@Test
fun `Gyldig ValidationResult med resultat INVALID skal validere ok`() {
val validationResult: ValidationResult = objectMapper.readValue(
ValidationResult::class.java.getResourceAsStream("/gyldig-validationresult-avvist.json").readBytes()
.toString(Charsets.UTF_8)
)

validationResult.status shouldBeEqualTo Status.INVALID
validationResult.ruleHits.size shouldBeEqualTo 1
validationResult.ruleHits[0] shouldBeEqualTo RuleInfo(
ruleName = "TILBAKEDATERT_MER_ENN_8_DAGER_FORSTE_SYKMELDING",
messageForSender = "Sykmeldingen kan ikke rettes, det må skrives en ny. Pasienten har fått beskjed om å vente på ny sykmelding fra deg.",
messageForUser = "Sykmeldingen er tilbakedatert uten begrunnelse fra den som sykmeldte deg.",
ruleStatus = Status.INVALID
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,41 @@ import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
import com.fasterxml.jackson.module.kotlin.readValue
import com.fasterxml.jackson.module.kotlin.registerKotlinModule
import io.kotest.core.spec.style.FunSpec
import org.amshove.kluent.shouldBeEqualTo
import org.junit.jupiter.api.Test
import java.time.LocalDate
import java.time.Month

class ArbeidsgiverSykmeldingTest : FunSpec({
internal class ArbeidsgiverSykmeldingTest {
val objectMapper = ObjectMapper()
.registerKotlinModule()
.registerModule(JavaTimeModule())
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true)
.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)

context("Validering av ArbeidsgiverSykmelding") {
test("Maksimal gyldig ArbeidsgiverSykmelding skal validere ok") {
val arbeidsgiverSykmelding: ArbeidsgiverSykmelding = objectMapper.readValue(
ArbeidsgiverSykmelding::class.java.getResourceAsStream("/gyldig-arbeidsgiversykmelding-maksimal.json")
.readBytes().toString(Charsets.UTF_8)
)

arbeidsgiverSykmelding.mottattTidspunkt.toLocalDate() shouldBeEqualTo LocalDate.of(2020, Month.JANUARY, 1)
arbeidsgiverSykmelding.id shouldBeEqualTo "b5e84795-43a8-4adb-ac1d-4b2e1e0c5fb7"
}
test("Minimal gyldig ArbeidsgiverSykmelding skal validere ok") {
val arbeidsgiverSykmelding: ArbeidsgiverSykmelding = objectMapper.readValue(
ArbeidsgiverSykmelding::class.java.getResourceAsStream("/gyldig-arbeidsgiversykmelding-minimal.json")
.readBytes().toString(Charsets.UTF_8)
)

arbeidsgiverSykmelding.mottattTidspunkt.toLocalDate() shouldBeEqualTo LocalDate.of(2020, Month.JANUARY, 1)
arbeidsgiverSykmelding.id shouldBeEqualTo "b5e84795-43a8-4adb-ac1d-4b2e1e0c5fb7"
arbeidsgiverSykmelding.arbeidsgiver shouldBeEqualTo ArbeidsgiverAGDTO(null, null)
arbeidsgiverSykmelding.prognose shouldBeEqualTo null
}

@Test
fun `Maksimal gyldig ArbeidsgiverSykmelding skal validere ok`() {
val arbeidsgiverSykmelding: ArbeidsgiverSykmelding = objectMapper.readValue(
ArbeidsgiverSykmelding::class.java.getResourceAsStream("/gyldig-arbeidsgiversykmelding-maksimal.json")
.readBytes().toString(Charsets.UTF_8)
)

arbeidsgiverSykmelding.mottattTidspunkt.toLocalDate() shouldBeEqualTo LocalDate.of(2020, Month.JANUARY, 1)
arbeidsgiverSykmelding.id shouldBeEqualTo "b5e84795-43a8-4adb-ac1d-4b2e1e0c5fb7"
}

@Test
fun `Minimal gyldig ArbeidsgiverSykmelding skal validere ok`() {
val arbeidsgiverSykmelding: ArbeidsgiverSykmelding = objectMapper.readValue(
ArbeidsgiverSykmelding::class.java.getResourceAsStream("/gyldig-arbeidsgiversykmelding-minimal.json")
.readBytes().toString(Charsets.UTF_8)
)

arbeidsgiverSykmelding.mottattTidspunkt.toLocalDate() shouldBeEqualTo LocalDate.of(2020, Month.JANUARY, 1)
arbeidsgiverSykmelding.id shouldBeEqualTo "b5e84795-43a8-4adb-ac1d-4b2e1e0c5fb7"
arbeidsgiverSykmelding.arbeidsgiver shouldBeEqualTo ArbeidsgiverAGDTO(null, null)
arbeidsgiverSykmelding.prognose shouldBeEqualTo null
}
})

}
Loading

0 comments on commit 8d91eb2

Please sign in to comment.