Skip to content

Commit

Permalink
chore(jkube-kit-enricher-api): Removed org.mockito.Mockito references…
Browse files Browse the repository at this point in the history
… from JKubeEnricherContextTest
  • Loading branch information
ShantKhatri committed Feb 5, 2024
1 parent da9fa85 commit 9957773
Showing 1 changed file with 21 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.eclipse.jkube.kit.config.image.ImageConfiguration;
import org.eclipse.jkube.kit.config.image.build.JKubeBuildStrategy;
import org.eclipse.jkube.kit.config.resource.ResourceConfig;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;

Expand All @@ -35,6 +36,16 @@
import static org.mockito.Mockito.mockStatic;

class JKubeEnricherContextTest {

private JavaProject javaProject;

@BeforeEach
void setUp() {
javaProject = JavaProject.builder()
.groupId("org.eclipse.jkube").artifactId("test-project").version("0.0.1")
.build();
}

@Test
void builder_whenInvoked_shouldConstructJKubeEnricherContext() {
// Given + When
Expand All @@ -61,9 +72,7 @@ void builder_whenInvoked_shouldConstructJKubeEnricherContext() {
void getGav_whenInvoked_shouldReturnExpectedGroupArtifactVersion() {
// Given + When
JKubeEnricherContext jKubeEnricherContext = JKubeEnricherContext.builder()
.project(JavaProject.builder()
.groupId("org.eclipse.jkube").artifactId("test-project").version("0.0.1")
.build())
.project(javaProject)
.build();

// Then
Expand All @@ -77,9 +86,7 @@ void getGav_whenInvoked_shouldReturnExpectedGroupArtifactVersion() {
void getDockerJsonConfigString_whenNoServerPresent_shouldReturnBlankString() {
// Given
JKubeEnricherContext jKubeEnricherContext = JKubeEnricherContext.builder()
.project(JavaProject.builder()
.groupId("org.eclipse.jkube").artifactId("test-project").version("0.0.1")
.build())
.project(javaProject)
.build();

// When
Expand All @@ -93,9 +100,7 @@ void getDockerJsonConfigString_whenNoServerPresent_shouldReturnBlankString() {
void getDockerJsonConfigString_whenServerPresent_shouldReturnDockerJsonString() {
// Given
JKubeEnricherContext jKubeEnricherContext = JKubeEnricherContext.builder()
.project(JavaProject.builder()
.groupId("org.eclipse.jkube").artifactId("test-project").version("0.0.1")
.build())
.project(javaProject)
.build();

// When
Expand All @@ -117,10 +122,7 @@ void getProperty_whenPropertyPresent_shouldReturnValue() {
Properties properties = new Properties();
properties.put("key1", "value1");
JKubeEnricherContext jKubeEnricherContext = JKubeEnricherContext.builder()
.project(JavaProject.builder()
.groupId("org.eclipse.jkube").artifactId("test-project").version("0.0.1")
.properties(properties)
.build())
.project(javaProject.toBuilder().properties(properties).build())
.build();

// When
Expand All @@ -135,10 +137,7 @@ void getProperty_whenPropertyAbsent_shouldReturnNull() {
// Given
Properties properties = new Properties();
JKubeEnricherContext jKubeEnricherContext = JKubeEnricherContext.builder()
.project(JavaProject.builder()
.groupId("org.eclipse.jkube").artifactId("test-project").version("0.0.1")
.properties(properties)
.build())
.project(javaProject.toBuilder().properties(properties).build())
.build();

// When
Expand All @@ -152,9 +151,7 @@ void getProperty_whenPropertyAbsent_shouldReturnNull() {
void getBuildStrategy_whenBuildStrategyPresent_shouldReturnBuildStrategy() {
// Given
JKubeEnricherContext jKubeEnricherContext = JKubeEnricherContext.builder()
.project(JavaProject.builder()
.groupId("org.eclipse.jkube").artifactId("test-project").version("0.0.1")
.build())
.project(javaProject)
.jKubeBuildStrategy(JKubeBuildStrategy.docker)
.build();

Expand All @@ -168,7 +165,6 @@ void getBuildStrategy_whenBuildStrategyPresent_shouldReturnBuildStrategy() {
@Test
void getDependencies_whenTransitiveTrue_shouldGetTransitiveDeps() {
// Given
JavaProject javaProject = JavaProject.builder().groupId("org.eclipse.jkube").artifactId("test-project").version("0.0.1").build();
List<Dependency> deps = new ArrayList<>(javaProject.getDependencies());
deps.add(Dependency.builder()
.groupId("org.eclipse.jkube").artifactId("test-project").version("0.0.1").build());
Expand All @@ -189,7 +185,6 @@ void getDependencies_whenTransitiveTrue_shouldGetTransitiveDeps() {
@Test
void getDependencies_whenTransitiveFalse_shouldGetDeps() {
// Given
JavaProject javaProject = JavaProject.builder().groupId("org.eclipse.jkube").artifactId("test-project").version("0.0.1").build();
List<Dependency> deps = new ArrayList<>(javaProject.getDependencies());
deps.add(Dependency.builder()
.groupId("org.eclipse.jkube").artifactId("test-project").version("0.0.1").build());
Expand All @@ -210,9 +205,6 @@ void getDependencies_whenTransitiveFalse_shouldGetDeps() {
void hasPlugin_withNullGroup_shouldSearchPluginWithArtifactId() {
try (MockedStatic<JKubeProjectUtil> jKubeProjectUtilMockedStatic = mockStatic(JKubeProjectUtil.class)) {
// Given
JavaProject javaProject = JavaProject.builder()
.groupId("org.eclipse.jkube").artifactId("test-project").version("0.0.1")
.build();
JKubeEnricherContext jKubeEnricherContext = JKubeEnricherContext.builder()
.project(javaProject)
.build();
Expand All @@ -229,9 +221,6 @@ void hasPlugin_withNullGroup_shouldSearchPluginWithArtifactId() {
void hasPlugin_withGroup_shouldSearchPluginWithArtifactId() {
try (MockedStatic<JKubeProjectUtil> jKubeProjectUtilMockedStatic = mockStatic(JKubeProjectUtil.class)) {
// Given
JavaProject javaProject = JavaProject.builder()
.groupId("org.eclipse.jkube").artifactId("test-project").version("0.0.1")
.build();
JKubeEnricherContext jKubeEnricherContext = JKubeEnricherContext.builder()
.project(javaProject)
.build();
Expand All @@ -249,13 +238,11 @@ void getProjectClassLoaders_whenInvoked_shouldCreateClassLoaderFromCompileClassp
try (MockedStatic<ClassUtil> classUtilMockedStatic = mockStatic(ClassUtil.class)) {
// Given
File targetDir = new File("target");
JavaProject javaProject = JavaProject.builder()
.groupId("org.eclipse.jkube").artifactId("test-project").version("0.0.1")
.compileClassPathElements(Collections.singletonList("/test/foo.jar"))
.outputDirectory(targetDir)
.build();
JKubeEnricherContext jKubeEnricherContext = JKubeEnricherContext.builder()
.project(javaProject)
.project(javaProject.toBuilder()
.compileClassPathElements(Collections.singletonList("/test/foo.jar"))
.outputDirectory(targetDir)
.build())
.build();

// When
Expand Down

0 comments on commit 9957773

Please sign in to comment.