GRÜN: Korrektur der falsch formulierten Erwartungen zu dem Consumer-Zustand
authorKai Moritz <kai@juplo.de>
Fri, 19 Aug 2022 10:07:08 +0000 (12:07 +0200)
committerKai Moritz <kai@juplo.de>
Fri, 19 Aug 2022 10:32:44 +0000 (12:32 +0200)
src/test/java/de/juplo/kafka/ApplicationTests.java

index 740c09c..7246e17 100644 (file)
@@ -4,6 +4,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.kafka.clients.producer.ProducerRecord;
 import org.apache.kafka.common.serialization.StringSerializer;
 import org.apache.kafka.common.utils.Bytes;
+import org.assertj.core.api.Assertions;
 import org.springframework.beans.factory.annotation.Autowired;
 
 import java.util.*;
@@ -124,15 +125,29 @@ public class ApplicationTests extends GenericApplicationTests<String, String>
             tests.stateRepository.findById(Integer.toString(i)).get();
 
         stateDocument
-            .results.entrySet().stream()
+            .results
+            .entrySet()
+            .stream()
             .forEach(entry ->
             {
               String user = entry.getKey();
               List<AdderResult> resultsForUser = entry.getValue();
 
+              for (int j=0; j < resultsForUser.size(); j++)
+              {
+                if (!(j < state.get(user).size()))
+                {
+                  break;
+                }
+
+                assertThat(resultsForUser.get(j))
+                    .as("Unexpected results calculation %i of user %s", j, user)
+                    .isEqualTo(state.get(user).get(j));
+              }
+
               assertThat(state.get(user))
-                  .as("Unexpected results for user %s", user)
-                  .containsExactlyElementsOf(resultsForUser);
+                  .as("More results calculated for user %s as expected", user)
+                  .containsAll(resultsForUser);
             });
       }
     }