From 8e47c3e73f46514e37df1a3dc9c4961fc17ac3a5 Mon Sep 17 00:00:00 2001 From: Alexey Vinogradov Date: Tue, 1 Jun 2021 17:08:17 +0700 Subject: [PATCH] feat: fix the ZeebeClusterBuilderTest Expand assertions to the `singleElement` and `satisfies` --- .../cluster/ZeebeClusterBuilderTest.java | 38 +++++++++++++------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/test/java/io/zeebe/containers/cluster/ZeebeClusterBuilderTest.java b/src/test/java/io/zeebe/containers/cluster/ZeebeClusterBuilderTest.java index 037b75bb..822489a8 100644 --- a/src/test/java/io/zeebe/containers/cluster/ZeebeClusterBuilderTest.java +++ b/src/test/java/io/zeebe/containers/cluster/ZeebeClusterBuilderTest.java @@ -24,6 +24,7 @@ import io.zeebe.containers.ZeebeNode; import java.util.HashSet; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import org.assertj.core.api.Condition; import org.junit.jupiter.api.Test; @@ -521,9 +522,12 @@ void shouldSetImageNameForGateways() { final ZeebeCluster cluster = builder.build(); // then - final Map>> gateways = - cluster.getGateways(); - assertThat(gateways).hasSize(1).hasValueSatisfying(zeebeImageHasImageName(zeebeDockerImage)); + assertThat(cluster + .getGateways() + .entrySet()) + .as("the only gateway created has the right docker image") + .singleElement() + .satisfies(gatewayEntry -> verifyZeebeHasImageName(gatewayEntry.getValue(), zeebeDockerImage)); } @Test @@ -538,9 +542,12 @@ void shouldSetImageNameForBrokers() { final ZeebeCluster cluster = builder.build(); // then - final Map>> brokers = - cluster.getBrokers(); - assertThat(brokers).hasSize(1).hasValueSatisfying(zeebeImageHasImageName(zeebeDockerImage)); + assertThat(cluster + .getBrokers() + .entrySet()) + .as("the only broker created has the right docker image") + .singleElement() + .satisfies(brokerEntry -> verifyZeebeHasImageName(brokerEntry.getValue(), zeebeDockerImage)); } @Test @@ -559,12 +566,14 @@ void shouldSetImageNameForGatewaysAndBrokers() { final ZeebeCluster cluster = builder.build(); // then - final Map>> brokers = - cluster.getBrokers(); - assertThat(brokers).hasSize(1).hasValueSatisfying(zeebeImageHasImageName(zeebeDockerImage)); - final Map>> gateways = - cluster.getGateways(); - assertThat(gateways).hasSize(1).hasValueSatisfying(zeebeImageHasImageName(zeebeDockerImage)); + assertThat(cluster.getBrokers().entrySet()) + .as("the only broker created has the right docker image") + .singleElement() + .satisfies(brokerEntry -> verifyZeebeHasImageName(brokerEntry.getValue(), zeebeDockerImage)); + assertThat(cluster.getGateways().entrySet()) + .as("the only standalone gateway created has the right docker image") + .singleElement() + .satisfies(gatewayEntry -> verifyZeebeHasImageName(gatewayEntry.getValue(), zeebeDockerImage)); } private Condition>> zeebeImageHasImageName( @@ -572,4 +581,9 @@ private Condition>> zeebeImageHasImageNa return new Condition<>( node -> node.getDockerImageName().equals(imageName), "Image Name Condition"); } + + private void verifyZeebeHasImageName(final ZeebeNode> zeebe, + final String imageName) { + assertThat(zeebe.getDockerImageName()).isEqualTo(imageName); + } }