From 649332b6055b42f04014751f8a11081108f4a731 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Fri, 5 Jul 2024 23:30:56 +0200 Subject: [PATCH] Simplified code: DRY for assertions --- .../counter/StreamStreamJoinTopologyTest.java | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) 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 -- 2.20.1