Skip to content

Commit

Permalink
F - Erstatter postconstruct med init for å få bort annotation(jakarta)
Browse files Browse the repository at this point in the history
  • Loading branch information
dskarpas committed Nov 3, 2023
1 parent a69181d commit a3756e2
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package no.nav.eessi.pensjon.personoppslag.pdl

import jakarta.annotation.PostConstruct
import no.nav.eessi.pensjon.metrics.MetricsHelper
import no.nav.eessi.pensjon.metrics.MetricsHelper.Metric
import no.nav.eessi.pensjon.metrics.MetricsHelper.Toggle.OFF
Expand Down Expand Up @@ -32,8 +31,7 @@ class PersonService(
private lateinit var sokPersonMetric: Metric
private lateinit var hentPersonUidMetric: Metric

@PostConstruct
fun initMetrics() {
init {
hentPersonMetric = metricsHelper.init("hentPerson", alert = OFF)
hentPersonnavnMetric = metricsHelper.init("hentPersonnavn", alert = OFF)
harAdressebeskyttelseMetric = metricsHelper.init("harAdressebeskyttelse", alert = OFF)
Expand All @@ -45,7 +43,6 @@ class PersonService(
hentPersonUidMetric = metricsHelper.init("hentPersonUid", alert = OFF)
}


fun <T : Ident> hentPersonUtenlandskIdent(ident: T): PersonUtenlandskIdent? {
return hentPersonMetric.measure {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ internal class PersonServiceIntegrationTest {
PersonClient(mockClient, "https://pdl-api.intern.dev.nav.no/graphql")
)

@BeforeEach
fun startup() {
service.initMetrics()
}

@Test
fun hentPerson_virkerSomForventet() {
val person = service.hentPerson(NorskIdent("25078521492"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ internal class PersonServiceTest {

private val service: PersonService = PersonService(client)

@BeforeAll
fun beforeAll() {
service.initMetrics()
}

private fun mockMeta(registrert: LocalDateTime = LocalDateTime.of(2010, 4,1, 10, 2, 14)): Metadata {
return Metadata(
listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ internal class PersonTest {
private val mockPersonService = PersonService(mockPersonClient)
private val mapper = jacksonObjectMapper().registerModule(JavaTimeModule())

@BeforeEach
fun setup() {
mockPersonService.initMetrics()
}

@AfterEach
fun after() {
clearAllMocks()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,11 @@ class PersonUtenlandskIdentTest {
private val mockPersonService = PersonService(mockPersonClient)
private val mapper = jacksonObjectMapper().registerModule(JavaTimeModule())

@BeforeEach
fun setup() {
mockPersonService.initMetrics()
}

@AfterEach
fun after() {
clearAllMocks()
}


@Test
fun testforPersonMedUid() {
val json = javaClass.getResource("/hentPersonUid.json").readText()
Expand Down

0 comments on commit a3756e2

Please sign in to comment.