1
1
package no.nav.emottak.ebms.async.kafka
2
2
3
+ import com.sksamuel.hoplite.Masked
3
4
import kotlinx.coroutines.runBlocking
4
5
import kotlinx.serialization.json.Json
5
6
import no.nav.emottak.utils.config.Kafka
6
7
import no.nav.emottak.utils.config.KeystoreLocation
7
8
import no.nav.emottak.utils.config.KeystoreType
8
- import no.nav.emottak.utils.config.Masked
9
9
import no.nav.emottak.utils.config.SecurityProtocol
10
10
import no.nav.emottak.utils.config.TruststoreLocation
11
11
import no.nav.emottak.utils.config.TruststoreType
@@ -36,13 +36,11 @@ class KafkaPublisherClientTest {
36
36
fun `Legg 2 meldinger på Kafka` () {
37
37
kafkaConsumer.subscribe(listOf (TOPIC ))
38
38
runBlocking {
39
- kafkaPublisher.send( " MSG 1 " , randomEvent(" Event 1" ).toByteArray())
40
- kafkaPublisher.send( " MSG 2 " , randomEvent(" Event 2" ).toByteArray())
39
+ kafkaPublisher.publishMessage( randomEvent(" Event 1" ).toByteArray())
40
+ kafkaPublisher.publishMessage( randomEvent(" Event 2" ).toByteArray())
41
41
}
42
42
val msgs: List <ConsumerRecord <String , ByteArray >> = readRecentMessages()
43
43
Assertions .assertEquals(2 , msgs.size)
44
- Assertions .assertEquals(" MSG 1" , msgs.first().key())
45
- Assertions .assertEquals(" MSG 2" , msgs.last().key())
46
44
47
45
val firstEventJson = msgs.first().value().decodeToString()
48
46
val firstEvent = Json .decodeFromString<Event >(firstEventJson)
@@ -57,11 +55,10 @@ class KafkaPublisherClientTest {
57
55
fun `Legg 1 melding på Kafka` () {
58
56
kafkaConsumer.subscribe(listOf (TOPIC ))
59
57
runBlocking {
60
- kafkaPublisher.send( " MSG 3 " , randomEvent(" Ny event 3" ).toByteArray())
58
+ kafkaPublisher.publishMessage( randomEvent(" Ny event 3" ).toByteArray())
61
59
}
62
60
val msgs: List <ConsumerRecord <String , ByteArray >> = readRecentMessages()
63
61
Assertions .assertEquals(1 , msgs.size)
64
- Assertions .assertEquals(" MSG 3" , msgs.first().key())
65
62
66
63
val firstEventJson = msgs.first().value().decodeToString()
67
64
val firstEvent = Json .decodeFromString<Event >(firstEventJson)
@@ -99,7 +96,7 @@ class KafkaPublisherClientTest {
99
96
println (" === Kafka Test Container ===" )
100
97
KafkaTestContainer .start()
101
98
println (" KafkaTestContainer.bootstrapServers: ${KafkaTestContainer .bootstrapServers} " )
102
- kafkaPublisher = KafkaPublisherClient (TOPIC , kafkaSettings(KafkaTestContainer .bootstrapServers))
99
+ kafkaPublisher = KafkaPublisherClient (kafkaSettings(KafkaTestContainer .bootstrapServers))
103
100
kafkaConsumer = createConsumer(KafkaTestContainer .bootstrapServers)
104
101
}
105
102
@@ -119,7 +116,9 @@ class KafkaPublisherClientTest {
119
116
truststoreType = TruststoreType (" " ),
120
117
truststoreLocation = TruststoreLocation (" " ),
121
118
truststorePassword = Masked (" " ),
122
- groupId = " ebms-provider"
119
+ groupId = " ebms-provider" ,
120
+ topic = TOPIC ,
121
+ eventLoggingProducerActive = false
123
122
)
124
123
125
124
private fun createConsumer (bootstrapServers : String ): KafkaConsumer <String , ByteArray > {
0 commit comments