Skip to content

Commit

Permalink
Refactoring, resctructiring, remodeling
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-meidell committed Sep 4, 2023
1 parent ff69b2b commit 338f720
Show file tree
Hide file tree
Showing 41 changed files with 1,817 additions and 1,027 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ dependencies {
testImplementation("no.nav.security:token-validation-spring-test:$navTokenSupportVersion")
testImplementation("org.testcontainers:postgresql:$testcontainersVersion")
testImplementation("org.springframework.kafka:spring-kafka-test:$springKafkaTestVersion")

testImplementation("org.mockito.kotlin:mockito-kotlin:5.1.0")
}

tasks.test {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ object Mdc {
return MDC.putCloseable(InnlesingId.identifier, innlesingId.toString()).use { block(innlesingId) }
}

fun getCorrelationId(): String {
return MDC.get(CorrelationId.identifier).toString()
fun getCorrelationId(): CorrelationId {
return CorrelationId.fromString(MDC.get(CorrelationId.identifier).toString())
}

fun getInnlesingId(): String? {
return MDC.get(InnlesingId.identifier).toString()
fun getInnlesingId(): InnlesingId {
return InnlesingId.fromString(MDC.get(InnlesingId.identifier).toString())
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.domain

import no.nav.pensjon.opptjening.omsorgsopptjening.felles.InnlesingId
import java.time.Instant

sealed class BarnetrygdInnlesing {
abstract val id: InnlesingId
abstract val år: Int
abstract val forespurtTidspunkt: Instant
open val startTidspunkt: Instant? = null
open val ferdigTidspunkt: Instant? = null

open fun startet(): Startet = throw UgyldigTilstand(
fra = this::class.java.simpleName,
til = Startet::class.java.simpleName
)

open fun mottaData(): Startet = throw UgyldigTilstand(
fra = this::class.java.simpleName,
til = Startet::class.java.simpleName
)

open fun ferdig(): Ferdig = throw UgyldigTilstand(
fra = this::class.java.simpleName,
til = Ferdig::class.java.simpleName
)

data class Bestilt(
override val id: InnlesingId,
override val år: Int,
override val forespurtTidspunkt: Instant
) : BarnetrygdInnlesing() {
override fun startet(): Startet {
return Startet(id, år, forespurtTidspunkt, Instant.now())
}
}

data class Startet(
override val id: InnlesingId,
override val år: Int,
override val forespurtTidspunkt: Instant,
override val startTidspunkt: Instant,
) : BarnetrygdInnlesing() {

override fun mottaData(): Startet {
return this
}

override fun ferdig(): Ferdig {
return Ferdig(id, år, forespurtTidspunkt, startTidspunkt, Instant.now())
}
}

data class Ferdig(
override val id: InnlesingId,
override val år: Int,
override val forespurtTidspunkt: Instant,
override val startTidspunkt: Instant,
override val ferdigTidspunkt: Instant
) : BarnetrygdInnlesing()

companion object Factory {
fun of(
id: InnlesingId,
år: Int,
forespurtTidspunkt: Instant,
startTidspunkt: Instant?,
ferdigTidspunkt: Instant?
): BarnetrygdInnlesing {
return if (ferdigTidspunkt != null && startTidspunkt != null) {
Ferdig(id, år, forespurtTidspunkt, startTidspunkt, ferdigTidspunkt)
} else if (ferdigTidspunkt == null && startTidspunkt != null) {
Startet(id, år, forespurtTidspunkt, startTidspunkt)
} else {
Bestilt(id, år, forespurtTidspunkt)
}
}
}

data class UgyldigTilstand(
val fra: String,
val til: String
) : RuntimeException()
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd
package no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.domain

import com.fasterxml.jackson.annotation.JsonTypeInfo
import com.fasterxml.jackson.annotation.JsonTypeName
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.domain

import no.nav.pensjon.opptjening.omsorgsopptjening.felles.CorrelationId
import no.nav.pensjon.opptjening.omsorgsopptjening.felles.InnlesingId

sealed class BarnetrygdmottakerMelding {
abstract val correlationId: CorrelationId
abstract val innlesingId: InnlesingId

data class Start(
override val correlationId: CorrelationId,
override val innlesingId: InnlesingId
) : BarnetrygdmottakerMelding()

data class Data(
val personIdent: String,
override val correlationId: CorrelationId,
override val innlesingId: InnlesingId
) : BarnetrygdmottakerMelding()

data class Slutt(
override val correlationId: CorrelationId,
override val innlesingId: InnlesingId
) : BarnetrygdmottakerMelding()
}
Loading

0 comments on commit 338f720

Please sign in to comment.