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.2.15 - Refined `CounterApplicationIT` (simplified setup)
[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
c1dd45a
..
19443ac
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,7
@@
package de.juplo.kafka.wordcount.counter;
package de.juplo.kafka.wordcount.counter;
+import org.apache.kafka.common.header.Header;
+import org.apache.kafka.common.header.Headers;
import org.apache.kafka.streams.KeyValue;
import java.util.List;
import org.apache.kafka.streams.KeyValue;
import java.util.List;
@@
-50,7
+52,7
@@
class TestData
Word.of("klaus","s"));
}
Word.of("klaus","s"));
}
- static void assertExpectedResult(List<KeyValue<Word, WordCount>> receivedMessages)
+ static void assertExpectedResult(List<KeyValue<Word, WordCount
er
>> receivedMessages)
{
assertThat(receivedMessages).hasSize(11);
assertThat(receivedMessages).containsSubsequence(
{
assertThat(receivedMessages).hasSize(11);
assertThat(receivedMessages).containsSubsequence(
@@
-71,41
+73,41
@@
class TestData
expectedMessages[9]); // Boäh
}
expectedMessages[9]); // Boäh
}
- static KeyValue<Word,
WordCount
>[] expectedMessages = new KeyValue[]
+ static KeyValue<Word,
WordCounter
>[] expectedMessages = new KeyValue[]
{
KeyValue.pair(
Word.of("peter","Hallo"),
{
KeyValue.pair(
Word.of("peter","Hallo"),
- WordCount.of("peter","Hallo",1)),
+ WordCount
er
.of("peter","Hallo",1)),
KeyValue.pair(
Word.of("klaus","Müsch"),
KeyValue.pair(
Word.of("klaus","Müsch"),
- WordCount.of("klaus","Müsch",1)),
+ WordCount
er
.of("klaus","Müsch",1)),
KeyValue.pair(
Word.of("peter","Welt"),
KeyValue.pair(
Word.of("peter","Welt"),
- WordCount.of("peter","Welt",1)),
+ WordCount
er
.of("peter","Welt",1)),
KeyValue.pair(
Word.of("klaus","Müsch"),
KeyValue.pair(
Word.of("klaus","Müsch"),
- WordCount.of("klaus","Müsch",2)),
+ WordCount
er
.of("klaus","Müsch",2)),
KeyValue.pair(
Word.of("klaus","s"),
KeyValue.pair(
Word.of("klaus","s"),
- WordCount.of("klaus","s",1)),
+ WordCount
er
.of("klaus","s",1)),
KeyValue.pair(
Word.of("peter","Boäh"),
KeyValue.pair(
Word.of("peter","Boäh"),
- WordCount.of("peter","Boäh",1)),
+ WordCount
er
.of("peter","Boäh",1)),
KeyValue.pair(
Word.of("peter","Welt"),
KeyValue.pair(
Word.of("peter","Welt"),
- WordCount.of("peter","Welt",2)),
+ WordCount
er
.of("peter","Welt",2)),
KeyValue.pair(
Word.of("peter","Boäh"),
KeyValue.pair(
Word.of("peter","Boäh"),
- WordCount.of("peter","Boäh",2)),
+ WordCount
er
.of("peter","Boäh",2)),
KeyValue.pair(
Word.of("klaus","s"),
KeyValue.pair(
Word.of("klaus","s"),
- WordCount.of("klaus","s",2)),
+ WordCount
er
.of("klaus","s",2)),
KeyValue.pair(
Word.of("peter","Boäh"),
KeyValue.pair(
Word.of("peter","Boäh"),
- WordCount.of("peter","Boäh",3)),
+ WordCount
er
.of("peter","Boäh",3)),
KeyValue.pair(
Word.of("klaus","s"),
KeyValue.pair(
Word.of("klaus","s"),
- WordCount.of("klaus","s",3)),
+ WordCount
er
.of("klaus","s",3)),
};
static Map<String, Object> convertToMap(Properties properties)
};
static Map<String, Object> convertToMap(Properties properties)
@@
-119,4
+121,17
@@
class TestData
entry -> entry.getValue()
));
}
entry -> entry.getValue()
));
}
+
+ static String parseHeader(Headers headers, String key)
+ {
+ Header header = headers.lastHeader(key);
+ if (header == null)
+ {
+ return key + "=null";
+ }
+ else
+ {
+ return key + "=" + new String(header.value());
+ }
+ }
}
}