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:
4e10b6e
)
counter: 1.2.11 - Refactored test-classes (DRY for test-config)
counter-1.2.11
author
Kai Moritz
<kai@juplo.de>
Mon, 13 May 2024 19:11:38 +0000
(21:11 +0200)
committer
Kai Moritz
<kai@juplo.de>
Tue, 14 May 2024 20:35:39 +0000
(22:35 +0200)
pom.xml
patch
|
blob
|
history
src/test/java/de/juplo/kafka/wordcount/counter/CounterApplicationIT.java
patch
|
blob
|
history
src/test/java/de/juplo/kafka/wordcount/counter/CounterStreamProcessorTopologyTest.java
patch
|
blob
|
history
src/test/java/de/juplo/kafka/wordcount/counter/TestData.java
patch
|
blob
|
history
diff --git
a/pom.xml
b/pom.xml
index
2d65a21
..
5c0de9f
100644
(file)
--- a/
pom.xml
+++ b/
pom.xml
@@
-10,7
+10,7
@@
</parent>
<groupId>de.juplo.kafka.wordcount</groupId>
<artifactId>counter</artifactId>
</parent>
<groupId>de.juplo.kafka.wordcount</groupId>
<artifactId>counter</artifactId>
- <version>1.2.1
0
</version>
+ <version>1.2.1
1
</version>
<name>Wordcount-Counter</name>
<description>Word-counting stream-processor of the multi-user wordcount-example</description>
<properties>
<name>Wordcount-Counter</name>
<description>Word-counting stream-processor of the multi-user wordcount-example</description>
<properties>
diff --git
a/src/test/java/de/juplo/kafka/wordcount/counter/CounterApplicationIT.java
b/src/test/java/de/juplo/kafka/wordcount/counter/CounterApplicationIT.java
index
fea89ab
..
e0f4672
100644
(file)
--- a/
src/test/java/de/juplo/kafka/wordcount/counter/CounterApplicationIT.java
+++ b/
src/test/java/de/juplo/kafka/wordcount/counter/CounterApplicationIT.java
@@
-27,9
+27,9
@@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.List;
import java.util.Map;
import java.util.Properties;
-import java.util.stream.Collectors;
import static de.juplo.kafka.wordcount.counter.CounterApplicationIT.*;
import static de.juplo.kafka.wordcount.counter.CounterApplicationIT.*;
+import static de.juplo.kafka.wordcount.counter.TestData.convertToMap;
import static org.awaitility.Awaitility.*;
import static org.awaitility.Awaitility.*;
@@
-97,14
+97,7
@@
public class CounterApplicationIT
@Bean
ProducerFactory<?, ?> producerFactory(Properties streamProcessorProperties)
{
@Bean
ProducerFactory<?, ?> producerFactory(Properties streamProcessorProperties)
{
- Map<String, Object> propertyMap = streamProcessorProperties
- .entrySet()
- .stream()
- .collect(
- Collectors.toMap(
- entry -> (String)entry.getKey(),
- entry -> entry.getValue()
- ));
+ Map<String, Object> propertyMap = convertToMap(streamProcessorProperties);
propertyMap.put(
ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG,
propertyMap.put(
ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG,
@@
-120,14
+113,7
@@
public class CounterApplicationIT
ConcurrentKafkaListenerContainerFactory<?, ?> kafkaListenerContainerFactory(
Properties streamProcessorProperties)
{
ConcurrentKafkaListenerContainerFactory<?, ?> kafkaListenerContainerFactory(
Properties streamProcessorProperties)
{
- Map<String, Object> propertyMap = streamProcessorProperties
- .entrySet()
- .stream()
- .collect(
- Collectors.toMap(
- entry -> (String)entry.getKey(),
- entry -> entry.getValue()
- ));
+ Map<String, Object> propertyMap = convertToMap(streamProcessorProperties);
propertyMap.put(
ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG,
propertyMap.put(
ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG,
diff --git
a/src/test/java/de/juplo/kafka/wordcount/counter/CounterStreamProcessorTopologyTest.java
b/src/test/java/de/juplo/kafka/wordcount/counter/CounterStreamProcessorTopologyTest.java
index
1bdfd48
..
159123b
100644
(file)
--- a/
src/test/java/de/juplo/kafka/wordcount/counter/CounterStreamProcessorTopologyTest.java
+++ b/
src/test/java/de/juplo/kafka/wordcount/counter/CounterStreamProcessorTopologyTest.java
@@
-10,7
+10,8
@@
import org.springframework.kafka.support.serializer.JsonSerializer;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.List;
import java.util.Map;
import java.util.Properties;
-import java.util.stream.Collectors;
+
+import static de.juplo.kafka.wordcount.counter.TestData.convertToMap;
public class CounterStreamProcessorTopologyTest
public class CounterStreamProcessorTopologyTest
@@
-30,15
+31,8
@@
public class CounterStreamProcessorTopologyTest
new CounterApplicationConfiguriation();
Properties streamProcessorProperties =
applicationConfiguriation.streamProcessorProperties(new CounterApplicationProperties());
new CounterApplicationConfiguriation();
Properties streamProcessorProperties =
applicationConfiguriation.streamProcessorProperties(new CounterApplicationProperties());
+ Map<String, Object> propertyMap = convertToMap(streamProcessorProperties);
- Map<String, ?> propertyMap = streamProcessorProperties
- .entrySet()
- .stream()
- .collect(
- Collectors.toMap(
- entry -> (String)entry.getKey(),
- entry -> entry.getValue()
- ));
JsonSerde<?> keySerde = new JsonSerde<>();
keySerde.configure(propertyMap, true);
JsonSerde<?> valueSerde = new JsonSerde<>();
JsonSerde<?> keySerde = new JsonSerde<>();
keySerde.configure(propertyMap, true);
JsonSerde<?> valueSerde = new JsonSerde<>();
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
5798fc3
..
c1dd45a
100644
(file)
--- a/
src/test/java/de/juplo/kafka/wordcount/counter/TestData.java
+++ b/
src/test/java/de/juplo/kafka/wordcount/counter/TestData.java
@@
-3,7
+3,10
@@
package de.juplo.kafka.wordcount.counter;
import org.apache.kafka.streams.KeyValue;
import java.util.List;
import org.apache.kafka.streams.KeyValue;
import java.util.List;
+import java.util.Map;
+import java.util.Properties;
import java.util.function.BiConsumer;
import java.util.function.BiConsumer;
+import java.util.stream.Collectors;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
@@
-104,4
+107,16
@@
class TestData
Word.of("klaus","s"),
WordCount.of("klaus","s",3)),
};
Word.of("klaus","s"),
WordCount.of("klaus","s",3)),
};
+
+ static Map<String, Object> convertToMap(Properties properties)
+ {
+ return properties
+ .entrySet()
+ .stream()
+ .collect(
+ Collectors.toMap(
+ entry -> (String)entry.getKey(),
+ entry -> entry.getValue()
+ ));
+ }
}
}