Benennung vereinheitlicht und projektunabhängig gemacht
[demos/kafka/training] / src / test / java / de / juplo / kafka / ApplicationTests.java
index fc5d4c9..1f18e59 100644 (file)
@@ -64,17 +64,15 @@ class ApplicationTests
        @Autowired
        KafkaConsumer<Bytes, Bytes> offsetConsumer;
        @Autowired
-       PartitionStatisticsRepository partitionStatisticsRepository;
-       @Autowired
        ApplicationProperties properties;
        @Autowired
        ExecutorService executor;
        @Autowired
-       PartitionStatisticsRepository repository;
+  StateRepository stateRepository;
        @Autowired
-       KeyCountingRebalanceListener keyCountingRebalanceListener;
+  ApplicationRebalanceListener rebalanceListener;
        @Autowired
-       KeyCountingRecordHandler keyCountingRecordHandler;
+  ApplicationRecordHandler recordHandler;
 
        EndlessConsumer<String, Long> endlessConsumer;
        Map<TopicPartition, Long> oldOffsets;
@@ -196,12 +194,12 @@ class ApplicationTests
                        Long offset = offsetConsumer.position(tp);
                        log.info("New position for {}: {}", tp, offset);
                        Integer partition = tp.partition();
-                       StatisticsDocument document =
-                                       partitionStatisticsRepository
+                       StateDocument document =
+                                       stateRepository
                                                        .findById(partition.toString())
-                                                       .orElse(new StatisticsDocument(partition));
+                                                       .orElse(new StateDocument(partition));
                        document.offset = offset;
-                       partitionStatisticsRepository.save(document);
+                       stateRepository.save(document);
                });
                offsetConsumer.unsubscribe();
        }
@@ -211,7 +209,7 @@ class ApplicationTests
                partitions().forEach(tp ->
                {
                        String partition = Integer.toString(tp.partition());
-                       Optional<Long> offset = partitionStatisticsRepository.findById(partition).map(document -> document.offset);
+                       Optional<Long> offset = stateRepository.findById(partition).map(document -> document.offset);
                        consumer.accept(tp, offset.orElse(0l));
                });
                }
@@ -283,7 +281,7 @@ class ApplicationTests
                });
 
                TestRecordHandler<String, Long> captureOffsetAndExecuteTestHandler =
-                               new TestRecordHandler<String, Long>(keyCountingRecordHandler) {
+                               new TestRecordHandler<String, Long>(recordHandler) {
                                        @Override
                                        public void onNewRecord(ConsumerRecord<String, Long> record)
                                        {
@@ -300,7 +298,7 @@ class ApplicationTests
                                                properties.getClientId(),
                                                properties.getTopic(),
                                                kafkaConsumer,
-                                               keyCountingRebalanceListener,
+            rebalanceListener,
                                                captureOffsetAndExecuteTestHandler);
 
                endlessConsumer.start();