-
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.
Legg til metrikk for feil status (#727)
* Legg til metrikk for feil status * Fjern uriktig kommentar * Ikke gjenbruk IdMapping, bruk ny klasse
- Loading branch information
Showing
7 changed files
with
185 additions
and
27 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
14 changes: 11 additions & 3 deletions
14
src/main/kotlin/no/nav/veilarbaktivitet/aktivitetskort/idmapping/IdMapping.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 |
---|---|---|
@@ -1,10 +1,18 @@ | ||
package no.nav.veilarbaktivitet.aktivitetskort.idmapping | ||
|
||
import no.nav.veilarbaktivitet.aktivitet.domain.AktivitetStatus | ||
import no.nav.veilarbaktivitet.arena.model.ArenaId | ||
import java.util.* | ||
|
||
data class IdMapping( | ||
public val arenaId: ArenaId, | ||
public val aktivitetId: Long, | ||
public val funksjonellId: UUID | ||
val arenaId: ArenaId, | ||
val aktivitetId: Long, | ||
val funksjonellId: UUID, | ||
) | ||
|
||
data class IdMappingWithAktivitetStatus ( | ||
val arenaId: ArenaId, | ||
val aktivitetId: Long, | ||
val funksjonellId: UUID, | ||
val status: AktivitetStatus | ||
) |
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
109 changes: 109 additions & 0 deletions
109
src/test/kotlin/no/nav/veilarbaktivitet/aktivitetskort/MigreringServiceTest.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,109 @@ | ||
package no.nav.veilarbaktivitet.aktivitetskort | ||
|
||
import io.getunleash.Unleash | ||
import no.nav.veilarbaktivitet.aktivitet.domain.AktivitetStatus | ||
import no.nav.veilarbaktivitet.aktivitetskort.idmapping.IdMappingDAO | ||
import no.nav.veilarbaktivitet.aktivitetskort.idmapping.IdMappingWithAktivitetStatus | ||
import no.nav.veilarbaktivitet.arena.model.ArenaAktivitetDTO | ||
import no.nav.veilarbaktivitet.arena.model.ArenaAktivitetTypeDTO | ||
import no.nav.veilarbaktivitet.arena.model.ArenaId | ||
import org.junit.jupiter.api.Test | ||
import org.mockito.Mockito.mock | ||
import org.mockito.kotlin.verify | ||
import java.util.* | ||
|
||
class MigreringServiceTest { | ||
|
||
val testAktiviteter = listOf( | ||
ArenaAktivitetDTO.builder() | ||
.type(ArenaAktivitetTypeDTO.TILTAKSAKTIVITET) | ||
.id("ARENATA101") | ||
.status(AktivitetStatus.PLANLAGT).build(), | ||
ArenaAktivitetDTO.builder() | ||
.type(ArenaAktivitetTypeDTO.TILTAKSAKTIVITET) | ||
.id("ARENATA102") | ||
.status(AktivitetStatus.GJENNOMFORES).build(), | ||
ArenaAktivitetDTO.builder() | ||
.type(ArenaAktivitetTypeDTO.TILTAKSAKTIVITET) | ||
.id("ARENATA103") | ||
.status(AktivitetStatus.FULLFORT).build() | ||
) | ||
|
||
@Test | ||
fun `skal telle feil status og riktig status`() { | ||
val metrikker = mock(AktivitetskortMetrikker::class.java) | ||
val migreringService = MigreringService( | ||
unleash = mock(Unleash::class.java), | ||
idMappingDAO = mock(IdMappingDAO::class.java), | ||
aktivitetskortMetrikker = metrikker | ||
) | ||
migreringService.countArenaAktiviteter( | ||
foer = testAktiviteter, | ||
idMappings = mapOf( | ||
ArenaId("ARENATA101") to IdMappingWithAktivitetStatus( | ||
ArenaId("ARENATA101"), | ||
1, | ||
UUID.randomUUID(), | ||
AktivitetStatus.PLANLAGT | ||
), | ||
ArenaId("ARENATA102") to IdMappingWithAktivitetStatus( | ||
ArenaId("ARENATA102"), | ||
2, | ||
UUID.randomUUID(), | ||
AktivitetStatus.PLANLAGT // Feil status | ||
) | ||
) | ||
) | ||
verify(metrikker).countMigrerteArenaAktiviteter(ArenaAktivitetTypeDTO.TILTAKSAKTIVITET, 3, 1,1,1) | ||
} | ||
|
||
@Test | ||
fun `skal telle riktig når ingen er migrert`() { | ||
val metrikker = mock(AktivitetskortMetrikker::class.java) | ||
val migreringService = MigreringService( | ||
unleash = mock(Unleash::class.java), | ||
idMappingDAO = mock(IdMappingDAO::class.java), | ||
aktivitetskortMetrikker = metrikker | ||
) | ||
migreringService.countArenaAktiviteter( | ||
foer = testAktiviteter, | ||
idMappings = mapOf() | ||
) | ||
verify(metrikker).countMigrerteArenaAktiviteter(ArenaAktivitetTypeDTO.TILTAKSAKTIVITET, 3, 0,0,3) | ||
} | ||
|
||
@Test | ||
fun `skal telle riktig når alle er feil status`() { | ||
val metrikker = mock(AktivitetskortMetrikker::class.java) | ||
val migreringService = MigreringService( | ||
unleash = mock(Unleash::class.java), | ||
idMappingDAO = mock(IdMappingDAO::class.java), | ||
aktivitetskortMetrikker = metrikker | ||
) | ||
migreringService.countArenaAktiviteter( | ||
foer = testAktiviteter, | ||
idMappings = mapOf( | ||
ArenaId("ARENATA101") to IdMappingWithAktivitetStatus( | ||
ArenaId("ARENATA101"), | ||
1, | ||
UUID.randomUUID(), | ||
AktivitetStatus.FULLFORT | ||
), | ||
ArenaId("ARENATA102") to IdMappingWithAktivitetStatus( | ||
ArenaId("ARENATA102"), | ||
2, | ||
UUID.randomUUID(), | ||
AktivitetStatus.PLANLAGT // Feil status | ||
), | ||
ArenaId("ARENATA103") to IdMappingWithAktivitetStatus( | ||
ArenaId("ARENATA103"), | ||
3, | ||
UUID.randomUUID(), | ||
AktivitetStatus.PLANLAGT // Feil status | ||
) | ||
) | ||
) | ||
verify(metrikker).countMigrerteArenaAktiviteter(ArenaAktivitetTypeDTO.TILTAKSAKTIVITET, 3, 0,3,0) | ||
} | ||
} | ||
|