Signatur und Handling des `RecordGenerator` vereinfacht/überarbeitet
[demos/kafka/training] / src / test / java / de / juplo / kafka / ApplicationTests.java
index 1272124..8369a7b 100644 (file)
@@ -27,9 +27,9 @@ public class ApplicationTests extends GenericApplicationTests<String, Long>
 
 
           @Override
-          public void generate(
-              Set<Integer> poisonPills,
-              Set<Integer> logicErrors,
+          public int generate(
+              boolean poisonPills,
+              boolean logicErrors,
               Consumer<ProducerRecord<Bytes, Bytes>> messageSender)
           {
             int i = 0;
@@ -38,17 +38,19 @@ public class ApplicationTests extends GenericApplicationTests<String, Long>
             {
               for (int key = 0; key < 10; key++)
               {
-                if (++i > 100)
-                  return;
+                i++;
 
                 Bytes value = new Bytes(longSerializer.serialize(TOPIC, (long)i));
-                if (logicErrors.contains(i))
+                if (i == 77)
                 {
-                  value = new Bytes(longSerializer.serialize(TOPIC, Long.MIN_VALUE));
-                }
-                if (poisonPills.contains(i))
-                {
-                  value = new Bytes(stringSerializer.serialize(TOPIC, "BOOM (Poison-Pill)!"));
+                  if (logicErrors)
+                  {
+                    value = new Bytes(longSerializer.serialize(TOPIC, Long.MIN_VALUE));
+                  }
+                  if (poisonPills)
+                  {
+                    value = new Bytes(stringSerializer.serialize(TOPIC, "BOOM (Poison-Pill)!"));
+                  }
                 }
 
                 ProducerRecord<Bytes, Bytes> record =
@@ -61,6 +63,8 @@ public class ApplicationTests extends GenericApplicationTests<String, Long>
                 messageSender.accept(record);
               }
             }
+
+            return i;
           }
         });
   }