From 85efcef77193aed03ea8ae3d714851d2fc1b72dc Mon Sep 17 00:00:00 2001 From: David Kornel Date: Wed, 18 Sep 2024 09:53:58 +0200 Subject: [PATCH] Change asserts + clean client builder code (#48) Signed-off-by: David Kornel --- .../io/streams/clients/kafka/StrimziKafkaClients.java | 8 +++----- src/test/java/io/streams/unit/SqlWithTest.java | 7 +++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/io/streams/clients/kafka/StrimziKafkaClients.java b/src/main/java/io/streams/clients/kafka/StrimziKafkaClients.java index bc9c79d..ff910b0 100644 --- a/src/main/java/io/streams/clients/kafka/StrimziKafkaClients.java +++ b/src/main/java/io/streams/clients/kafka/StrimziKafkaClients.java @@ -24,7 +24,7 @@ @Buildable(editableEnabled = false, builderPackage = "io.fabric8.kubernetes.api.builder") public class StrimziKafkaClients extends BaseClients { private static final Logger LOGGER = LogManager.getLogger(StrimziKafkaClients.class); - private static Random rng = new Random(); + private static final Random RNG = new Random(); private String producerName; private String consumerName; @@ -295,7 +295,7 @@ public JobBuilder defaultConsumerStrimzi() { consumerLabels.put(TestConstants.STRIMZI_TEST_CLIENTS_LABEL_KEY, TestConstants.STRIMZI_TEST_CLIENTS_LABEL_VALUE); - final JobBuilder builder = new JobBuilder() + return new JobBuilder() .withNewMetadata() .withNamespace(this.getNamespaceName()) .withLabels(consumerLabels) @@ -351,8 +351,6 @@ public JobBuilder defaultConsumerStrimzi() { .endSpec() .endTemplate() .endSpec(); - - return builder; } private EnvVar getClusterCaCertEnv(String clusterName) { @@ -410,7 +408,7 @@ protected List getTlsEnvVars() { * @return consumer group name with pattern: my-consumer-group-*-* */ private static String generateRandomConsumerGroup() { - int salt = rng.nextInt(Integer.MAX_VALUE); + int salt = RNG.nextInt(Integer.MAX_VALUE); return "my-group" + salt; } diff --git a/src/test/java/io/streams/unit/SqlWithTest.java b/src/test/java/io/streams/unit/SqlWithTest.java index 2a0a6ff..bebc6ee 100644 --- a/src/test/java/io/streams/unit/SqlWithTest.java +++ b/src/test/java/io/streams/unit/SqlWithTest.java @@ -10,9 +10,8 @@ import java.util.HashMap; import java.util.Map; -import java.util.Objects; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; public class SqlWithTest { @Test @@ -38,7 +37,7 @@ void testCreateTableWithFilesystemConnector() { .withAdditionalProperties(additionalProperties) .build(); - assertTrue(Objects.equals(sqlWith.generateSql(), expectedSql)); + assertEquals(sqlWith.generateSql(), expectedSql); } @Test @@ -77,6 +76,6 @@ void testCreateTableWithKafkaConnector() { .withAdditionalProperties(additionalProperties) .build(); - assertTrue(Objects.equals(sqlWith.generateSql(), expectedSql)); + assertEquals(sqlWith.generateSql(), expectedSql); } }