await("Expexted converted data")
.atMost(Duration.ofSeconds(10))
- .untilAsserted(() -> TestData.assertExpectedResult(consumer.received));
+ .untilAsserted(() -> TestData.assertExpectedResult(consumer.getReceivedMessages()));
}
private final ObjectMapper mapper;
@KafkaListener(groupId = "TEST", topics = TOPIC_OUT)
- public void receive(ConsumerRecord<String, String> record) throws JsonProcessingException
+ public synchronized void receive(ConsumerRecord<String, String> record) throws JsonProcessingException
{
log.debug("Received message: {}", record);
Key key = mapper.readValue(record.key(), Key.class);
received.add(Message.of(key,record.value()));
}
+
+ synchronized List<Message> getReceivedMessages()
+ {
+ return received;
+ }
}
@TestConfiguration