projects
/
demos
/
kafka
/
wordcount
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9e0ee34
)
top10: 1.2.1 - DRY for `User` in `TestData`
author
Kai Moritz
<kai@juplo.de>
Sun, 2 Jun 2024 08:58:24 +0000
(10:58 +0200)
committer
Kai Moritz
<kai@juplo.de>
Sat, 8 Jun 2024 11:15:05 +0000
(13:15 +0200)
src/test/java/de/juplo/kafka/wordcount/top10/TestData.java
patch
|
blob
|
history
diff --git
a/src/test/java/de/juplo/kafka/wordcount/top10/TestData.java
b/src/test/java/de/juplo/kafka/wordcount/top10/TestData.java
index
f6d7ccd
..
d8c603a
100644
(file)
--- a/
src/test/java/de/juplo/kafka/wordcount/top10/TestData.java
+++ b/
src/test/java/de/juplo/kafka/wordcount/top10/TestData.java
@@
-19,41
+19,44
@@
import static org.assertj.core.api.Assertions.assertThat;
class TestData
{
class TestData
{
+ static final User PETER = User.of("peter");
+ static final User KLAUS = User.of("klaus");
+
static final KeyValue<TestWord, TestCounter>[] INPUT_MESSAGES = new KeyValue[]
{
new KeyValue<>(
static final KeyValue<TestWord, TestCounter>[] INPUT_MESSAGES = new KeyValue[]
{
new KeyValue<>(
- TestWord.of(
"peter"
,"Hallo"),
- TestCounter.of(
"peter"
,"Hallo",1)),
+ TestWord.of(
PETER.getUser()
,"Hallo"),
+ TestCounter.of(
PETER.getUser()
,"Hallo",1)),
new KeyValue<>(
new KeyValue<>(
- TestWord.of(
"klaus"
,"Müsch"),
- TestCounter.of(
"klaus"
,"Müsch",1)),
+ TestWord.of(
KLAUS.getUser()
,"Müsch"),
+ TestCounter.of(
KLAUS.getUser()
,"Müsch",1)),
new KeyValue<>(
new KeyValue<>(
- TestWord.of(
"peter"
,"Welt"),
- TestCounter.of(
"peter"
,"Welt",1)),
+ TestWord.of(
PETER.getUser()
,"Welt"),
+ TestCounter.of(
PETER.getUser()
,"Welt",1)),
new KeyValue<>(
new KeyValue<>(
- TestWord.of(
"klaus"
,"Müsch"),
- TestCounter.of(
"klaus"
,"Müsch",2)),
+ TestWord.of(
KLAUS.getUser()
,"Müsch"),
+ TestCounter.of(
KLAUS.getUser()
,"Müsch",2)),
new KeyValue<>(
new KeyValue<>(
- TestWord.of(
"klaus"
,"s"),
- TestCounter.of(
"klaus"
,"s",1)),
+ TestWord.of(
KLAUS.getUser()
,"s"),
+ TestCounter.of(
KLAUS.getUser()
,"s",1)),
new KeyValue<>(
new KeyValue<>(
- TestWord.of(
"peter"
,"Boäh"),
- TestCounter.of(
"peter"
,"Boäh",1)),
+ TestWord.of(
PETER.getUser()
,"Boäh"),
+ TestCounter.of(
PETER.getUser()
,"Boäh",1)),
new KeyValue<>(
new KeyValue<>(
- TestWord.of(
"peter"
,"Welt"),
- TestCounter.of(
"peter"
,"Welt",2)),
+ TestWord.of(
PETER.getUser()
,"Welt"),
+ TestCounter.of(
PETER.getUser()
,"Welt",2)),
new KeyValue<>(
new KeyValue<>(
- TestWord.of(
"peter"
,"Boäh"),
- TestCounter.of(
"peter"
,"Boäh",2)),
+ TestWord.of(
PETER.getUser()
,"Boäh"),
+ TestCounter.of(
PETER.getUser()
,"Boäh",2)),
new KeyValue<>(
new KeyValue<>(
- TestWord.of(
"klaus"
,"s"),
- TestCounter.of(
"klaus"
,"s",2)),
+ TestWord.of(
KLAUS.getUser()
,"s"),
+ TestCounter.of(
KLAUS.getUser()
,"s",2)),
new KeyValue<>(
new KeyValue<>(
- TestWord.of(
"peter"
,"Boäh"),
- TestCounter.of(
"peter"
,"Boäh",3)),
+ TestWord.of(
PETER.getUser()
,"Boäh"),
+ TestCounter.of(
PETER.getUser()
,"Boäh",3)),
new KeyValue<>(
new KeyValue<>(
- TestWord.of(
"klaus"
,"s"),
- TestCounter.of(
"klaus"
,"s",3)),
+ TestWord.of(
KLAUS.getUser()
,"s"),
+ TestCounter.of(
KLAUS.getUser()
,"s",3)),
};
static void assertExpectedMessages(MultiValueMap<User, Ranking> receivedMessages)
};
static void assertExpectedMessages(MultiValueMap<User, Ranking> receivedMessages)
@@
-73,58
+76,58
@@
class TestData
static KeyValue<User, Ranking>[] EXPECTED_MESSAGES = new KeyValue[]
{
KeyValue.pair( // 0
static KeyValue<User, Ranking>[] EXPECTED_MESSAGES = new KeyValue[]
{
KeyValue.pair( // 0
-
User.of("peter")
,
+
PETER
,
Ranking.of(
Entry.of("Hallo", 1l))),
KeyValue.pair( // 1
Ranking.of(
Entry.of("Hallo", 1l))),
KeyValue.pair( // 1
-
User.of("klaus")
,
+
KLAUS
,
Ranking.of(
Entry.of("Müsch", 1l))),
KeyValue.pair( // 2
Ranking.of(
Entry.of("Müsch", 1l))),
KeyValue.pair( // 2
-
User.of("peter")
,
+
PETER
,
Ranking.of(
Entry.of("Hallo", 1l),
Entry.of("Welt", 1l))),
KeyValue.pair( // 3
Ranking.of(
Entry.of("Hallo", 1l),
Entry.of("Welt", 1l))),
KeyValue.pair( // 3
-
User.of("klaus")
,
+
KLAUS
,
Ranking.of(
Entry.of("Müsch", 2l))),
KeyValue.pair( // 4
Ranking.of(
Entry.of("Müsch", 2l))),
KeyValue.pair( // 4
-
User.of("klaus")
,
+
KLAUS
,
Ranking.of(
Entry.of("Müsch", 2l),
Entry.of("s", 1l))),
KeyValue.pair( // 5
Ranking.of(
Entry.of("Müsch", 2l),
Entry.of("s", 1l))),
KeyValue.pair( // 5
-
User.of("peter")
,
+
PETER
,
Ranking.of(
Entry.of("Hallo", 1l),
Entry.of("Welt", 1l),
Entry.of("Boäh", 1l))),
KeyValue.pair( // 6
Ranking.of(
Entry.of("Hallo", 1l),
Entry.of("Welt", 1l),
Entry.of("Boäh", 1l))),
KeyValue.pair( // 6
-
User.of("peter")
,
+
PETER
,
Ranking.of(
Entry.of("Welt", 2l),
Entry.of("Hallo", 1l),
Entry.of("Boäh", 1l))),
KeyValue.pair( // 7
Ranking.of(
Entry.of("Welt", 2l),
Entry.of("Hallo", 1l),
Entry.of("Boäh", 1l))),
KeyValue.pair( // 7
-
User.of("peter")
,
+
PETER
,
Ranking.of(
Entry.of("Welt", 2l),
Entry.of("Boäh", 2l),
Entry.of("Hallo", 1l))),
KeyValue.pair( // 8
Ranking.of(
Entry.of("Welt", 2l),
Entry.of("Boäh", 2l),
Entry.of("Hallo", 1l))),
KeyValue.pair( // 8
-
User.of("klaus")
,
+
KLAUS
,
Ranking.of(
Entry.of("Müsch", 2l),
Entry.of("s", 2l))),
KeyValue.pair( // 9
Ranking.of(
Entry.of("Müsch", 2l),
Entry.of("s", 2l))),
KeyValue.pair( // 9
-
User.of("peter")
,
+
PETER
,
Ranking.of(
Entry.of("Boäh", 3l),
Entry.of("Welt", 2l),
Entry.of("Hallo", 1l))),
KeyValue.pair( // 10
Ranking.of(
Entry.of("Boäh", 3l),
Entry.of("Welt", 2l),
Entry.of("Hallo", 1l))),
KeyValue.pair( // 10
-
User.of("klaus")
,
+
KLAUS
,
Ranking.of(
Entry.of("s", 3l),
Entry.of("Müsch", 2l))),
Ranking.of(
Entry.of("s", 3l),
Entry.of("Müsch", 2l))),