Skip to content

Commit

Permalink
Clean redundant code in unit test and reuse separator iterface
Browse files Browse the repository at this point in the history
  • Loading branch information
kornys committed Dec 7, 2023
1 parent 2cd80f9 commit 7fd1973
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ public interface TestVisualSeparator {
@BeforeEach
default void beforeEachTest(ExtensionContext testContext) {
LOGGER.info(String.join("", Collections.nCopies(76, SEPARATOR_CHAR)));
LOGGER.info(String.format("%s.%s-STARTED", testContext.getRequiredTestClass().getName(), testContext.getDisplayName()));
LOGGER.info(String.format("%s.%s-STARTED", testContext.getRequiredTestClass().getName(),
testContext.getDisplayName().replace("()", "")));
}

@AfterEach
default void afterEachTest(ExtensionContext testContext) {
LOGGER.info(String.format("%s.%s-FINISHED", testContext.getRequiredTestClass().getName(), testContext.getDisplayName()));
LOGGER.info(String.format("%s.%s-FINISHED", testContext.getRequiredTestClass().getName(),
testContext.getDisplayName().replace("()", "")));
LOGGER.info(String.join("", Collections.nCopies(76, SEPARATOR_CHAR)));
}
}
28 changes: 2 additions & 26 deletions src/test/java/io/odh/test/unit/UnitTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,17 @@
import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient;
import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer;
import io.odh.test.framework.ExtensionContextParameterResolver;
import io.odh.test.framework.listeners.TestVisualSeparator;
import io.opendatahub.datasciencecluster.v1.DataScienceCluster;
import io.opendatahub.datasciencecluster.v1.DataScienceClusterBuilder;
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.ComponentsBuilder;
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.Codeflare;
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.CodeflareBuilder;
import io.opendatahub.v1alpha.OdhDashboardConfig;
import io.opendatahub.v1alpha.OdhDashboardConfigBuilder;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Collections;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
Expand All @@ -36,30 +30,12 @@
@Tag("unit")
@ExtendWith(ExtensionContextParameterResolver.class)
@EnableKubernetesMockClient(crud = true)
public class UnitTests {

static final Logger LOGGER = LoggerFactory.getLogger(UnitTests.class);

static final String SEPARATOR_CHAR = "#";
public class UnitTests implements TestVisualSeparator {

private KubernetesClient kubernetesClient;

private KubernetesMockServer server;

@BeforeEach
void before(ExtensionContext extensionContext) {
LOGGER.info(String.join("", Collections.nCopies(76, SEPARATOR_CHAR)));
LOGGER.info(String.format("%s.%s-STARTED", extensionContext.getRequiredTestClass().getName(),
extensionContext.getDisplayName().replace("()", "")));
}

@AfterEach
void after(ExtensionContext extensionContext) {
LOGGER.info(String.format("%s.%s-FINISHED", extensionContext.getRequiredTestClass().getName(),
extensionContext.getDisplayName().replace("()", "")));
LOGGER.info(String.join("", Collections.nCopies(76, SEPARATOR_CHAR)));
}

@Test
void testCreateDeleteDataScienceCluster() {
MixedOperation<DataScienceCluster, KubernetesResourceList<DataScienceCluster>, Resource<DataScienceCluster>> dsClient =
Expand Down

0 comments on commit 7fd1973

Please sign in to comment.