-
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.
Oppdaterte regelsett for inngang slik at flere regler kombineres i en…
… response
- Loading branch information
Showing
7 changed files
with
164 additions
and
11 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
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
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
141 changes: 141 additions & 0 deletions
141
...ker-regler/src/test/kotlin/no/nav/paw/arbeidssokerregisteret/application/RegelEvalTest.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,141 @@ | ||
package no.nav.paw.arbeidssokerregisteret.application | ||
|
||
import arrow.core.Either | ||
import arrow.core.NonEmptyList | ||
import io.kotest.core.spec.style.FreeSpec | ||
import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder | ||
import io.kotest.matchers.should | ||
import io.kotest.matchers.types.shouldBeInstanceOf | ||
import no.nav.paw.arbeidssokerregisteret.application.opplysninger.DomeneOpplysning | ||
|
||
typealias Avvist = Either.Left<NonEmptyList<Problem>> | ||
typealias Godkjent = Either.Right<GrunnlagForGodkjenning> | ||
|
||
class RegelEvalTest : FreeSpec({ | ||
"Verifiser regel evaluering" - { | ||
"Person under 18 år" - { | ||
"og forhåndsgodkjent" - { | ||
"skal avvises når" - { | ||
"er doed" { | ||
InngangsRegler.evaluer( | ||
listOf( | ||
DomeneOpplysning.ErDoed, | ||
DomeneOpplysning.ErForhaandsgodkjent, | ||
DomeneOpplysning.ErUnder18Aar | ||
) | ||
) should { result -> | ||
result.shouldBeInstanceOf<Avvist>() | ||
result.value.map { problem -> problem.regel.id } shouldContainExactlyInAnyOrder listOf( | ||
Doed, | ||
Under18Aar, | ||
IkkeBosattINorgeIHenholdTilFolkeregisterloven | ||
) | ||
} | ||
} | ||
"er savnet" { | ||
InngangsRegler.evaluer( | ||
listOf( | ||
DomeneOpplysning.ErSavnet, | ||
DomeneOpplysning.ErForhaandsgodkjent, | ||
DomeneOpplysning.ErUnder18Aar | ||
) | ||
) should { result -> | ||
result.shouldBeInstanceOf<Avvist>() | ||
result.value.map { problem -> problem.regel.id } shouldContainExactlyInAnyOrder listOf( | ||
Savnet, | ||
Under18Aar, | ||
IkkeBosattINorgeIHenholdTilFolkeregisterloven | ||
) | ||
} | ||
} | ||
"ikke funnet i PDL" { | ||
InngangsRegler.evaluer( | ||
listOf( | ||
DomeneOpplysning.PersonIkkeFunnet | ||
) | ||
) should { result -> | ||
result.shouldBeInstanceOf<Avvist>() | ||
result.value.map { problem -> problem.regel.id } shouldContainExactlyInAnyOrder listOf( | ||
IkkeFunnet | ||
) | ||
} | ||
} | ||
} | ||
"skal godkjennes når" - { | ||
"ikke bosatt" { | ||
InngangsRegler.evaluer( | ||
listOf( | ||
DomeneOpplysning.IkkeBosatt, | ||
DomeneOpplysning.ErUnder18Aar, | ||
DomeneOpplysning.ErForhaandsgodkjent | ||
) | ||
) should { result -> | ||
result.shouldBeInstanceOf<Godkjent>() | ||
} | ||
} | ||
"ingen informasjon om bosatt" { | ||
InngangsRegler.evaluer( | ||
listOf( | ||
DomeneOpplysning.ErUnder18Aar, | ||
DomeneOpplysning.ErForhaandsgodkjent | ||
) | ||
) should { result -> | ||
result.shouldBeInstanceOf<Godkjent>() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
"Person over 18 år" - { | ||
"skal avvises når" - { | ||
"Norsk statsborger, ikke bosatt" { | ||
InngangsRegler.evaluer( | ||
listOf( | ||
DomeneOpplysning.ErNorskStatsborger, | ||
DomeneOpplysning.ErEuEoesStatsborger, | ||
DomeneOpplysning.ErOver18Aar, | ||
DomeneOpplysning.IkkeBosatt | ||
) | ||
) should { result -> | ||
result.shouldBeInstanceOf<Avvist>() | ||
result.value.map { it.regel.id } shouldContainExactlyInAnyOrder listOf( | ||
IkkeBosattINorgeIHenholdTilFolkeregisterloven | ||
) | ||
} | ||
} | ||
"3. lands borger, ikke bosatt" { | ||
InngangsRegler.evaluer( | ||
listOf( | ||
DomeneOpplysning.ErOver18Aar, | ||
DomeneOpplysning.IkkeBosatt | ||
) | ||
) should { result -> | ||
result.shouldBeInstanceOf<Avvist>() | ||
result.value.map { it.regel.id } shouldContainExactlyInAnyOrder listOf( | ||
IkkeBosattINorgeIHenholdTilFolkeregisterloven | ||
) | ||
} | ||
} | ||
} | ||
"skal godkjennes når" - { | ||
"bosatt" { | ||
InngangsRegler.evaluer( | ||
listOf( | ||
DomeneOpplysning.ErOver18Aar, | ||
DomeneOpplysning.BosattEtterFregLoven | ||
) | ||
).shouldBeInstanceOf<Godkjent>() | ||
} | ||
"forhåndsgodkjent" { | ||
InngangsRegler.evaluer( | ||
listOf( | ||
DomeneOpplysning.ErOver18Aar, | ||
DomeneOpplysning.IkkeBosatt, | ||
DomeneOpplysning.ErForhaandsgodkjent | ||
) | ||
).shouldBeInstanceOf<Godkjent>() | ||
} | ||
} | ||
} | ||
} | ||
}) |