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 - `TestData` only holds and asserts the test-data
[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
ea33cb0
..
5dc8bc2
100644
(file)
--- a/
src/test/java/de/juplo/kafka/wordcount/counter/TestData.java
+++ b/
src/test/java/de/juplo/kafka/wordcount/counter/TestData.java
@@
-8,7
+8,6
@@
import org.springframework.util.MultiValueMap;
import java.util.Map;
import java.util.Properties;
import java.util.Map;
import java.util.Properties;
-import java.util.function.BiConsumer;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@
-17,14
+16,7
@@
import static org.assertj.core.api.Assertions.assertThat;
class TestData
{
class TestData
{
- static void writeInputData(BiConsumer<String, Word> consumer)
- {
- Stream
- .of(inputMessagesArray)
- .forEach(word -> consumer.accept(word.getUser(), word));
- }
-
- static Word[] inputMessagesArray = new Word[]
+ static final Word[] INPUT_MESSAGES = new Word[]
{
Word.of("peter","Hallo"),
Word.of("klaus","Müsch"),
{
Word.of("peter","Hallo"),
Word.of("klaus","Müsch"),
@@
-39,15
+31,15
@@
class TestData
Word.of("klaus","s"),
};
Word.of("klaus","s"),
};
- static void assertExpected
Result
(MultiValueMap<Word, WordCounter> receivedMessages)
+ static void assertExpected
Messages
(MultiValueMap<Word, WordCounter> receivedMessages)
{
{
- expectedMessages.forEach(
+ expectedMessages
()
.forEach(
(word, counter) ->
assertThat(receivedMessages.get(word))
.containsExactlyElementsOf(counter));
}
(word, counter) ->
assertThat(receivedMessages.get(word))
.containsExactlyElementsOf(counter));
}
- static
KeyValue<Word, WordCounter>[] expectedMessagesArray
= new KeyValue[]
+ static
final KeyValue<Word, WordCounter>[] EXPECTED_MESSAGES
= new KeyValue[]
{
KeyValue.pair(
Word.of("peter","Hallo"),
{
KeyValue.pair(
Word.of("peter","Hallo"),
@@
-84,13
+76,13
@@
class TestData
WordCounter.of("klaus","s",3)),
};
WordCounter.of("klaus","s",3)),
};
- static MultiValueMap<Word, WordCounter> expectedMessages;
- static
+ static MultiValueMap<Word, WordCounter> expectedMessages()
{
{
- expectedMessages = new LinkedMultiValueMap<>();
+
MultiValueMap<Word, WordCounter>
expectedMessages = new LinkedMultiValueMap<>();
Stream
Stream
- .of(
expectedMessagesArray
)
+ .of(
EXPECTED_MESSAGES
)
.forEach(keyValue -> expectedMessages.add(keyValue.key, keyValue.value));
.forEach(keyValue -> expectedMessages.add(keyValue.key, keyValue.value));
+ return expectedMessages;
}
static Map<String, Object> convertToMap(Properties properties)
}
static Map<String, Object> convertToMap(Properties properties)