From 029e76d1efa225ad277161b1ed19ab10adf21283 Mon Sep 17 00:00:00 2001 From: Magnus Evensberget Date: Fri, 4 Jun 2021 09:44:40 +0200 Subject: [PATCH] Adding test API --- .../config/ApplicationContext.kt | 8 +-- .../fo/veilarbvarsel/config/system/rest.kt | 3 +- .../nav/fo/veilarbvarsel/varsel/VarselApi.kt | 62 +++++++++---------- 3 files changed, 36 insertions(+), 37 deletions(-) diff --git a/src/main/kotlin/no/nav/fo/veilarbvarsel/config/ApplicationContext.kt b/src/main/kotlin/no/nav/fo/veilarbvarsel/config/ApplicationContext.kt index ec6ee95..31f616b 100644 --- a/src/main/kotlin/no/nav/fo/veilarbvarsel/config/ApplicationContext.kt +++ b/src/main/kotlin/no/nav/fo/veilarbvarsel/config/ApplicationContext.kt @@ -20,10 +20,10 @@ class ApplicationContext { // topic = environment.kafkaTopics.varselKvitteringOutgoing // ) -// val varselProducer = VarselEventProducer( -// env = environment.kafka, -// topic = environment.kafkaTopics.varselIncoming -// ) + val varselProducer = VarselEventProducer( + env = environment.kafka, + topic = environment.kafkaTopics.varselIncoming + ) // val beskjedProducer = BrukernotifikasjonBeskjedProducer( diff --git a/src/main/kotlin/no/nav/fo/veilarbvarsel/config/system/rest.kt b/src/main/kotlin/no/nav/fo/veilarbvarsel/config/system/rest.kt index cfccbb3..30780e4 100644 --- a/src/main/kotlin/no/nav/fo/veilarbvarsel/config/system/rest.kt +++ b/src/main/kotlin/no/nav/fo/veilarbvarsel/config/system/rest.kt @@ -34,7 +34,6 @@ fun Application.healthModule(appContext: ApplicationContext) { application.log.debug(it.buildText()) } healthApi(appContext.metrics) - //varselApi(appContext.varselProducer) - varselApi() + varselApi(appContext.varselProducer) } } diff --git a/src/main/kotlin/no/nav/fo/veilarbvarsel/varsel/VarselApi.kt b/src/main/kotlin/no/nav/fo/veilarbvarsel/varsel/VarselApi.kt index 7f86547..5b0b034 100644 --- a/src/main/kotlin/no/nav/fo/veilarbvarsel/varsel/VarselApi.kt +++ b/src/main/kotlin/no/nav/fo/veilarbvarsel/varsel/VarselApi.kt @@ -6,9 +6,11 @@ import io.ktor.request.* import io.ktor.response.* import io.ktor.routing.* import org.slf4j.LoggerFactory +import java.time.LocalDateTime +import java.util.* fun Route.varselApi( - //varselEventProducer: VarselEventProducer + varselEventProducer: VarselEventProducer ) { val logger = LoggerFactory.getLogger(javaClass) @@ -17,24 +19,23 @@ fun Route.varselApi( post { val varsel = call.receive() - println("Here 4") - -// varselEventProducer.send( -// CreateVarselVarselEvent( -// UUID.randomUUID(), -// LocalDateTime.now(), -// varsel.system, -// varsel.id, -// varsel.type, -// varsel.fodselsnummer, -// varsel.groupId, -// varsel.message, -// varsel.link.toString(), -// varsel.sikkerhetsnivaa, -// varsel.visibleUntil, -// varsel.externalVarsling -// ) -// ) + + varselEventProducer.send( + CreateVarselVarselEvent( + UUID.randomUUID(), + LocalDateTime.now(), + varsel.system, + varsel.id, + varsel.type, + varsel.fodselsnummer, + varsel.groupId, + varsel.message, + varsel.link.toString(), + varsel.sikkerhetsnivaa, + varsel.visibleUntil, + varsel.externalVarsling + ) + ) call.respond(HttpStatusCode.Created) @@ -42,18 +43,17 @@ fun Route.varselApi( post("/done") { val done = call.receive() - println("Here 5") - -// varselEventProducer.send( -// DoneVarselEvent( -// UUID.randomUUID(), -// LocalDateTime.now(), -// done.system, -// done.id, -// done.fodselsnummer, -// done.groupId -// ) -// ) + + varselEventProducer.send( + DoneVarselEvent( + UUID.randomUUID(), + LocalDateTime.now(), + done.system, + done.id, + done.fodselsnummer, + done.groupId + ) + ) call.respond(HttpStatusCode.Created) }