I've tried to test my code locally by setting up a Kafka server and sending messages using a producer, but I am wondering if there is a way I can write a unit test for this piece of code (test whether the message received by the consumer is correct).
val consumerSettings = ConsumerSettings(system,
new ByteArrayDeserializer, new StringDeserializer)
.withBootstrapServers("localhost:9092")
.withGroupId("group1")
.withProperty(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest")
val done = Consumer.committableSource(consumerSettings,
Subscriptions.topics("topic1"))
.map { msg =>
msg.committableOffset.commitScaladsl()
}
.runWith(Sink.ignore)