1
1
import api.afp.VedtakRequest
2
2
import api.afp.VedtakRequestMedSaksRef
3
+ import api.afp.VedtakResponse
3
4
import api.api
4
5
import api.api_intern.IApiInternClient
5
6
import api.sporingslogg.JacksonSerializer
@@ -17,20 +18,20 @@ import io.ktor.client.statement.*
17
18
import io.ktor.http.*
18
19
import io.ktor.serialization.jackson.*
19
20
import io.ktor.server.testing.*
20
- import io.ktor.websocket.Serializer
21
21
import no.nav.aap.api.intern.Medium
22
22
import no.nav.aap.arenaoppslag.kontrakt.ekstern.EksternVedtakRequest
23
23
import no.nav.security.mock.oauth2.MockOAuth2Server
24
24
import org.apache.kafka.clients.producer.MockProducer
25
25
import org.apache.kafka.common.serialization.StringSerializer
26
+ import org.assertj.core.api.Assertions.assertThat
26
27
import org.junit.jupiter.api.AfterAll
27
28
import org.junit.jupiter.api.Assertions.assertEquals
28
29
import org.junit.jupiter.api.BeforeAll
29
30
import org.junit.jupiter.api.Test
30
- import java.time.LocalDate
31
- import java.util.*
32
31
import org.junit.jupiter.params.ParameterizedTest
33
32
import org.junit.jupiter.params.provider.CsvSource
33
+ import java.time.LocalDate
34
+ import java.util.*
34
35
35
36
internal class AfpOffentligServerTest {
36
37
companion object {
@@ -78,7 +79,7 @@ internal class AfpOffentligServerTest {
78
79
79
80
@Test
80
81
fun testAfpOffentlig () = testApplication {
81
- val apiInternClient = ApiInternKlient ()
82
+ val apiInternClient = apiInternKlient ()
82
83
83
84
application {
84
85
api(
@@ -100,18 +101,19 @@ internal class AfpOffentligServerTest {
100
101
)
101
102
assertEquals(HttpStatusCode .OK , response.status)
102
103
assertEquals(
103
- api.afp. VedtakResponse (perioder = listOf ()),
104
- response.body() as api.afp. VedtakResponse
104
+ VedtakResponse (perioder = listOf ()),
105
+ response.body() as VedtakResponse
105
106
)
106
107
}
107
108
108
109
@Test
109
110
fun `hent ut dummy-vedtak fra tp-ordningen` () = testApplication {
110
- val apiInternClient = ApiInternKlient ()
111
+ val apiInternClient = apiInternKlient ()
111
112
113
+ val kafkaProducer = mockProducer()
112
114
application {
113
115
api(
114
- Config (), mockProducer() ,
116
+ Config (), kafkaProducer ,
115
117
apiInternClient,
116
118
tpRegisterKlient(),
117
119
)
@@ -123,19 +125,23 @@ internal class AfpOffentligServerTest {
123
125
client, jwt, VedtakRequest (
124
126
personidentifikator = " 123" ,
125
127
fraOgMedDato = LocalDate .now(),
126
- tilOgMedDato = LocalDate .now(),
128
+ tilOgMedDato = LocalDate .now().plusWeeks( 1 ) ,
127
129
), " /tp-samhandling"
128
130
)
129
131
assertEquals(HttpStatusCode .OK , response.status)
130
132
assertEquals(
131
- api.Maksimum (vedtak = listOf ()),
132
- response.body() as api.Maksimum
133
+ api.Medium (vedtak = listOf ()),
134
+ response.body() as api.Medium
133
135
)
136
+
137
+ val sporingslogg = kafkaProducer.history()
138
+ // Det blir logget i sporingslogg
139
+ assertThat(sporingslogg).hasSize(1 )
134
140
}
135
141
136
142
@Test
137
143
fun `får 404 ved negativt svar fra tp-ordningen` () = testApplication {
138
- val apiInternClient = ApiInternKlient ()
144
+ val apiInternClient = apiInternKlient ()
139
145
140
146
application {
141
147
api(
@@ -168,7 +174,7 @@ internal class AfpOffentligServerTest {
168
174
api(
169
175
Config (),
170
176
mockProducer(),
171
- ApiInternKlient (),
177
+ apiInternKlient (),
172
178
tpRegisterKlient(),
173
179
)
174
180
}
@@ -191,7 +197,7 @@ internal class AfpOffentligServerTest {
191
197
api(
192
198
Config (),
193
199
mockProducer(),
194
- ApiInternKlient (),
200
+ apiInternKlient (),
195
201
tpRegisterKlient(),
196
202
)
197
203
}
@@ -219,7 +225,7 @@ internal class AfpOffentligServerTest {
219
225
api(
220
226
Config (),
221
227
mockProducer(),
222
- ApiInternKlient (),
228
+ apiInternKlient (),
223
229
tpRegisterKlient(),
224
230
)
225
231
}
@@ -247,7 +253,7 @@ internal class AfpOffentligServerTest {
247
253
248
254
}
249
255
250
- private fun ApiInternKlient () = object : IApiInternClient {
256
+ private fun apiInternKlient () = object : IApiInternClient {
251
257
override fun hentMaksimum (
252
258
callId : String ,
253
259
vedtakRequest : EksternVedtakRequest
@@ -276,7 +282,8 @@ internal class AfpOffentligServerTest {
276
282
}
277
283
}
278
284
279
- private fun mockProducer () = MockProducer (true , null , StringSerializer (), JacksonSerializer <Spor >())
285
+ private fun mockProducer () =
286
+ MockProducer (true , null , StringSerializer (), JacksonSerializer <Spor >())
280
287
281
288
private suspend fun sendPostRequest (
282
289
client : HttpClient ,
0 commit comments