-
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.
Håndterer Person lik null, lagt til en test for versjon 2
- Loading branch information
1 parent
5f7847b
commit 277f6a4
Showing
6 changed files
with
239 additions
and
57 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
83 changes: 83 additions & 0 deletions
83
...ng-pdl/src/test/kotlin/no/nav/paw/arbeidssoekerregisteret/utgang/pdl/ApplicationTestV2.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,83 @@ | ||
package no.nav.paw.arbeidssoekerregisteret.utgang.pdl | ||
|
||
import io.kotest.core.spec.style.FreeSpec | ||
import io.kotest.matchers.shouldBe | ||
import no.nav.paw.arbeidssokerregisteret.api.v1.Periode | ||
import no.nav.paw.arbeidssokerregisteret.intern.v1.Startet | ||
import no.nav.paw.arbeidssokerregisteret.intern.v1.vo.Bruker as InternBruker | ||
import no.nav.paw.arbeidssokerregisteret.intern.v1.vo.BrukerType as InternBrukerType | ||
import no.nav.paw.arbeidssokerregisteret.intern.v1.vo.Metadata as InternMetadata | ||
import no.nav.paw.arbeidssokerregisteret.api.v1.Metadata | ||
import no.nav.paw.arbeidssokerregisteret.api.v1.Bruker | ||
import no.nav.paw.arbeidssokerregisteret.api.v1.BrukerType | ||
import org.slf4j.LoggerFactory | ||
import java.time.Duration | ||
import java.time.Instant | ||
import java.util.* | ||
import ch.qos.logback.classic.Logger as LogbackLogger | ||
|
||
class ApplicationTestV2 : FreeSpec({ | ||
val periodeId = UUID.randomUUID() | ||
|
||
"Sender ikke AvsluttetHendelse og logger error for PersonIkkeFunnet" { | ||
val logger = LoggerFactory.getLogger("scheduleAvsluttPerioder") as LogbackLogger | ||
val testAppender = TestAppender() | ||
logger.addAppender(testAppender) | ||
testAppender.start() | ||
with( | ||
testScopeV2( | ||
generatePdlHentPersonMockResponse( | ||
"12345678901", | ||
null, | ||
"PersonIkkeFunnet" | ||
) | ||
) | ||
) { | ||
verifyEmptyTopic(hendelseloggOutputTopic) | ||
hendelseloggInputTopic.pipeInput(1234L, | ||
Startet( | ||
periodeId, | ||
1234L, | ||
"12345678901", | ||
InternMetadata( | ||
Instant.now(), | ||
InternBruker( | ||
InternBrukerType.SLUTTBRUKER, | ||
"12345678901" | ||
), | ||
"", | ||
"" | ||
), | ||
emptySet() | ||
) | ||
) | ||
periodeTopic.pipeInput( | ||
1234L, | ||
Periode( | ||
periodeId, | ||
"12345678901", | ||
Metadata( | ||
Instant.now(), | ||
Bruker( | ||
BrukerType.SLUTTBRUKER, | ||
"12345678901" | ||
), | ||
"", | ||
"", | ||
null | ||
), | ||
null | ||
) | ||
) | ||
|
||
topologyTestDriver.advanceWallClockTime(Duration.ofDays(2)) | ||
hendelseloggOutputTopic.isEmpty shouldBe true | ||
val logEvents = testAppender.events | ||
logEvents.any { | ||
it.level == ch.qos.logback.classic.Level.ERROR | ||
&& it.message.contains("Versjon 2: Person er null") | ||
} shouldBe true | ||
} | ||
testAppender.stop() | ||
} | ||
}) |
12 changes: 12 additions & 0 deletions
12
.../utgang-pdl/src/test/kotlin/no/nav/paw/arbeidssoekerregisteret/utgang/pdl/TestAppender.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,12 @@ | ||
package no.nav.paw.arbeidssoekerregisteret.utgang.pdl | ||
|
||
import ch.qos.logback.classic.spi.ILoggingEvent | ||
import ch.qos.logback.core.AppenderBase | ||
|
||
class TestAppender : AppenderBase<ILoggingEvent>() { | ||
val events = mutableListOf<ILoggingEvent>() | ||
|
||
override fun append(eventObject: ILoggingEvent) { | ||
events.add(eventObject) | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
apps/utgang-pdl/src/test/kotlin/no/nav/paw/arbeidssoekerregisteret/utgang/pdl/TestData.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,70 @@ | ||
package no.nav.paw.arbeidssoekerregisteret.utgang.pdl | ||
|
||
import no.nav.paw.pdl.graphql.generated.enums.Oppholdstillatelse | ||
import no.nav.paw.pdl.graphql.generated.hentpersonbolk.Bostedsadresse | ||
import no.nav.paw.pdl.graphql.generated.hentpersonbolk.Foedsel | ||
import no.nav.paw.pdl.graphql.generated.hentpersonbolk.Folkeregisterpersonstatus | ||
import no.nav.paw.pdl.graphql.generated.hentpersonbolk.HentPersonBolkResult | ||
import no.nav.paw.pdl.graphql.generated.hentpersonbolk.Metadata | ||
import no.nav.paw.pdl.graphql.generated.hentpersonbolk.Opphold | ||
import no.nav.paw.pdl.graphql.generated.hentpersonbolk.Person | ||
import no.nav.paw.pdl.graphql.generated.hentpersonbolk.Statsborgerskap | ||
|
||
fun generatePdlPerson( | ||
foedsel: Foedsel? = null, | ||
statsborgerskap: Statsborgerskap? = null, | ||
opphold: Opphold? = null, | ||
folkeregisterpersonstatus: Folkeregisterpersonstatus? = null, | ||
bostedsadresse: Bostedsadresse? = null, | ||
): Person = | ||
Person( | ||
foedsel = listOf( | ||
foedsel ?: Foedsel( | ||
foedselsdato = "1990-01-01", | ||
foedselsaar = 1990 | ||
) | ||
), | ||
statsborgerskap = listOf( | ||
statsborgerskap ?: Statsborgerskap( | ||
land = "NOR", | ||
metadata = Metadata( | ||
endringer = emptyList() | ||
) | ||
) | ||
), | ||
opphold = listOf( | ||
opphold ?: Opphold( | ||
oppholdFra = "2020-01-01", | ||
oppholdTil = "2021-01-01", | ||
type = Oppholdstillatelse.PERMANENT, | ||
metadata = Metadata( | ||
endringer = emptyList() | ||
) | ||
) | ||
), | ||
folkeregisterpersonstatus = listOf( | ||
folkeregisterpersonstatus ?: Folkeregisterpersonstatus( | ||
forenkletStatus = "bosattEtterFolkeregisterloven", | ||
metadata = Metadata( | ||
endringer = emptyList() | ||
) | ||
) | ||
), | ||
bostedsadresse = listOf( | ||
bostedsadresse ?: Bostedsadresse( | ||
angittFlyttedato = null, | ||
) | ||
), | ||
innflyttingTilNorge = emptyList(), | ||
utflyttingFraNorge = emptyList(), | ||
) | ||
|
||
|
||
fun generatePdlHentPersonMockResponse(ident: String, person: Person?, status: String): List<HentPersonBolkResult> = | ||
listOf( | ||
HentPersonBolkResult( | ||
ident, | ||
person, | ||
status | ||
) | ||
) |
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