projects
/
demos
/
kafka
/
wordcount
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
counter: 1.3.1 - Splitted up test in `CounterStreamProcessorTopologyTest`
[demos/kafka/wordcount]
/
src
/
test
/
java
/
de
/
juplo
/
kafka
/
wordcount
/
counter
/
TestData.java
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
4e431e1
..
862eb2b
100644
(file)
--- a/
src/test/java/de/juplo/kafka/wordcount/counter/TestData.java
+++ b/
src/test/java/de/juplo/kafka/wordcount/counter/TestData.java
@@
-1,5
+1,6
@@
package de.juplo.kafka.wordcount.counter;
package de.juplo.kafka.wordcount.counter;
+import de.juplo.kafka.wordcount.splitter.TestInputUser;
import de.juplo.kafka.wordcount.splitter.TestInputWord;
import de.juplo.kafka.wordcount.top10.TestOutputWord;
import de.juplo.kafka.wordcount.top10.TestOutputWordCounter;
import de.juplo.kafka.wordcount.splitter.TestInputWord;
import de.juplo.kafka.wordcount.top10.TestOutputWord;
import de.juplo.kafka.wordcount.top10.TestOutputWordCounter;
@@
-8,7
+9,6
@@
import org.apache.kafka.streams.state.ReadOnlyKeyValueStore;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
-import java.util.function.Consumer;
import java.util.stream.Stream;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.stream.Stream;
import static org.assertj.core.api.Assertions.assertThat;
@@
-31,53
+31,48
@@
class TestData
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 KLAUS_MÜSCH = TestOutputWord.of(KLAUS, WORD_MÜSCH);
static final TestOutputWord KLAUS_S = TestOutputWord.of(KLAUS, WORD_S);
- private static final KeyValue<
String
, TestInputWord>[] INPUT_MESSAGES = new KeyValue[]
+ private static final KeyValue<
TestInputUser
, TestInputWord>[] INPUT_MESSAGES = new KeyValue[]
{
{
-
new KeyValue<>
(
-
PETER
,
+
KeyValue.pair
(
+
TestInputUser.of(PETER)
,
TestInputWord.of(PETER, WORD_HALLO)),
TestInputWord.of(PETER, WORD_HALLO)),
-
new KeyValue<>
(
-
KLAUS
,
+
KeyValue.pair
(
+
TestInputUser.of(KLAUS)
,
TestInputWord.of(KLAUS, WORD_MÜSCH)),
TestInputWord.of(KLAUS, WORD_MÜSCH)),
-
new KeyValue<>
(
-
PETER
,
+
KeyValue.pair
(
+
TestInputUser.of(PETER)
,
TestInputWord.of(PETER, WORD_WELT)),
TestInputWord.of(PETER, WORD_WELT)),
-
new KeyValue<>
(
-
KLAUS
,
+
KeyValue.pair
(
+
TestInputUser.of(KLAUS)
,
TestInputWord.of(KLAUS, WORD_MÜSCH)),
TestInputWord.of(KLAUS, WORD_MÜSCH)),
-
new KeyValue<>
(
-
KLAUS
,
+
KeyValue.pair
(
+
TestInputUser.of(KLAUS)
,
TestInputWord.of(KLAUS, WORD_S)),
TestInputWord.of(KLAUS, WORD_S)),
-
new KeyValue<>
(
-
PETER
,
+
KeyValue.pair
(
+
TestInputUser.of(PETER)
,
TestInputWord.of(PETER, WORD_BOÄH)),
TestInputWord.of(PETER, WORD_BOÄH)),
-
new KeyValue<>
(
-
PETER
,
+
KeyValue.pair
(
+
TestInputUser.of(PETER)
,
TestInputWord.of(PETER, WORD_WELT)),
TestInputWord.of(PETER, WORD_WELT)),
-
new KeyValue<>
(
-
PETER
,
+
KeyValue.pair
(
+
TestInputUser.of(PETER)
,
TestInputWord.of(PETER, WORD_BOÄH)),
TestInputWord.of(PETER, WORD_BOÄH)),
-
new KeyValue<>
(
-
KLAUS
,
+
KeyValue.pair
(
+
TestInputUser.of(KLAUS)
,
TestInputWord.of(KLAUS, WORD_S)),
TestInputWord.of(KLAUS, WORD_S)),
-
new KeyValue<>
(
-
PETER
,
+
KeyValue.pair
(
+
TestInputUser.of(PETER)
,
TestInputWord.of(PETER, WORD_BOÄH)),
TestInputWord.of(PETER, WORD_BOÄH)),
-
new KeyValue<>
(
-
KLAUS
,
+
KeyValue.pair
(
+
TestInputUser.of(KLAUS)
,
TestInputWord.of(KLAUS, WORD_S)),
};
TestInputWord.of(KLAUS, WORD_S)),
};
- static Stream<KeyValue<
String
, TestInputWord>> getInputMessages()
+ static Stream<KeyValue<
TestInputUser
, TestInputWord>> getInputMessages()
{
return Stream.of(TestData.INPUT_MESSAGES);
}
{
return Stream.of(TestData.INPUT_MESSAGES);
}
- static Consumer<MultiValueMap<TestOutputWord, TestOutputWordCounter>> expectedMessagesAssertion()
- {
- return receivedMessages -> assertExpectedMessages(receivedMessages);
- }
-
static void assertExpectedMessages(MultiValueMap<TestOutputWord, TestOutputWordCounter> receivedMessages)
{
expectedMessages().forEach(
static void assertExpectedMessages(MultiValueMap<TestOutputWord, TestOutputWordCounter> receivedMessages)
{
expectedMessages().forEach(
@@
-86,11
+81,6
@@
class TestData
.containsExactlyElementsOf(counter));
}
.containsExactlyElementsOf(counter));
}
- static Consumer<MultiValueMap<TestOutputWord, TestOutputWordCounter>> expectedNumberOfMessagesForWordAssertion()
- {
- return receivedMessages -> assertExpectedNumberOfMessagesForWord(receivedMessages);
- }
-
static void assertExpectedNumberOfMessagesForWord(MultiValueMap<TestOutputWord, TestOutputWordCounter> receivedMessages)
{
assertThat(countMessagesForWord(PETER_HALLO, receivedMessages));
static void assertExpectedNumberOfMessagesForWord(MultiValueMap<TestOutputWord, TestOutputWordCounter> receivedMessages)
{
assertThat(countMessagesForWord(PETER_HALLO, receivedMessages));
@@
-102,12
+92,9
@@
class TestData
private static int countMessagesForWord(TestOutputWord word, MultiValueMap<TestOutputWord, TestOutputWordCounter> messagesForUsers)
{
private static int countMessagesForWord(TestOutputWord word, MultiValueMap<TestOutputWord, TestOutputWordCounter> messagesForUsers)
{
- return messagesForUsers.get(word).size();
- }
-
- static Consumer<MultiValueMap<TestOutputWord, TestOutputWordCounter>> expectedLastMessagesForWordAssertion()
- {
- return receivedMessages -> assertExpectedLastMessagesForWord(receivedMessages);
+ return messagesForUsers.get(word) == null
+ ? 0
+ : messagesForUsers.get(word).size();
}
static void assertExpectedState(ReadOnlyKeyValueStore<Word, Long> store)
}
static void assertExpectedState(ReadOnlyKeyValueStore<Word, Long> store)