From: Kai Moritz Date: Fri, 19 Aug 2022 10:07:08 +0000 (+0200) Subject: GRÜN: Korrektur der falsch formulierten Erwartungen zu dem Consumer-Zustand X-Git-Tag: sumup-adder---lvm-2-tage~8 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=a89b6d6a026cc32da8186d52c48b25ac1e6249c2;p=demos%2Fkafka%2Ftraining GRÜN: Korrektur der falsch formulierten Erwartungen zu dem Consumer-Zustand --- diff --git a/src/test/java/de/juplo/kafka/ApplicationTests.java b/src/test/java/de/juplo/kafka/ApplicationTests.java index 740c09c..7246e17 100644 --- a/src/test/java/de/juplo/kafka/ApplicationTests.java +++ b/src/test/java/de/juplo/kafka/ApplicationTests.java @@ -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 tests.stateRepository.findById(Integer.toString(i)).get(); stateDocument - .results.entrySet().stream() + .results + .entrySet() + .stream() .forEach(entry -> { String user = entry.getKey(); List 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); }); } }