Skip to content

Commit

Permalink
feat: code review: small fixes on the ZeebeClusterBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
aivinog1 committed Jun 1, 2021
1 parent 8e47c3e commit a23c079
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
*/
package io.zeebe.containers.cluster;

import static io.zeebe.containers.ZeebeDefaults.getInstance;

import io.zeebe.containers.ZeebeBrokerContainer;
import io.zeebe.containers.ZeebeBrokerNode;
import io.zeebe.containers.ZeebeContainer;
import io.zeebe.containers.ZeebeDefaults;
import io.zeebe.containers.ZeebeGatewayContainer;
import io.zeebe.containers.ZeebeGatewayNode;
import io.zeebe.containers.ZeebeTopologyWaitStrategy;
Expand Down Expand Up @@ -96,7 +97,6 @@ public class ZeebeClusterBuilder {
private static final String BROKER_NETWORK_ALIAS_PREFIX = "zeebe-broker-";
private static final String GATEWAY_NETWORK_ALIAS_PREFIX = "zeebe-gateway-";
private static final String DEFAULT_CLUSTER_NAME = "zeebe-cluster";
private static final ZeebeDefaults ZEEBE_DEFAULTS = ZeebeDefaults.getInstance();

private Network network = Network.SHARED;
private String name = DEFAULT_CLUSTER_NAME;
Expand All @@ -107,8 +107,8 @@ public class ZeebeClusterBuilder {
private int partitionsCount = 1;
private int replicationFactor = 1;
private boolean useEmbeddedGateway = true;
private DockerImageName gatewayImageName = ZEEBE_DEFAULTS.getDefaultDockerImage();
private DockerImageName brokerImageName = ZEEBE_DEFAULTS.getDefaultDockerImage();
private DockerImageName gatewayImageName = getInstance().getDefaultDockerImage();
private DockerImageName brokerImageName = getInstance().getDefaultDockerImage();

private final Map<String, ZeebeGatewayNode<? extends GenericContainer<?>>> gateways =
new HashMap<>();
Expand Down Expand Up @@ -279,7 +279,7 @@ public ZeebeClusterBuilder withBrokerImage(final DockerImageName brokerImageName
* @return this builder instance for chaining
*/
public ZeebeClusterBuilder withImage(final DockerImageName imageName) {
return this.withGatewayImage(imageName).withBrokerImage(imageName);
return withGatewayImage(imageName).withBrokerImage(imageName);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
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;
Expand Down Expand Up @@ -522,12 +521,11 @@ void shouldSetImageNameForGateways() {
final ZeebeCluster cluster = builder.build();

// then
assertThat(cluster
.getGateways()
.entrySet())
.as("the only gateway created has the right docker image")
.singleElement()
.satisfies(gatewayEntry -> verifyZeebeHasImageName(gatewayEntry.getValue(), zeebeDockerImage));
assertThat(cluster.getGateways().entrySet())
.as("the only gateway created has the right docker image")
.singleElement()
.satisfies(
gatewayEntry -> verifyZeebeHasImageName(gatewayEntry.getValue(), zeebeDockerImage));
}

@Test
Expand All @@ -542,12 +540,11 @@ void shouldSetImageNameForBrokers() {
final ZeebeCluster cluster = builder.build();

// then
assertThat(cluster
.getBrokers()
.entrySet())
.as("the only broker created has the right docker image")
.singleElement()
.satisfies(brokerEntry -> verifyZeebeHasImageName(brokerEntry.getValue(), zeebeDockerImage));
assertThat(cluster.getBrokers().entrySet())
.as("the only broker created has the right docker image")
.singleElement()
.satisfies(
brokerEntry -> verifyZeebeHasImageName(brokerEntry.getValue(), zeebeDockerImage));
}

@Test
Expand All @@ -567,13 +564,15 @@ void shouldSetImageNameForGatewaysAndBrokers() {

// then
assertThat(cluster.getBrokers().entrySet())
.as("the only broker created has the right docker image")
.singleElement()
.satisfies(brokerEntry -> verifyZeebeHasImageName(brokerEntry.getValue(), zeebeDockerImage));
.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));
.as("the only standalone gateway created has the right docker image")
.singleElement()
.satisfies(
gatewayEntry -> verifyZeebeHasImageName(gatewayEntry.getValue(), zeebeDockerImage));
}

private Condition<ZeebeNode<? extends GenericContainer<?>>> zeebeImageHasImageName(
Expand All @@ -582,8 +581,8 @@ private Condition<ZeebeNode<? extends GenericContainer<?>>> zeebeImageHasImageNa
node -> node.getDockerImageName().equals(imageName), "Image Name Condition");
}

private void verifyZeebeHasImageName(final ZeebeNode<? extends GenericContainer<?>> zeebe,
final String imageName) {
private void verifyZeebeHasImageName(
final ZeebeNode<? extends GenericContainer<?>> zeebe, final String imageName) {
assertThat(zeebe.getDockerImageName()).isEqualTo(imageName);
}
}

0 comments on commit a23c079

Please sign in to comment.