From: Kai Moritz Date: Fri, 5 Jul 2024 21:30:56 +0000 (+0200) Subject: Simplified code: DRY for assertions X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=649332b6055b42f04014751f8a11081108f4a731;p=demos%2Fkafka%2Fwordcount Simplified code: DRY for assertions --- diff --git a/src/test/java/de/juplo/kafka/wordcount/counter/StreamStreamJoinTopologyTest.java b/src/test/java/de/juplo/kafka/wordcount/counter/StreamStreamJoinTopologyTest.java index de45d53..f73d028 100644 --- a/src/test/java/de/juplo/kafka/wordcount/counter/StreamStreamJoinTopologyTest.java +++ b/src/test/java/de/juplo/kafka/wordcount/counter/StreamStreamJoinTopologyTest.java @@ -62,37 +62,37 @@ public class StreamStreamJoinTopologyTest inLeft.pipeInput(recordOf("A", 3)); - assertThat(outcome()).containsExactlyInAnyOrder(); + assertThatOutcomeIs(); inRight.pipeInput(recordOf("a", 4)); - assertThat(outcome()).containsExactlyInAnyOrder("A-a"); + assertThatOutcomeIs("A-a"); inLeft.pipeInput(recordOf("B", 5)); - assertThat(outcome()).containsExactlyInAnyOrder("B-a"); + assertThatOutcomeIs("B-a"); inRight.pipeInput(recordOf("b", 6)); - assertThat(outcome()).containsExactlyInAnyOrder("A-b", "B-b"); + assertThatOutcomeIs("A-b", "B-b"); inLeft.pipeInput(recordOf("C", 9)); - assertThat(outcome()).containsExactlyInAnyOrder("C-a", "C-b"); + assertThatOutcomeIs("C-a", "C-b"); inRight.pipeInput(recordOf("c", 10)); - assertThat(outcome()).containsExactlyInAnyOrder("A-c", "B-c", "C-c"); + assertThatOutcomeIs("A-c", "B-c", "C-c"); inRight.pipeInput(recordOf("d", 14)); - assertThat(outcome()).containsExactlyInAnyOrder("B-d", "C-d"); // ! + assertThatOutcomeIs("B-d", "C-d"); // ! inLeft.pipeInput(recordOf("D", 15)); - assertThat(outcome()).containsExactlyInAnyOrder("D-b", "D-c", "D-d"); + assertThatOutcomeIs("D-b", "D-c", "D-d"); inLeft.pipeInput(recordOf("E", 40)); - assertThat(outcome()).containsExactlyInAnyOrder(); + assertThatOutcomeIs(); inLeft.pipeInput(recordOf("F", 60)); - assertThat(outcome()).containsExactlyInAnyOrder(); + assertThatOutcomeIs(); inLeft.pipeInput(recordOf("G", 100)); - assertThat(outcome()).containsExactlyInAnyOrder(); + assertThatOutcomeIs(); } @@ -102,6 +102,11 @@ public class StreamStreamJoinTopologyTest return new TestRecord<>("foo", value, T.plusSeconds(second)); } + void assertThatOutcomeIs(String... expected) + { + assertThat(outcome()).containsExactlyInAnyOrder(expected); + } + Stream outcome() { return outJoined