Typisierung in `GenericApplicationTest` nur noch, wo wirklich nötig
[demos/kafka/training] / src / test / java / de / juplo / kafka / GenericApplicationTest.java
index 6b2b635..68f150f 100644 (file)
@@ -53,7 +53,7 @@ abstract class GenericApplicationTest<K, V>
        @Autowired
        ExecutorService executor;
 
-       KafkaProducer<K, Bytes> testRecordProducer;
+       KafkaProducer<Bytes, Bytes> testRecordProducer;
        KafkaConsumer<Bytes, Bytes> offsetConsumer;
        Consumer<ConsumerRecord<K, V>> testHandler;
        EndlessConsumer<K, V> endlessConsumer;
@@ -62,15 +62,11 @@ abstract class GenericApplicationTest<K, V>
        Set<ConsumerRecord<K, V>> receivedRecords;
 
 
-       final Serializer<K> keySerializer;
-       final RecordGenerator<K> recordGenerator;
-       final Consumer<ProducerRecord<K, Bytes>> messageSender;
+       final RecordGenerator recordGenerator;
+       final Consumer<ProducerRecord<Bytes, Bytes>> messageSender;
 
-       public GenericApplicationTest(
-                       Serializer<K> keySerializer,
-                       RecordGenerator<K> recordGenerator)
+       public GenericApplicationTest(RecordGenerator recordGenerator)
        {
-               this.keySerializer = keySerializer;
                this.recordGenerator = recordGenerator;
                this.messageSender = (record) -> sendMessage(record);
        }
@@ -204,15 +200,15 @@ abstract class GenericApplicationTest<K, V>
        }
 
 
-       public interface RecordGenerator<K>
+       public interface RecordGenerator
        {
                void generate(
                                int numberOfMessagesToGenerate,
                                Set<Integer> poistionPills,
-                               Consumer<ProducerRecord<K, Bytes>> messageSender);
+                               Consumer<ProducerRecord<Bytes, Bytes>> messageSender);
        }
 
-       void sendMessage(ProducerRecord<K, Bytes> record)
+       void sendMessage(ProducerRecord<Bytes, Bytes> record)
        {
                testRecordProducer.send(record, (metadata, e) ->
                {
@@ -244,7 +240,7 @@ abstract class GenericApplicationTest<K, V>
                props = new Properties();
                props.put("bootstrap.servers", properties.getBootstrapServer());
                props.put("linger.ms", 100);
-               props.put("key.serializer", keySerializer.getClass().getName());
+               props.put("key.serializer", BytesSerializer.class.getName());
                props.put("value.serializer", BytesSerializer.class.getName());
                testRecordProducer = new KafkaProducer<>(props);