From 251e8547c57d73a4dbab527974bf5b2f084e2180 Mon Sep 17 00:00:00 2001 From: Jon Ole Hagemo Date: Thu, 4 Jan 2024 09:49:41 +0100 Subject: [PATCH 1/4] Update Individ01a.kt Set future date further into the future --- .../kostra/validation/rule/barnevern/individrule/Individ01a.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kontroller/src/main/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/Individ01a.kt b/kontroller/src/main/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/Individ01a.kt index 6de65efb2..7a7a2ab1a 100644 --- a/kontroller/src/main/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/Individ01a.kt +++ b/kontroller/src/main/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/Individ01a.kt @@ -144,7 +144,7 @@ class Individ01a : AbstractRule( 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.plusIfNotNull(other: ValidationReportEntry?) = if (other != null) this.plus(other) else this From 76fefdcb194881c9bf83d4bc0a80d7688651331d Mon Sep 17 00:00:00 2001 From: Jon Ole Hagemo Date: Thu, 4 Jan 2024 12:56:48 +0100 Subject: [PATCH 2/4] Barnevern: Changes to Individ Kontroll 07 --- .../rule/barnevern/SharedValidationConstants.kt | 2 +- .../rule/barnevern/individrule/Individ07.kt | 6 +++--- .../rule/barnevern/individrule/Individ07Test.kt | 17 +++++++++-------- .../individrule/IndividRuleTestData.kt | 6 ++---- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/kontroller/src/main/kotlin/no/ssb/kostra/validation/rule/barnevern/SharedValidationConstants.kt b/kontroller/src/main/kotlin/no/ssb/kostra/validation/rule/barnevern/SharedValidationConstants.kt index 6ce1a1a27..c059300ee 100644 --- a/kontroller/src/main/kotlin/no/ssb/kostra/validation/rule/barnevern/SharedValidationConstants.kt +++ b/kontroller/src/main/kotlin/no/ssb/kostra/validation/rule/barnevern/SharedValidationConstants.kt @@ -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" diff --git a/kontroller/src/main/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/Individ07.kt b/kontroller/src/main/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/Individ07.kt index 427d5dcad..26d8bd959 100644 --- a/kontroller/src/main/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/Individ07.kt +++ b/kontroller/src/main/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/Individ07.kt @@ -6,17 +6,17 @@ 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( ruleName = IndividRuleId.INDIVID_07.title, severity = Severity.ERROR ) { override fun validate(context: KostraIndividType, arguments: KotlinArguments) = - context.fodselsnummer + context.also { println(arguments) }.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" diff --git a/kontroller/src/test/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/Individ07Test.kt b/kontroller/src/test/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/Individ07Test.kt index ffa71688a..70c1942d8 100644 --- a/kontroller/src/test/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/Individ07Test.kt +++ b/kontroller/src/test/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/Individ07Test.kt @@ -1,6 +1,7 @@ package no.ssb.kostra.validation.rule.barnevern.individrule import io.kotest.core.spec.style.BehaviorSpec +import no.ssb.kostra.testutil.RandomUtils import no.ssb.kostra.testutil.RandomUtils.generateRandomSSN import no.ssb.kostra.validation.report.Severity import no.ssb.kostra.validation.rule.ForAllRowItem @@ -26,19 +27,19 @@ class Individ07Test : BehaviorSpec({ ForAllRowItem( "individ with fodselsnummer, age below 25", individInTest.copy( - fodselsnummer = generateRandomSSN( - LocalDate.now().minusYears(1), - LocalDate.now() - ) + fodselsnummer = RandomUtils.generateRandomSsn(24, LocalDate.now().year) + ) + ), + ForAllRowItem( + "individ with fodselsnummer, age is 25", + individInTest.copy( + fodselsnummer = RandomUtils.generateRandomSsn(25, LocalDate.now().year) ) ), 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, LocalDate.now().year) ), expectedErrorMessage = "Individet er 25 år og skal avsluttes som klient" ) diff --git a/kontroller/src/test/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/IndividRuleTestData.kt b/kontroller/src/test/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/IndividRuleTestData.kt index dfbed7dde..ddfad908b 100644 --- a/kontroller/src/test/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/IndividRuleTestData.kt +++ b/kontroller/src/test/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/IndividRuleTestData.kt @@ -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 @@ -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", From 9eb8df3ee49b44ae19353f67dcbb43edc086998e Mon Sep 17 00:00:00 2001 From: Jon Ole Hagemo Date: Thu, 4 Jan 2024 13:19:38 +0100 Subject: [PATCH 3/4] Barnevern: fixed Individ Kontroll 07 --- .../validation/rule/barnevern/individrule/Individ07.kt | 2 +- .../rule/barnevern/individrule/Individ07Test.kt | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/kontroller/src/main/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/Individ07.kt b/kontroller/src/main/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/Individ07.kt index 26d8bd959..fb2075190 100644 --- a/kontroller/src/main/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/Individ07.kt +++ b/kontroller/src/main/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/Individ07.kt @@ -16,7 +16,7 @@ class Individ07 : AbstractRule( context.also { println(arguments) }.fodselsnummer ?.ageInYears(arguments.aargang.toInt()) ?.let { ageInYears -> - if (ageInYears >= AGE_TWENTY_FIVE) { + if (ageInYears > AGE_TWENTY_FIVE) { createSingleReportEntryList( contextId = context.id, messageText = "Individet er $ageInYears år og skal avsluttes som klient" diff --git a/kontroller/src/test/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/Individ07Test.kt b/kontroller/src/test/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/Individ07Test.kt index 70c1942d8..d349bc965 100644 --- a/kontroller/src/test/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/Individ07Test.kt +++ b/kontroller/src/test/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/Individ07Test.kt @@ -2,12 +2,10 @@ package no.ssb.kostra.validation.rule.barnevern.individrule import io.kotest.core.spec.style.BehaviorSpec import no.ssb.kostra.testutil.RandomUtils -import no.ssb.kostra.testutil.RandomUtils.generateRandomSSN 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({ @@ -27,21 +25,21 @@ class Individ07Test : BehaviorSpec({ ForAllRowItem( "individ with fodselsnummer, age below 25", individInTest.copy( - fodselsnummer = RandomUtils.generateRandomSsn(24, LocalDate.now().year) + fodselsnummer = RandomUtils.generateRandomSsn(24, Year.now().value - 1) ) ), ForAllRowItem( "individ with fodselsnummer, age is 25", individInTest.copy( - fodselsnummer = RandomUtils.generateRandomSsn(25, LocalDate.now().year) + fodselsnummer = RandomUtils.generateRandomSsn(25, Year.now().value - 1) ) ), ForAllRowItem( "individ age above 25", individInTest.copy( - fodselsnummer = RandomUtils.generateRandomSsn(26, LocalDate.now().year) + 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" ) ) ) From 9bf34b8d868c9f8e83daa4123eea36be05d3ac68 Mon Sep 17 00:00:00 2001 From: Jon Ole Hagemo Date: Thu, 4 Jan 2024 13:47:31 +0100 Subject: [PATCH 4/4] Update Individ07.kt --- .../kostra/validation/rule/barnevern/individrule/Individ07.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kontroller/src/main/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/Individ07.kt b/kontroller/src/main/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/Individ07.kt index fb2075190..00045b8a5 100644 --- a/kontroller/src/main/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/Individ07.kt +++ b/kontroller/src/main/kotlin/no/ssb/kostra/validation/rule/barnevern/individrule/Individ07.kt @@ -13,7 +13,7 @@ class Individ07 : AbstractRule( severity = Severity.ERROR ) { override fun validate(context: KostraIndividType, arguments: KotlinArguments) = - context.also { println(arguments) }.fodselsnummer + context.fodselsnummer ?.ageInYears(arguments.aargang.toInt()) ?.let { ageInYears -> if (ageInYears > AGE_TWENTY_FIVE) {