package de.juplo.kafka.wordcount.splitter;
-import de.juplo.kafka.wordcount.counter.TestWord;
-import de.juplo.kafka.wordcount.recorder.TestRecording;
+import de.juplo.kafka.wordcount.counter.TestOutputWord;
+import de.juplo.kafka.wordcount.recorder.TestInputRecording;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@BeforeAll
public static void testSendMessage(
- @Autowired KafkaTemplate<String, TestRecording> kafkaTemplate)
+ @Autowired KafkaTemplate<String, TestInputRecording> kafkaTemplate)
{
TestData
.getInputMessages()
{
try
{
- SendResult<String, TestRecording> result = kafkaTemplate.send(TOPIC_IN, kv.key, kv.value).get();
+ SendResult<String, TestInputRecording> result = kafkaTemplate.send(TOPIC_IN, kv.key, kv.value).get();
log.info(
"Sent: {}={}, partition={}, offset={}",
result.getProducerRecord().key(),
static class Consumer
{
- private final MultiValueMap<String, TestWord> received = new LinkedMultiValueMap<>();
+ private final MultiValueMap<String, TestOutputWord> received = new LinkedMultiValueMap<>();
@KafkaListener(groupId = "TEST", topics = TOPIC_OUT)
public synchronized void receive(
@Header(KafkaHeaders.RECEIVED_KEY) String key,
- @Payload TestWord value)
+ @Payload TestOutputWord value)
{
log.debug("Received message: {}={}", key, value);
received.add(key, value);
}
- synchronized MultiValueMap<String, TestWord> getReceivedMessages()
+ synchronized MultiValueMap<String, TestOutputWord> getReceivedMessages()
{
return received;
}
package de.juplo.kafka.wordcount.splitter;
-import de.juplo.kafka.wordcount.counter.TestWord;
-import de.juplo.kafka.wordcount.recorder.TestRecording;
+import de.juplo.kafka.wordcount.counter.TestOutputWord;
+import de.juplo.kafka.wordcount.recorder.TestInputRecording;
import org.apache.kafka.streams.KeyValue;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
static final String KLAUS = "klaus";
- static final Stream<KeyValue<String, TestRecording>> getInputMessages()
+ static final Stream<KeyValue<String, TestInputRecording>> getInputMessages()
{
return Stream.of(INPUT_MESSAGES);
}
- private static final KeyValue<String, TestRecording>[] INPUT_MESSAGES = new KeyValue[]
+ private static final KeyValue<String, TestInputRecording>[] INPUT_MESSAGES = new KeyValue[]
{
new KeyValue<>(
PETER,
- TestRecording.of(PETER, "Hallo Welt!")),
+ TestInputRecording.of(PETER, "Hallo Welt!")),
new KeyValue<>(
KLAUS,
- TestRecording.of(KLAUS, "Müsch gäb's auch!")),
+ TestInputRecording.of(KLAUS, "Müsch gäb's auch!")),
new KeyValue<>(
PETER,
- TestRecording.of(PETER, "Boäh, echt! ß mal nä Nümmäh!")),
+ TestInputRecording.of(PETER, "Boäh, echt! ß mal nä Nümmäh!")),
};
- static void assertExpectedMessages(MultiValueMap<String, TestWord> receivedMessages)
+ static void assertExpectedMessages(MultiValueMap<String, TestOutputWord> receivedMessages)
{
await("Received expected messages")
.atMost(Duration.ofSeconds(5))
assertThat(receivedMessages.get(user)).containsExactlyElementsOf(word)));
}
- private static final KeyValue<String, TestWord>[] EXPECTED_MESSAGES = new KeyValue[]
+ private static final KeyValue<String, TestOutputWord>[] EXPECTED_MESSAGES = new KeyValue[]
{
KeyValue.pair(
"peter",
- TestWord.of("peter", "Hallo")),
+ TestOutputWord.of("peter", "Hallo")),
KeyValue.pair(
"peter",
- TestWord.of("peter", "Welt")),
+ TestOutputWord.of("peter", "Welt")),
KeyValue.pair(
"klaus",
- TestWord.of("klaus", "Müsch")),
+ TestOutputWord.of("klaus", "Müsch")),
KeyValue.pair(
"klaus",
- TestWord.of("klaus", "gäb")),
+ TestOutputWord.of("klaus", "gäb")),
KeyValue.pair(
"klaus",
- TestWord.of("klaus", "s")),
+ TestOutputWord.of("klaus", "s")),
KeyValue.pair(
"klaus",
- TestWord.of("klaus", "auch")),
+ TestOutputWord.of("klaus", "auch")),
KeyValue.pair(
"peter",
- TestWord.of("peter", "Boäh")),
+ TestOutputWord.of("peter", "Boäh")),
KeyValue.pair(
"peter",
- TestWord.of("peter", "echt")),
+ TestOutputWord.of("peter", "echt")),
KeyValue.pair(
"peter",
- TestWord.of("peter", "ß")),
+ TestOutputWord.of("peter", "ß")),
KeyValue.pair(
"peter",
- TestWord.of("peter", "mal")),
+ TestOutputWord.of("peter", "mal")),
KeyValue.pair(
"peter",
- TestWord.of("peter", "nä")),
+ TestOutputWord.of("peter", "nä")),
KeyValue.pair(
"peter",
- TestWord.of("peter", "Nümmäh")),
+ TestOutputWord.of("peter", "Nümmäh")),
};
- static MultiValueMap<String, TestWord> expectedMessages()
+ static MultiValueMap<String, TestOutputWord> expectedMessages()
{
- MultiValueMap<String, TestWord> expectedMessages = new LinkedMultiValueMap<>();
+ MultiValueMap<String, TestOutputWord> expectedMessages = new LinkedMultiValueMap<>();
Stream
.of(EXPECTED_MESSAGES)
.forEach(keyValue -> expectedMessages.add(keyValue.key, keyValue.value));