Skip to content

Commit

Permalink
Merge pull request #406 from statisticsnorway/Barnevern_Bugfix
Browse files Browse the repository at this point in the history
Barnevern: Update Individ Kontroll 07
  • Loading branch information
jonolehagemo authored Jan 4, 2024
2 parents 7d8b09c + 9bf34b8 commit b98e969
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ object SharedValidationConstants {
const val AGE_SIX = 6
const val AGE_TEN = 10
const val AGE_SEVENTEEN = 17
const val AGE_TWENTY_FOUR = 24
const val AGE_TWENTY_FIVE = 25

const val BVL1992 = "BVL"
const val BVL2021 = "BVL2021"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class Individ01a : AbstractRule<KostraIndividType>(

companion object {
val minDate: LocalDate = LocalDate.of(1998, 1, 1)
val maxDate: LocalDate = LocalDate.of(2029, 12, 31)
val maxDate: LocalDate = LocalDate.of(2049, 12, 31)

fun List<ValidationReportEntry>.plusIfNotNull(other: ValidationReportEntry?) =
if (other != null) this.plus(other) else this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import no.ssb.kostra.program.extension.ageInYears
import no.ssb.kostra.validation.report.Severity
import no.ssb.kostra.validation.rule.AbstractRule
import no.ssb.kostra.validation.rule.barnevern.IndividRuleId
import no.ssb.kostra.validation.rule.barnevern.SharedValidationConstants.AGE_TWENTY_FOUR
import no.ssb.kostra.validation.rule.barnevern.SharedValidationConstants.AGE_TWENTY_FIVE

class Individ07 : AbstractRule<KostraIndividType>(
ruleName = IndividRuleId.INDIVID_07.title,
Expand All @@ -16,7 +16,7 @@ class Individ07 : AbstractRule<KostraIndividType>(
context.fodselsnummer
?.ageInYears(arguments.aargang.toInt())
?.let { ageInYears ->
if (ageInYears > AGE_TWENTY_FOUR) {
if (ageInYears > AGE_TWENTY_FIVE) {
createSingleReportEntryList(
contextId = context.id,
messageText = "Individet er $ageInYears år og skal avsluttes som klient"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package no.ssb.kostra.validation.rule.barnevern.individrule

import io.kotest.core.spec.style.BehaviorSpec
import no.ssb.kostra.testutil.RandomUtils.generateRandomSSN
import no.ssb.kostra.testutil.RandomUtils
import no.ssb.kostra.validation.report.Severity
import no.ssb.kostra.validation.rule.ForAllRowItem
import no.ssb.kostra.validation.rule.KostraTestFactory.validationRuleWithArgsTest
import no.ssb.kostra.validation.rule.barnevern.individrule.IndividRuleTestData.individInTest
import java.time.LocalDate
import java.time.Year

class Individ07Test : BehaviorSpec({
Expand All @@ -26,21 +25,21 @@ class Individ07Test : BehaviorSpec({
ForAllRowItem(
"individ with fodselsnummer, age below 25",
individInTest.copy(
fodselsnummer = generateRandomSSN(
LocalDate.now().minusYears(1),
LocalDate.now()
)
fodselsnummer = RandomUtils.generateRandomSsn(24, Year.now().value - 1)
)
),
ForAllRowItem(
"individ with fodselsnummer, age is 25",
individInTest.copy(
fodselsnummer = RandomUtils.generateRandomSsn(25, Year.now().value - 1)
)
),
ForAllRowItem(
"individ age above 25",
individInTest.copy(
fodselsnummer = generateRandomSSN(
Year.now().atDay(1).minusYears(26),
Year.now().atDay(1).minusYears(25)
)
fodselsnummer = RandomUtils.generateRandomSsn(26, Year.now().value - 1)
),
expectedErrorMessage = "Individet er 25 år og skal avsluttes som klient"
expectedErrorMessage = "Individet er 26 år og skal avsluttes som klient"
)
)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package no.ssb.kostra.validation.rule.barnevern.individrule

import no.ssb.kostra.barnevern.xsd.*
import no.ssb.kostra.testutil.RandomUtils
import no.ssb.kostra.testutil.RandomUtils.generateRandomSSN
import no.ssb.kostra.validation.rule.barnevern.SharedValidationConstants.BVL1992
import no.ssb.kostra.validation.rule.barnevern.SharedValidationConstants.KAPITTEL_4
Expand Down Expand Up @@ -69,10 +70,7 @@ object IndividRuleTestData {
startDato = dateInTest,
sluttDato = null,
avslutta3112 = KOSTRA_IS_CLOSED_FALSE,
fodselsnummer = generateRandomSSN(
LocalDate.now().minusYears(1),
LocalDate.now()
),
fodselsnummer = RandomUtils.generateRandomSsn(1, LocalDate.now().year),
duFnummer = null,
saksbehandler = "~saksbehandler~",
bydelsnummer = "11",
Expand Down

0 comments on commit b98e969

Please sign in to comment.