X-Git-Url: https://juplo.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Ftest%2Fjava%2Fde%2Fjuplo%2Fkafka%2Fwordcount%2Fcounter%2FTestData.java;h=862eb2bc67463437168bc94db062c62d8d3cdb5f;hb=refs%2Fheads%2Fcounter;hp=1ecfdbdea8a0b0a0e0c3c9eac1d93241d79b5b9e;hpb=5aa03935c0d09c363dc2b3ddcbd5fc9aac93b8e1;p=demos%2Fkafka%2Fwordcount diff --git a/src/test/java/de/juplo/kafka/wordcount/counter/TestData.java b/src/test/java/de/juplo/kafka/wordcount/counter/TestData.java index 1ecfdbd..9b38dbc 100644 --- a/src/test/java/de/juplo/kafka/wordcount/counter/TestData.java +++ b/src/test/java/de/juplo/kafka/wordcount/counter/TestData.java @@ -11,6 +11,7 @@ import org.springframework.util.MultiValueMap; import java.util.stream.Stream; +import static de.juplo.kafka.wordcount.counter.CounterStreamProcessor.TYPE; import static org.assertj.core.api.Assertions.assertThat; @@ -25,45 +26,45 @@ class TestData static final String WORD_S = "s"; static final String WORD_BOÄH = "Boäh"; - static final TestOutputWord PETER_HALLO = TestOutputWord.of(PETER, WORD_HALLO); - static final TestOutputWord PETER_WELT = TestOutputWord.of(PETER, WORD_WELT); - static final TestOutputWord PETER_BOÄH = TestOutputWord.of(PETER, WORD_BOÄH); - static final TestOutputWord KLAUS_MÜSCH = TestOutputWord.of(KLAUS, WORD_MÜSCH); - static final TestOutputWord KLAUS_S = TestOutputWord.of(KLAUS, WORD_S); + static final TestOutputWord PETER_HALLO = TestOutputWord.of(TYPE, PETER, WORD_HALLO); + static final TestOutputWord PETER_WELT = TestOutputWord.of(TYPE, PETER, WORD_WELT); + static final TestOutputWord PETER_BOÄH = TestOutputWord.of(TYPE, PETER, WORD_BOÄH); + static final TestOutputWord KLAUS_MÜSCH = TestOutputWord.of(TYPE, KLAUS, WORD_MÜSCH); + static final TestOutputWord KLAUS_S = TestOutputWord.of(TYPE, KLAUS, WORD_S); private static final KeyValue[] INPUT_MESSAGES = new KeyValue[] { - new KeyValue<>( + KeyValue.pair( TestInputUser.of(PETER), TestInputWord.of(PETER, WORD_HALLO)), - new KeyValue<>( + KeyValue.pair( TestInputUser.of(KLAUS), TestInputWord.of(KLAUS, WORD_MÜSCH)), - new KeyValue<>( + KeyValue.pair( TestInputUser.of(PETER), TestInputWord.of(PETER, WORD_WELT)), - new KeyValue<>( + KeyValue.pair( TestInputUser.of(KLAUS), TestInputWord.of(KLAUS, WORD_MÜSCH)), - new KeyValue<>( + KeyValue.pair( TestInputUser.of(KLAUS), TestInputWord.of(KLAUS, WORD_S)), - new KeyValue<>( + KeyValue.pair( TestInputUser.of(PETER), TestInputWord.of(PETER, WORD_BOÄH)), - new KeyValue<>( + KeyValue.pair( TestInputUser.of(PETER), TestInputWord.of(PETER, WORD_WELT)), - new KeyValue<>( + KeyValue.pair( TestInputUser.of(PETER), TestInputWord.of(PETER, WORD_BOÄH)), - new KeyValue<>( + KeyValue.pair( TestInputUser.of(KLAUS), TestInputWord.of(KLAUS, WORD_S)), - new KeyValue<>( + KeyValue.pair( TestInputUser.of(PETER), TestInputWord.of(PETER, WORD_BOÄH)), - new KeyValue<>( + KeyValue.pair( TestInputUser.of(KLAUS), TestInputWord.of(KLAUS, WORD_S)), }; @@ -108,12 +109,9 @@ class TestData private static Word wordOf(TestOutputWord testOutputWord) { - Word word = new Word(); - - word.setUser(testOutputWord.getUser()); - word.setWord(testOutputWord.getWord()); - - return word; + return Word.of( + testOutputWord.getChannel(), + testOutputWord.getKey()); } static void assertExpectedLastMessagesForWord(MultiValueMap receivedMessages) @@ -130,8 +128,8 @@ class TestData Long counter) { TestOutputWordCounter testOutputWordCounter = TestOutputWordCounter.of( - word.getUser(), - word.getWord(), + word.getChannel(), + word.getKey(), counter); assertWordCountEqualsWordCountFromLastMessage(word, testOutputWordCounter); }