From 214e2e7d2d2cdba538627b9863f1342f78be96d5 Mon Sep 17 00:00:00 2001 From: Ondrej Babec Date: Wed, 28 Feb 2024 12:01:34 +0100 Subject: [PATCH] Add checkstyle and fix current violation (#18) * Add checkstyle * Allign files to checkstyle --- checkstyle.xml | 100 ++++++++++++++++++ pom.xml | 24 +++++ .../io/skodjob/testframe/LoggerUtils.java | 4 +- .../skodjob/testframe/TestFrameConstants.java | 4 + .../io/skodjob/testframe/TestFrameEnv.java | 8 +- .../skodjob/testframe/clients/KubeClient.java | 10 +- .../clients/cmdClient/BaseCmdKubeClient.java | 50 +++++---- .../clients/cmdClient/KubeCmdClient.java | 7 +- .../testframe/clients/cmdClient/Oc.java | 4 +- .../io/skodjob/testframe/executor/Exec.java | 26 +++-- .../testframe/executor/ExecBuilder.java | 4 +- .../interfaces/NamespacedResourceType.java | 4 +- .../testframe/interfaces/ResourceType.java | 4 +- .../listeners/ResourceManagerExtension.java | 11 +- .../TestVisualSeparatorExtension.java | 10 +- .../resources/ResourceCondition.java | 8 +- .../testframe/resources/ResourceManager.java | 43 +++++--- .../testframe/utils/TestFrameUtils.java | 23 +--- .../java/io/skodjob/testframe/wait/Wait.java | 31 +++--- .../resources/ClusterRoleBindingResource.java | 7 +- .../resources/ClusterRoleResource.java | 4 +- .../resources/ConfigMapResource.java | 4 +- .../CustomResourceDefinitionResource.java | 7 +- .../resources/DeploymentResource.java | 4 +- .../testframe/resources/JobResource.java | 4 +- .../testframe/resources/LeaseResource.java | 4 +- .../resources/NamespaceResource.java | 6 +- .../resources/NetworkPolicyResource.java | 4 +- .../resources/RoleBindingResource.java | 4 +- .../testframe/resources/RoleResource.java | 4 +- .../testframe/resources/SecretResource.java | 4 +- .../resources/ServiceAccountResource.java | 4 +- .../testframe/resources/ServiceResource.java | 7 +- ...alidatingWebhookConfigurationResource.java | 12 ++- 34 files changed, 308 insertions(+), 146 deletions(-) create mode 100644 checkstyle.xml diff --git a/checkstyle.xml b/checkstyle.xml new file mode 100644 index 0000000..b813e69 --- /dev/null +++ b/checkstyle.xml @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml index 4385e13..5d63d73 100644 --- a/pom.xml +++ b/pom.xml @@ -61,6 +61,11 @@ Jakub Stejskal xstejs24@gmail.com + + obabec + Ondrej Babec + ond.babec@gmail.com + @@ -82,6 +87,7 @@ 3.4.1 3.4.2 3.9.0 + checkstyle.xml 5.10.2 @@ -150,6 +156,24 @@ + + org.apache.maven.plugins + maven-checkstyle-plugin + ${maven.checkstyle.version} + + + validate + validate + + true + true + + + check + + + + maven-source-plugin ${maven.source.plugin.version} diff --git a/test-frame-common/src/main/java/io/skodjob/testframe/LoggerUtils.java b/test-frame-common/src/main/java/io/skodjob/testframe/LoggerUtils.java index fcc34ad..578b4bb 100644 --- a/test-frame-common/src/main/java/io/skodjob/testframe/LoggerUtils.java +++ b/test-frame-common/src/main/java/io/skodjob/testframe/LoggerUtils.java @@ -4,11 +4,11 @@ */ package io.skodjob.testframe; +import java.util.Collections; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.Collections; - public class LoggerUtils { private static final Logger LOGGER = LoggerFactory.getLogger(LoggerUtils.class); diff --git a/test-frame-common/src/main/java/io/skodjob/testframe/TestFrameConstants.java b/test-frame-common/src/main/java/io/skodjob/testframe/TestFrameConstants.java index 3f9198c..841d955 100644 --- a/test-frame-common/src/main/java/io/skodjob/testframe/TestFrameConstants.java +++ b/test-frame-common/src/main/java/io/skodjob/testframe/TestFrameConstants.java @@ -1,3 +1,7 @@ +/* + * Copyright Skodjob authors. + * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html). + */ package io.skodjob.testframe; import java.time.Duration; diff --git a/test-frame-common/src/main/java/io/skodjob/testframe/TestFrameEnv.java b/test-frame-common/src/main/java/io/skodjob/testframe/TestFrameEnv.java index ec12345..fadb31e 100644 --- a/test-frame-common/src/main/java/io/skodjob/testframe/TestFrameEnv.java +++ b/test-frame-common/src/main/java/io/skodjob/testframe/TestFrameEnv.java @@ -4,10 +4,6 @@ */ package io.skodjob.testframe; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.yaml.snakeyaml.Yaml; - import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -18,6 +14,10 @@ import java.util.Objects; import java.util.function.Function; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.yaml.snakeyaml.Yaml; + /** * Class which holds environment variables for system tests. */ diff --git a/test-frame-common/src/main/java/io/skodjob/testframe/clients/KubeClient.java b/test-frame-common/src/main/java/io/skodjob/testframe/clients/KubeClient.java index 6a1c54d..d9fb2a5 100644 --- a/test-frame-common/src/main/java/io/skodjob/testframe/clients/KubeClient.java +++ b/test-frame-common/src/main/java/io/skodjob/testframe/clients/KubeClient.java @@ -4,6 +4,8 @@ */ package io.skodjob.testframe.clients; +import java.util.Arrays; + import io.fabric8.kubernetes.client.Config; import io.fabric8.kubernetes.client.ConfigBuilder; import io.fabric8.kubernetes.client.KubernetesClient; @@ -13,8 +15,6 @@ import io.skodjob.testframe.TestFrameEnv; import io.skodjob.testframe.executor.Exec; -import java.util.Arrays; - public class KubeClient { private KubernetesClient client; @@ -73,13 +73,15 @@ private String createLocalKubeconfig() { if (TestFrameEnv.KUBE_URL != null && TestFrameEnv.KUBE_TOKEN != null) { createLocalOcKubeconfig(TestFrameEnv.KUBE_TOKEN, TestFrameEnv.KUBE_URL); } else { - createLocalOcKubeconfig(TestFrameEnv.KUBE_USERNAME, TestFrameEnv.KUBE_PASSWORD, TestFrameEnv.KUBE_URL); + createLocalOcKubeconfig(TestFrameEnv.KUBE_USERNAME, TestFrameEnv.KUBE_PASSWORD, + TestFrameEnv.KUBE_URL); } } else { if (TestFrameEnv.KUBE_URL != null && TestFrameEnv.KUBE_TOKEN != null) { createLocalKubectlContext(TestFrameEnv.KUBE_TOKEN, TestFrameEnv.KUBE_URL); } else { - createLocalKubectlContext(TestFrameEnv.KUBE_USERNAME, TestFrameEnv.KUBE_PASSWORD, TestFrameEnv.KUBE_URL); + createLocalKubectlContext(TestFrameEnv.KUBE_USERNAME, TestFrameEnv.KUBE_PASSWORD, + TestFrameEnv.KUBE_URL); } } return TestFrameEnv.USER_PATH + "/test.kubeconfig"; diff --git a/test-frame-common/src/main/java/io/skodjob/testframe/clients/cmdClient/BaseCmdKubeClient.java b/test-frame-common/src/main/java/io/skodjob/testframe/clients/cmdClient/BaseCmdKubeClient.java index f09c43a..2206bc1 100644 --- a/test-frame-common/src/main/java/io/skodjob/testframe/clients/cmdClient/BaseCmdKubeClient.java +++ b/test-frame-common/src/main/java/io/skodjob/testframe/clients/cmdClient/BaseCmdKubeClient.java @@ -4,12 +4,6 @@ */ package io.skodjob.testframe.clients.cmdClient; -import io.skodjob.testframe.clients.KubeClusterException; -import io.skodjob.testframe.executor.Exec; -import io.skodjob.testframe.executor.ExecResult; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.File; import java.nio.file.NoSuchFileException; import java.util.ArrayList; @@ -21,6 +15,12 @@ import java.util.function.Consumer; import java.util.stream.Collectors; +import io.skodjob.testframe.clients.KubeClusterException; +import io.skodjob.testframe.executor.Exec; +import io.skodjob.testframe.executor.ExecResult; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import static java.lang.String.join; import static java.util.Arrays.asList; @@ -89,7 +89,8 @@ public String getEvents() { @SuppressWarnings("unchecked") public K create(File... files) { try (Context context = defaultContext()) { - Map execResults = execRecursive(CREATE, files, Comparator.comparing(File::getName).reversed()); + Map execResults = execRecursive(CREATE, files, Comparator.comparing(File::getName) + .reversed()); for (Map.Entry entry : execResults.entrySet()) { if (!entry.getValue().exitStatus()) { LOGGER.warn("Failed to create {}!", entry.getKey().getAbsolutePath()); @@ -104,7 +105,8 @@ public K create(File... files) { @SuppressWarnings("unchecked") public K apply(File... files) { try (Context context = defaultContext()) { - Map execResults = execRecursive(APPLY, files, Comparator.comparing(File::getName).reversed()); + Map execResults = execRecursive(APPLY, files, Comparator.comparing(File::getName) + .reversed()); for (Map.Entry entry : execResults.entrySet()) { if (!entry.getValue().exitStatus()) { LOGGER.warn("Failed to apply {}!", entry.getKey().getAbsolutePath()); @@ -119,7 +121,8 @@ public K apply(File... files) { @SuppressWarnings("unchecked") public K delete(File... files) { try (Context context = defaultContext()) { - Map execResults = execRecursive(DELETE, files, Comparator.comparing(File::getName).reversed()); + Map execResults = execRecursive(DELETE, files, Comparator.comparing(File::getName) + .reversed()); for (Map.Entry entry : execResults.entrySet()) { if (!entry.getValue().exitStatus()) { LOGGER.warn("Failed to delete {}!", entry.getKey().getAbsolutePath()); @@ -135,7 +138,8 @@ private Map execRecursive(String subcommand, File[] files, Com for (File f : files) { if (f.isFile()) { if (f.getName().endsWith(".yaml")) { - execResults.put(f, Exec.exec(null, namespacedCommand(subcommand, "-f", f.getAbsolutePath()), 0, false, false)); + execResults.put(f, Exec.exec(null, namespacedCommand(subcommand, "-f", + f.getAbsolutePath()), 0, false, false)); } } else if (f.isDirectory()) { File[] children = f.listFiles(); @@ -187,7 +191,8 @@ public K deleteContentInNamespace(String yamlContent) { @SuppressWarnings("unchecked") public K applyContent(String yamlContent) { try (Context context = defaultContext()) { - Exec.exec(yamlContent, command(Arrays.asList(APPLY, "-f", "-"), false), 0, true, true); + Exec.exec(yamlContent, command(Arrays.asList(APPLY, "-f", "-"), false), 0, + true, true); return (K) this; } } @@ -196,7 +201,8 @@ public K applyContent(String yamlContent) { @SuppressWarnings("unchecked") public K deleteContent(String yamlContent) { try (Context context = defaultContext()) { - Exec.exec(yamlContent, command(Arrays.asList(DELETE, "-f", "-"), false), 0, true, false); + Exec.exec(yamlContent, command(Arrays.asList(DELETE, "-f", "-"), false), 0, + true, false); return (K) this; } } @@ -280,7 +286,9 @@ public String toString() { @Override public List list(String resourceType) { - return Arrays.stream(Exec.exec(namespacedCommand(GET, resourceType, "-o", "jsonpath={range .items[*]}{.metadata.name} ")).out().trim().split(" +")) + return Arrays.stream(Exec.exec(namespacedCommand(GET, resourceType, + "-o", "jsonpath={range .items[*]}{.metadata.name} ")) + .out().trim().split(" +")) .filter(s -> !s.trim().isEmpty()).collect(Collectors.toList()); } @@ -330,8 +338,10 @@ public String logs(String pod, String container) { @Override public String searchInLog(String resourceType, String resourceName, long sinceSeconds, String... grepPattern) { try { - return Exec.exec("bash", "-c", join(" ", namespacedCommand("logs", resourceType + "/" + resourceName, "--since=" + sinceSeconds + "s", - "|", "grep", " -e " + join(" -e ", grepPattern), "-B", "1"))).out(); + return Exec.exec("bash", "-c", join(" ", + namespacedCommand("logs", resourceType + "/" + resourceName, "--since=" + sinceSeconds + "s", + "|", "grep", " -e " + join(" -e ", grepPattern), "-B", "1"))) + .out(); } catch (KubeClusterException e) { if (e.result != null && e.result.returnCode() == 1) { LOGGER.info("{} not found", Arrays.stream(grepPattern).toList()); @@ -343,9 +353,11 @@ public String searchInLog(String resourceType, String resourceName, long sinceSe } @Override - public String searchInLog(String resourceType, String resourceName, String resourceContainer, long sinceSeconds, String... grepPattern) { + public String searchInLog(String resourceType, String resourceName, String resourceContainer, + long sinceSeconds, String... grepPattern) { try { - return Exec.exec("bash", "-c", join(" ", namespacedCommand("logs", resourceType + "/" + resourceName, "-c " + resourceContainer, "--since=" + sinceSeconds + "s", + return Exec.exec("bash", "-c", join(" ", namespacedCommand("logs", + resourceType + "/" + resourceName, "-c " + resourceContainer, "--since=" + sinceSeconds + "s", "|", "grep", " -e " + join(" -e ", grepPattern), "-B", "1"))).out(); } catch (KubeClusterException e) { if (e.result != null && e.result.exitStatus()) { @@ -359,7 +371,9 @@ public String searchInLog(String resourceType, String resourceName, String resou @Override public List listResourcesByLabel(String resourceType, String label) { - return asList(Exec.exec(namespacedCommand(GET, resourceType, "-l", label, "-o", "jsonpath={range .items[*]}{.metadata.name} ")).out().split("\\s+")); + return asList(Exec.exec(namespacedCommand(GET, resourceType, + "-l", label, "-o", "jsonpath={range .items[*]}{.metadata.name} ")) + .out().split("\\s+")); } private List command(List rest, boolean namespaced) { diff --git a/test-frame-common/src/main/java/io/skodjob/testframe/clients/cmdClient/KubeCmdClient.java b/test-frame-common/src/main/java/io/skodjob/testframe/clients/cmdClient/KubeCmdClient.java index f63349f..bd5a318 100644 --- a/test-frame-common/src/main/java/io/skodjob/testframe/clients/cmdClient/KubeCmdClient.java +++ b/test-frame-common/src/main/java/io/skodjob/testframe/clients/cmdClient/KubeCmdClient.java @@ -4,13 +4,13 @@ */ package io.skodjob.testframe.clients.cmdClient; -import io.skodjob.testframe.executor.ExecResult; - import java.io.File; import java.util.List; import java.util.Map; import java.util.function.Consumer; +import io.skodjob.testframe.executor.ExecResult; + import static java.util.Arrays.asList; import static java.util.stream.Collectors.toList; @@ -192,7 +192,8 @@ default String logs(String pod) { * @param grepPattern Grep patterns for search * @return Grep result as string */ - String searchInLog(String resourceType, String resourceName, String resourceContainer, long sinceSeconds, String... grepPattern); + String searchInLog(String resourceType, String resourceName, String resourceContainer, + long sinceSeconds, String... grepPattern); String getResourceAsJson(String resourceType, String resourceName); diff --git a/test-frame-common/src/main/java/io/skodjob/testframe/clients/cmdClient/Oc.java b/test-frame-common/src/main/java/io/skodjob/testframe/clients/cmdClient/Oc.java index 8295c69..79888f1 100644 --- a/test-frame-common/src/main/java/io/skodjob/testframe/clients/cmdClient/Oc.java +++ b/test-frame-common/src/main/java/io/skodjob/testframe/clients/cmdClient/Oc.java @@ -4,11 +4,11 @@ */ package io.skodjob.testframe.clients.cmdClient; -import io.skodjob.testframe.executor.Exec; - import java.util.List; import java.util.Map; +import io.skodjob.testframe.executor.Exec; + /** * A {@link KubeCmdClient} implementation wrapping {@code oc}. */ diff --git a/test-frame-common/src/main/java/io/skodjob/testframe/executor/Exec.java b/test-frame-common/src/main/java/io/skodjob/testframe/executor/Exec.java index 2048bb8..d114cdb 100644 --- a/test-frame-common/src/main/java/io/skodjob/testframe/executor/Exec.java +++ b/test-frame-common/src/main/java/io/skodjob/testframe/executor/Exec.java @@ -4,11 +4,6 @@ */ package io.skodjob.testframe.executor; -import io.fabric8.kubernetes.api.model.EnvVar; -import io.skodjob.testframe.clients.KubeClusterException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -33,6 +28,11 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import io.fabric8.kubernetes.api.model.EnvVar; +import io.skodjob.testframe.clients.KubeClusterException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import static java.lang.String.join; public class Exec { @@ -163,7 +163,8 @@ public static ExecResult exec(String input, List command, int timeout, b * @param throwErrors throw error if exec fail * @return results */ - public static ExecResult exec(String input, List command, int timeout, boolean logToOutput, boolean throwErrors) { + public static ExecResult exec(String input, List command, int timeout, boolean logToOutput, + boolean throwErrors) { return exec(input, command, Collections.emptySet(), timeout, logToOutput, throwErrors); } @@ -178,7 +179,8 @@ public static ExecResult exec(String input, List command, int timeout, b * @param throwErrors look for errors in output and throws exception if true * @return execution results */ - public static ExecResult exec(String input, List command, Set envVars, int timeout, boolean logToOutput, boolean throwErrors) { + public static ExecResult exec(String input, List command, Set envVars, int timeout, + boolean logToOutput, boolean throwErrors) { int ret = 1; ExecResult execResult; try { @@ -204,7 +206,9 @@ public static ExecResult exec(String input, List command, Set en execResult = new ExecResult(ret, executor.out(), executor.err()); if (throwErrors && ret != 0) { - String msg = "`" + join(" ", command) + "` got status code " + ret + " and stderr:\n------\n" + executor.stdErr + "\n------\nand stdout:\n------\n" + executor.stdOut + "\n------"; + String msg = "`" + join(" ", command) + "` got status code " + ret + + " and stderr:\n------\n" + executor.stdErr + + "\n------\nand stdout:\n------\n" + executor.stdOut + "\n------"; Matcher matcher = ERROR_PATTERN.matcher(executor.err()); KubeClusterException t = null; @@ -251,7 +255,8 @@ public static ExecResult exec(String input, List command, Set en * @throws InterruptedException * @throws ExecutionException */ - public int execute(String input, List commands, Set envVars, long timeoutMs) throws IOException, InterruptedException, ExecutionException { + public int execute(String input, List commands, Set envVars, long timeoutMs) + throws IOException, InterruptedException, ExecutionException { LOGGER.trace("Running command - " + join(" ", commands.toArray(new String[0]))); ProcessBuilder builder = new ProcessBuilder(); builder.command(commands); @@ -368,7 +373,8 @@ public static boolean isExecutableOnPath(String cmd) { */ public static String cutExecutorLog(String log) { if (log.length() > MAXIMUM_EXEC_LOG_CHARACTER_SIZE) { - LOGGER.warn("Executor log is too long. Going to strip it and print only first {} characters", MAXIMUM_EXEC_LOG_CHARACTER_SIZE); + LOGGER.warn("Executor log is too long. Going to strip it and print only first {} characters", + MAXIMUM_EXEC_LOG_CHARACTER_SIZE); return log.substring(0, MAXIMUM_EXEC_LOG_CHARACTER_SIZE); } return log; diff --git a/test-frame-common/src/main/java/io/skodjob/testframe/executor/ExecBuilder.java b/test-frame-common/src/main/java/io/skodjob/testframe/executor/ExecBuilder.java index 1c0e0c6..eb04b38 100644 --- a/test-frame-common/src/main/java/io/skodjob/testframe/executor/ExecBuilder.java +++ b/test-frame-common/src/main/java/io/skodjob/testframe/executor/ExecBuilder.java @@ -4,12 +4,12 @@ */ package io.skodjob.testframe.executor; -import io.fabric8.kubernetes.api.model.EnvVar; - import java.util.Arrays; import java.util.List; import java.util.Set; +import io.fabric8.kubernetes.api.model.EnvVar; + public class ExecBuilder { private String input; diff --git a/test-frame-common/src/main/java/io/skodjob/testframe/interfaces/NamespacedResourceType.java b/test-frame-common/src/main/java/io/skodjob/testframe/interfaces/NamespacedResourceType.java index aa94d1a..3f5116c 100644 --- a/test-frame-common/src/main/java/io/skodjob/testframe/interfaces/NamespacedResourceType.java +++ b/test-frame-common/src/main/java/io/skodjob/testframe/interfaces/NamespacedResourceType.java @@ -4,11 +4,11 @@ */ package io.skodjob.testframe.interfaces; +import java.util.function.Consumer; + import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.client.dsl.MixedOperation; -import java.util.function.Consumer; - public interface NamespacedResourceType extends ResourceType { /** diff --git a/test-frame-common/src/main/java/io/skodjob/testframe/interfaces/ResourceType.java b/test-frame-common/src/main/java/io/skodjob/testframe/interfaces/ResourceType.java index b5f57d8..4a74be5 100644 --- a/test-frame-common/src/main/java/io/skodjob/testframe/interfaces/ResourceType.java +++ b/test-frame-common/src/main/java/io/skodjob/testframe/interfaces/ResourceType.java @@ -4,11 +4,11 @@ */ package io.skodjob.testframe.interfaces; +import java.util.function.Consumer; + import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation; -import java.util.function.Consumer; - /** * Class for encapsulating methods related to {@link T} resource. * @param resource type diff --git a/test-frame-common/src/main/java/io/skodjob/testframe/listeners/ResourceManagerExtension.java b/test-frame-common/src/main/java/io/skodjob/testframe/listeners/ResourceManagerExtension.java index dd63118..6f267cd 100644 --- a/test-frame-common/src/main/java/io/skodjob/testframe/listeners/ResourceManagerExtension.java +++ b/test-frame-common/src/main/java/io/skodjob/testframe/listeners/ResourceManagerExtension.java @@ -14,26 +14,27 @@ /** * jUnit5 specific class which listening on test callbacks */ -public class ResourceManagerExtension implements BeforeAllCallback, BeforeEachCallback, AfterAllCallback, AfterEachCallback { +public class ResourceManagerExtension + implements BeforeAllCallback, BeforeEachCallback, AfterAllCallback, AfterEachCallback { @Override - public void beforeAll(ExtensionContext extensionContext) throws Exception { + public void beforeAll(ExtensionContext extensionContext) { ResourceManager.getInstance(); ResourceManager.setTestContext(extensionContext); } @Override - public void beforeEach(ExtensionContext extensionContext) throws Exception { + public void beforeEach(ExtensionContext extensionContext) { ResourceManager.setTestContext(extensionContext); } @Override - public void afterAll(ExtensionContext extensionContext) throws Exception { + public void afterAll(ExtensionContext extensionContext) { ResourceManager.setTestContext(extensionContext); } @Override - public void afterEach(ExtensionContext extensionContext) throws Exception { + public void afterEach(ExtensionContext extensionContext) { ResourceManager.setTestContext(extensionContext); } } diff --git a/test-frame-common/src/main/java/io/skodjob/testframe/listeners/TestVisualSeparatorExtension.java b/test-frame-common/src/main/java/io/skodjob/testframe/listeners/TestVisualSeparatorExtension.java index 3806df4..b25f5fa 100644 --- a/test-frame-common/src/main/java/io/skodjob/testframe/listeners/TestVisualSeparatorExtension.java +++ b/test-frame-common/src/main/java/io/skodjob/testframe/listeners/TestVisualSeparatorExtension.java @@ -15,17 +15,17 @@ * jUnit5 specific class which listening on test callbacks */ public class TestVisualSeparatorExtension implements BeforeEachCallback, AfterEachCallback { - Logger LOGGER = LoggerFactory.getLogger(TestVisualSeparatorExtension.class); + private final Logger logger = LoggerFactory.getLogger(TestVisualSeparatorExtension.class); @Override - public void beforeEach(ExtensionContext extensionContext) throws Exception { + public void beforeEach(ExtensionContext extensionContext) { LoggerUtils.logSeparator(); - LOGGER.info(String.format("%s.%s-STARTED", extensionContext.getRequiredTestClass().getName(), + logger.info(String.format("%s.%s-STARTED", extensionContext.getRequiredTestClass().getName(), extensionContext.getDisplayName().replace("()", ""))); } @Override - public void afterEach(ExtensionContext extensionContext) throws Exception { - LOGGER.info(String.format("%s.%s-FINISHED", extensionContext.getRequiredTestClass().getName(), + public void afterEach(ExtensionContext extensionContext) { + logger.info(String.format("%s.%s-FINISHED", extensionContext.getRequiredTestClass().getName(), extensionContext.getDisplayName().replace("()", ""))); LoggerUtils.logSeparator(); } diff --git a/test-frame-common/src/main/java/io/skodjob/testframe/resources/ResourceCondition.java b/test-frame-common/src/main/java/io/skodjob/testframe/resources/ResourceCondition.java index 7c3b654..17331c6 100644 --- a/test-frame-common/src/main/java/io/skodjob/testframe/resources/ResourceCondition.java +++ b/test-frame-common/src/main/java/io/skodjob/testframe/resources/ResourceCondition.java @@ -5,14 +5,12 @@ package io.skodjob.testframe.resources; -import io.fabric8.kubernetes.api.model.HasMetadata; -import io.fabric8.kubernetes.api.model.KubernetesResourceList; -import io.fabric8.kubernetes.client.dsl.Resource; -import io.skodjob.testframe.interfaces.ResourceType; - import java.util.Objects; import java.util.function.Predicate; +import io.fabric8.kubernetes.api.model.HasMetadata; +import io.skodjob.testframe.interfaces.ResourceType; + public class ResourceCondition { private final Predicate predicate; private final String conditionName; diff --git a/test-frame-common/src/main/java/io/skodjob/testframe/resources/ResourceManager.java b/test-frame-common/src/main/java/io/skodjob/testframe/resources/ResourceManager.java index 778cf68..c1b5b85 100644 --- a/test-frame-common/src/main/java/io/skodjob/testframe/resources/ResourceManager.java +++ b/test-frame-common/src/main/java/io/skodjob/testframe/resources/ResourceManager.java @@ -4,6 +4,11 @@ */ package io.skodjob.testframe.resources; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Stack; +import java.util.concurrent.atomic.AtomicInteger; + import io.fabric8.kubernetes.api.model.HasMetadata; import io.skodjob.testframe.LoggerUtils; import io.skodjob.testframe.TestFrameConstants; @@ -18,11 +23,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Stack; -import java.util.concurrent.atomic.AtomicInteger; - import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -111,7 +111,8 @@ private void createResource(boolean waitReady, T... reso "Creating", resource.getKind(), resource.getMetadata().getName()); } else { LOGGER.info(LoggerUtils.RESOURCE_WITH_NAMESPACE_LOGGER_PATTERN, - "Creating", resource.getKind(), resource.getMetadata().getName(), resource.getMetadata().getNamespace()); + "Creating", resource.getKind(), resource.getMetadata().getName(), + resource.getMetadata().getNamespace()); } if (type == null) { @@ -125,14 +126,16 @@ private void createResource(boolean waitReady, T... reso return client.getClient().resource(resource) != null; } }, "ready")), - String.format("Timed out waiting for %s/%s in %s to be ready", resource.getKind(), resource.getMetadata().getName(), resource.getMetadata().getNamespace())); + String.format("Timed out waiting for %s/%s in %s to be ready", resource.getKind(), + resource.getMetadata().getName(), resource.getMetadata().getNamespace())); } } else { // Create for typed resource implementing ResourceType type.create(resource); if (waitReady) { assertTrue(waitResourceCondition(resource, ResourceCondition.readiness(type)), - String.format("Timed out waiting for %s/%s in %s to be ready", resource.getKind(), resource.getMetadata().getName(), resource.getMetadata().getNamespace())); + String.format("Timed out waiting for %s/%s in %s to be ready", resource.getKind(), + resource.getMetadata().getName(), resource.getMetadata().getNamespace())); } } } @@ -147,23 +150,28 @@ public final void deleteResource(T... resources) { "Deleting", resource.getKind(), resource.getMetadata().getName()); } else { LOGGER.info(LoggerUtils.RESOURCE_WITH_NAMESPACE_LOGGER_PATTERN, - "Deleting", resource.getKind(), resource.getMetadata().getName(), resource.getMetadata().getNamespace()); + "Deleting", resource.getKind(), resource.getMetadata().getName(), + resource.getMetadata().getNamespace()); } try { if (type == null) { client.getClient().resource(resource).delete(); assertTrue(waitResourceCondition(resource, ResourceCondition.deletion()), - String.format("Timed out deleting %s/%s in %s", resource.getKind(), resource.getMetadata().getName(), resource.getMetadata().getNamespace())); + String.format("Timed out deleting %s/%s in %s", resource.getKind(), + resource.getMetadata().getName(), resource.getMetadata().getNamespace())); } else { type.delete(resource.getMetadata().getName()); assertTrue(waitResourceCondition(resource, ResourceCondition.deletion()), - String.format("Timed out deleting %s/%s in %s", resource.getKind(), resource.getMetadata().getName(), resource.getMetadata().getNamespace())); + String.format("Timed out deleting %s/%s in %s", resource.getKind(), + resource.getMetadata().getName(), resource.getMetadata().getNamespace())); } } catch (Exception e) { if (resource.getMetadata().getNamespace() == null) { - LOGGER.error(LoggerUtils.RESOURCE_LOGGER_PATTERN, "Deleting", resource.getKind(), resource.getMetadata().getName(), e); + LOGGER.error(LoggerUtils.RESOURCE_LOGGER_PATTERN, "Deleting", resource.getKind(), + resource.getMetadata().getName(), e); } else { - LOGGER.error(LoggerUtils.RESOURCE_WITH_NAMESPACE_LOGGER_PATTERN, "Deleting", resource.getKind(), resource.getMetadata().getName(), resource.getMetadata().getNamespace(), e); + LOGGER.error(LoggerUtils.RESOURCE_WITH_NAMESPACE_LOGGER_PATTERN, "Deleting",resource.getKind(), + resource.getMetadata().getName(), resource.getMetadata().getNamespace(), e); } } } @@ -177,7 +185,8 @@ public final void updateResource(T... resources) { "Updating", resource.getKind(), resource.getMetadata().getName()); } else { LOGGER.info(LoggerUtils.RESOURCE_WITH_NAMESPACE_LOGGER_PATTERN, - "Updating", resource.getKind(), resource.getMetadata().getName(), resource.getMetadata().getNamespace()); + "Updating", resource.getKind(), resource.getMetadata().getName(), + resource.getMetadata().getNamespace()); } ResourceType type = findResourceType(resource); if (type != null) { @@ -196,7 +205,8 @@ public final boolean waitResourceCondition(T resource, R ResourceType type = findResourceType(resource); boolean[] resourceReady = new boolean[1]; - Wait.until(String.format("Resource condition: %s to be fulfilled for resource %s/%s", condition.getConditionName(), resource.getKind(), resource.getMetadata().getName()), + Wait.until(String.format("Resource condition: %s to be fulfilled for resource %s/%s", + condition.getConditionName(), resource.getKind(), resource.getMetadata().getName()), TestFrameConstants.GLOBAL_POLL_INTERVAL_MEDIUM, TestFrameConstants.GLOBAL_TIMEOUT, () -> { T res = getKubeClient().getClient().resource(resource).get(); @@ -216,7 +226,8 @@ public final boolean waitResourceCondition(T resource, R public void deleteResources() { LoggerUtils.logSeparator(); - if (!STORED_RESOURCES.containsKey(getTestContext().getDisplayName()) || STORED_RESOURCES.get(getTestContext().getDisplayName()).isEmpty()) { + if (!STORED_RESOURCES.containsKey(getTestContext().getDisplayName()) + || STORED_RESOURCES.get(getTestContext().getDisplayName()).isEmpty()) { LOGGER.info("In context {} is everything deleted", getTestContext().getDisplayName()); } else { LOGGER.info("Deleting all resources for {}", getTestContext().getDisplayName()); diff --git a/test-frame-common/src/main/java/io/skodjob/testframe/utils/TestFrameUtils.java b/test-frame-common/src/main/java/io/skodjob/testframe/utils/TestFrameUtils.java index 88d36d5..25cbf79 100644 --- a/test-frame-common/src/main/java/io/skodjob/testframe/utils/TestFrameUtils.java +++ b/test-frame-common/src/main/java/io/skodjob/testframe/utils/TestFrameUtils.java @@ -4,30 +4,17 @@ */ package io.skodjob.testframe.utils; +import java.io.IOException; +import java.io.InputStream; +import java.util.concurrent.Callable; +import java.util.concurrent.TimeUnit; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.exc.InvalidFormatException; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import io.skodjob.testframe.wait.WaitException; -import org.junit.jupiter.api.TestInfo; -import org.junit.jupiter.api.extension.ExtensionContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.time.Duration; -import java.util.concurrent.Callable; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.function.BooleanSupplier; - @SuppressWarnings({"checkstyle:ClassFanOutComplexity"}) public final class TestFrameUtils { diff --git a/test-frame-common/src/main/java/io/skodjob/testframe/wait/Wait.java b/test-frame-common/src/main/java/io/skodjob/testframe/wait/Wait.java index 803ae93..db60bc8 100644 --- a/test-frame-common/src/main/java/io/skodjob/testframe/wait/Wait.java +++ b/test-frame-common/src/main/java/io/skodjob/testframe/wait/Wait.java @@ -4,10 +4,6 @@ */ package io.skodjob.testframe.wait; -import io.skodjob.testframe.LoggerUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.PrintWriter; import java.io.StringWriter; import java.time.Duration; @@ -20,6 +16,9 @@ import java.util.concurrent.TimeoutException; import java.util.function.BooleanSupplier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class Wait { private static final Logger LOGGER = LoggerFactory.getLogger(Wait.class); @@ -51,9 +50,11 @@ public static void until(String description, long pollIntervalMs, long timeoutMs * @param timeoutMs timeout specified in milliseconds * @param ready {@link BooleanSupplier} containing code, which should be executed each poll, verifying readiness * of the particular thing - * @param onTimeout {@link Runnable} executed once timeout is reached and before the {@link WaitException} is thrown. + * @param onTimeout {@link Runnable} executed once timeout is reached and + * before the {@link WaitException} is thrown. */ - public static void until(String description, long pollIntervalMs, long timeoutMs, BooleanSupplier ready, Runnable onTimeout) { + public static void until(String description, long pollIntervalMs, long timeoutMs, BooleanSupplier ready, + Runnable onTimeout) { System.out.println("Waiting for " + description); long deadline = System.currentTimeMillis() + timeoutMs; @@ -62,7 +63,8 @@ public static void until(String description, long pollIntervalMs, long timeoutMs // in case we are polling every 1s, we want to print exception after x tries, not on the first try // for minutes poll interval will 2 be enough - int exceptionAppearanceCount = Duration.ofMillis(pollIntervalMs).toMinutes() > 0 ? 2 : Math.max((int) (timeoutMs / pollIntervalMs) / 4, 2); + int exceptionAppearanceCount = Duration.ofMillis(pollIntervalMs).toMinutes() > 0 + ? 2 : Math.max((int) (timeoutMs / pollIntervalMs) / 4, 2); int exceptionCount = 0; int newExceptionAppearance = 0; @@ -75,11 +77,13 @@ public static void until(String description, long pollIntervalMs, long timeoutMs } catch (Exception e) { exceptionMessage = e.getMessage(); - if (++exceptionCount == exceptionAppearanceCount && exceptionMessage != null && exceptionMessage.equals(previousExceptionMessage)) { + if (++exceptionCount == exceptionAppearanceCount && exceptionMessage != null + && exceptionMessage.equals(previousExceptionMessage)) { System.out.println("While waiting for " + description + " exception occurred: " + exceptionMessage); // log the stacktrace e.printStackTrace(new PrintWriter(stackTraceError)); - } else if (exceptionMessage != null && !exceptionMessage.equals(previousExceptionMessage) && ++newExceptionAppearance == 2) { + } else if (exceptionMessage != null && !exceptionMessage.equals(previousExceptionMessage) + && ++newExceptionAppearance == 2) { previousExceptionMessage = exceptionMessage; } @@ -99,7 +103,8 @@ public static void until(String description, long pollIntervalMs, long timeoutMs } } onTimeout.run(); - WaitException waitException = new WaitException("Timeout after " + timeoutMs + " ms waiting for " + description); + WaitException waitException = new WaitException("Timeout after " + timeoutMs + + " ms waiting for " + description); waitException.printStackTrace(); throw waitException; } @@ -136,7 +141,8 @@ public Thread newThread(Runnable r) { * @param ready {@link BooleanSupplier} containing code, which should be executed each poll, verifying readiness * of the particular thing */ - public static CompletableFuture untilAsync(String description, long pollIntervalMs, long timeoutMs, BooleanSupplier ready) { + public static CompletableFuture untilAsync(String description, long pollIntervalMs, + long timeoutMs, BooleanSupplier ready) { LOGGER.info("Waiting for {}", description); long deadline = System.currentTimeMillis() + timeoutMs; CompletableFuture future = new CompletableFuture<>(); @@ -160,7 +166,8 @@ public void run() { } delayed.execute(this); } else { - future.completeExceptionally(new TimeoutException(String.format("Waiting for %s timeout %s exceeded", description, timeoutMs))); + future.completeExceptionally(new TimeoutException( + String.format("Waiting for %s timeout %s exceeded", description, timeoutMs))); } } else { future.complete(null); diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ClusterRoleBindingResource.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ClusterRoleBindingResource.java index 969bc8c..f0ecf15 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ClusterRoleBindingResource.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ClusterRoleBindingResource.java @@ -4,17 +4,18 @@ */ package io.skodjob.testframe.resources; +import java.util.function.Consumer; + import io.fabric8.kubernetes.api.model.rbac.ClusterRoleBinding; import io.fabric8.kubernetes.api.model.rbac.ClusterRoleBindingList; import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation; import io.fabric8.kubernetes.client.dsl.Resource; import io.skodjob.testframe.interfaces.ResourceType; -import java.util.function.Consumer; - public class ClusterRoleBindingResource implements ResourceType { - private final NonNamespaceOperation> client; + private final NonNamespaceOperation> client; public ClusterRoleBindingResource() { this.client = ResourceManager.getKubeClient().getClient().rbac().clusterRoleBindings(); diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ClusterRoleResource.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ClusterRoleResource.java index e773323..ad9ba31 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ClusterRoleResource.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ClusterRoleResource.java @@ -4,14 +4,14 @@ */ package io.skodjob.testframe.resources; +import java.util.function.Consumer; + import io.fabric8.kubernetes.api.model.rbac.ClusterRole; import io.fabric8.kubernetes.api.model.rbac.ClusterRoleList; import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation; import io.fabric8.kubernetes.client.dsl.Resource; import io.skodjob.testframe.interfaces.ResourceType; -import java.util.function.Consumer; - public class ClusterRoleResource implements ResourceType { private final NonNamespaceOperation> client; diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ConfigMapResource.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ConfigMapResource.java index f449f85..403036c 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ConfigMapResource.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ConfigMapResource.java @@ -4,14 +4,14 @@ */ package io.skodjob.testframe.resources; +import java.util.function.Consumer; + import io.fabric8.kubernetes.api.model.ConfigMap; import io.fabric8.kubernetes.api.model.ConfigMapList; import io.fabric8.kubernetes.client.dsl.MixedOperation; import io.fabric8.kubernetes.client.dsl.Resource; import io.skodjob.testframe.interfaces.NamespacedResourceType; -import java.util.function.Consumer; - public class ConfigMapResource implements NamespacedResourceType { private final MixedOperation> client; diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/CustomResourceDefinitionResource.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/CustomResourceDefinitionResource.java index f9608d5..1a7c00f 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/CustomResourceDefinitionResource.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/CustomResourceDefinitionResource.java @@ -4,17 +4,18 @@ */ package io.skodjob.testframe.resources; +import java.util.function.Consumer; + import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition; import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionList; import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation; import io.fabric8.kubernetes.client.dsl.Resource; import io.skodjob.testframe.interfaces.ResourceType; -import java.util.function.Consumer; - public class CustomResourceDefinitionResource implements ResourceType { - private final NonNamespaceOperation> client; + private final NonNamespaceOperation> client; public CustomResourceDefinitionResource() { this.client = ResourceManager.getKubeClient().getClient().apiextensions().v1().customResourceDefinitions(); diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/DeploymentResource.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/DeploymentResource.java index 4bde6b2..fb5a063 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/DeploymentResource.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/DeploymentResource.java @@ -4,14 +4,14 @@ */ package io.skodjob.testframe.resources; +import java.util.function.Consumer; + import io.fabric8.kubernetes.api.model.apps.Deployment; import io.fabric8.kubernetes.api.model.apps.DeploymentList; import io.fabric8.kubernetes.client.dsl.MixedOperation; import io.fabric8.kubernetes.client.dsl.RollableScalableResource; import io.skodjob.testframe.interfaces.NamespacedResourceType; -import java.util.function.Consumer; - public class DeploymentResource implements NamespacedResourceType { private final MixedOperation> client; diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/JobResource.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/JobResource.java index 6e23c76..ce65161 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/JobResource.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/JobResource.java @@ -4,14 +4,14 @@ */ package io.skodjob.testframe.resources; +import java.util.function.Consumer; + import io.fabric8.kubernetes.api.model.batch.v1.Job; import io.fabric8.kubernetes.api.model.batch.v1.JobList; import io.fabric8.kubernetes.client.dsl.MixedOperation; import io.fabric8.kubernetes.client.dsl.ScalableResource; import io.skodjob.testframe.interfaces.NamespacedResourceType; -import java.util.function.Consumer; - public class JobResource implements NamespacedResourceType { private final MixedOperation> client; diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/LeaseResource.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/LeaseResource.java index 53545d4..5268893 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/LeaseResource.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/LeaseResource.java @@ -4,14 +4,14 @@ */ package io.skodjob.testframe.resources; +import java.util.function.Consumer; + import io.fabric8.kubernetes.api.model.coordination.v1.Lease; import io.fabric8.kubernetes.api.model.coordination.v1.LeaseList; import io.fabric8.kubernetes.client.dsl.MixedOperation; import io.fabric8.kubernetes.client.dsl.Resource; import io.skodjob.testframe.interfaces.NamespacedResourceType; -import java.util.function.Consumer; - public class LeaseResource implements NamespacedResourceType { private MixedOperation> client; diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/NamespaceResource.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/NamespaceResource.java index 2c3cdf6..659d206 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/NamespaceResource.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/NamespaceResource.java @@ -4,15 +4,15 @@ */ package io.skodjob.testframe.resources; +import java.util.function.Consumer; + +import io.fabric8.kubernetes.api.model.Namespace; import io.fabric8.kubernetes.api.model.NamespaceBuilder; import io.fabric8.kubernetes.api.model.NamespaceList; -import io.fabric8.kubernetes.api.model.Namespace; import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation; import io.fabric8.kubernetes.client.dsl.Resource; import io.skodjob.testframe.interfaces.ResourceType; -import java.util.function.Consumer; - public class NamespaceResource implements ResourceType { private final NonNamespaceOperation> client; diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/NetworkPolicyResource.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/NetworkPolicyResource.java index 7efc810..6826ee9 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/NetworkPolicyResource.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/NetworkPolicyResource.java @@ -4,14 +4,14 @@ */ package io.skodjob.testframe.resources; +import java.util.function.Consumer; + import io.fabric8.kubernetes.api.model.networking.v1.NetworkPolicy; import io.fabric8.kubernetes.api.model.networking.v1.NetworkPolicyList; import io.fabric8.kubernetes.client.dsl.MixedOperation; import io.fabric8.kubernetes.client.dsl.Resource; import io.skodjob.testframe.interfaces.NamespacedResourceType; -import java.util.function.Consumer; - public class NetworkPolicyResource implements NamespacedResourceType { private final MixedOperation> client; diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/RoleBindingResource.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/RoleBindingResource.java index 5ef88f7..06626ba 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/RoleBindingResource.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/RoleBindingResource.java @@ -4,14 +4,14 @@ */ package io.skodjob.testframe.resources; +import java.util.function.Consumer; + import io.fabric8.kubernetes.api.model.rbac.RoleBinding; import io.fabric8.kubernetes.api.model.rbac.RoleBindingList; import io.fabric8.kubernetes.client.dsl.MixedOperation; import io.fabric8.kubernetes.client.dsl.Resource; import io.skodjob.testframe.interfaces.NamespacedResourceType; -import java.util.function.Consumer; - public class RoleBindingResource implements NamespacedResourceType { private final MixedOperation> client; diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/RoleResource.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/RoleResource.java index 51dfe8d..3124af9 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/RoleResource.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/RoleResource.java @@ -4,14 +4,14 @@ */ package io.skodjob.testframe.resources; +import java.util.function.Consumer; + import io.fabric8.kubernetes.api.model.rbac.Role; import io.fabric8.kubernetes.api.model.rbac.RoleList; import io.fabric8.kubernetes.client.dsl.MixedOperation; import io.fabric8.kubernetes.client.dsl.Resource; import io.skodjob.testframe.interfaces.NamespacedResourceType; -import java.util.function.Consumer; - public class RoleResource implements NamespacedResourceType { private final MixedOperation> client; diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/SecretResource.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/SecretResource.java index cd60dc6..ca4e145 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/SecretResource.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/SecretResource.java @@ -4,14 +4,14 @@ */ package io.skodjob.testframe.resources; +import java.util.function.Consumer; + import io.fabric8.kubernetes.api.model.Secret; import io.fabric8.kubernetes.api.model.SecretList; import io.fabric8.kubernetes.client.dsl.MixedOperation; import io.fabric8.kubernetes.client.dsl.Resource; import io.skodjob.testframe.interfaces.NamespacedResourceType; -import java.util.function.Consumer; - public class SecretResource implements NamespacedResourceType { private final MixedOperation> client; diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ServiceAccountResource.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ServiceAccountResource.java index 0369347..d14d8a0 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ServiceAccountResource.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ServiceAccountResource.java @@ -4,14 +4,14 @@ */ package io.skodjob.testframe.resources; +import java.util.function.Consumer; + import io.fabric8.kubernetes.api.model.ServiceAccount; import io.fabric8.kubernetes.api.model.ServiceAccountList; import io.fabric8.kubernetes.client.dsl.MixedOperation; import io.fabric8.kubernetes.client.dsl.Resource; import io.skodjob.testframe.interfaces.NamespacedResourceType; -import java.util.function.Consumer; - public class ServiceAccountResource implements NamespacedResourceType { private final MixedOperation> client; diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ServiceResource.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ServiceResource.java index 6912b6f..318e8af 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ServiceResource.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ServiceResource.java @@ -4,16 +4,17 @@ */ package io.skodjob.testframe.resources; +import java.util.function.Consumer; + import io.fabric8.kubernetes.api.model.Service; import io.fabric8.kubernetes.api.model.ServiceList; import io.fabric8.kubernetes.client.dsl.MixedOperation; import io.skodjob.testframe.interfaces.NamespacedResourceType; -import java.util.function.Consumer; - public class ServiceResource implements NamespacedResourceType { - private final MixedOperation> client; + private final MixedOperation> client; public ServiceResource() { this.client = ResourceManager.getKubeClient().getClient().services(); diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ValidatingWebhookConfigurationResource.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ValidatingWebhookConfigurationResource.java index 5af8e1d..e357f7a 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ValidatingWebhookConfigurationResource.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ValidatingWebhookConfigurationResource.java @@ -4,21 +4,25 @@ */ package io.skodjob.testframe.resources; +import java.util.function.Consumer; + import io.fabric8.kubernetes.api.model.admissionregistration.v1.ValidatingWebhookConfiguration; import io.fabric8.kubernetes.api.model.admissionregistration.v1.ValidatingWebhookConfigurationList; import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation; import io.fabric8.kubernetes.client.dsl.Resource; import io.skodjob.testframe.interfaces.ResourceType; -import java.util.function.Consumer; - public class ValidatingWebhookConfigurationResource implements ResourceType { - private final NonNamespaceOperation> client; + private final NonNamespaceOperation> client; public ValidatingWebhookConfigurationResource() { - this.client = ResourceManager.getKubeClient().getClient().admissionRegistration().v1().validatingWebhookConfigurations(); + this.client = ResourceManager.getKubeClient().getClient() + .admissionRegistration() + .v1() + .validatingWebhookConfigurations(); } /**