-
Notifications
You must be signed in to change notification settings - Fork 459
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KubernetesWatchTask Prerequisite refactor in JKube Kit
+ SpringBootWatcher.isApplicable returns true for Spring Boot Gradle Plugin + JKubeArtifactResolverService also resolves artifact in Gradle Local cache + SpringBootUtil.getSpringBootPluginConfiguration also fetches configuration of Spring Boot Gradle Plugin Signed-off-by: Rohan Kumar <rohaan@redhat.com>
- Loading branch information
1 parent
1e3b4a7
commit fbe0d52
Showing
6 changed files
with
289 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
.../src/test/java/org/eclipse/jkube/kit/config/service/JKubeArtifactResolverServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/** | ||
* Copyright (c) 2019 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at: | ||
* | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.jkube.kit.config.service; | ||
|
||
import org.eclipse.jkube.kit.common.JavaProject; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.TemporaryFolder; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
import static org.junit.Assert.assertThrows; | ||
|
||
public class JKubeArtifactResolverServiceTest { | ||
@Rule | ||
public TemporaryFolder temporaryFolder = new TemporaryFolder(); | ||
|
||
@Test | ||
public void resolveArtifact_whenArtifactPresentInGradleCache_thenReturnsArtifact() throws IOException { | ||
// Given | ||
File artifactParentDir = temporaryFolder.newFolder("org", "example", "test-artifact", "1.0.0"); | ||
File artifact = new File(artifactParentDir, "test-artifact-1.0.0.jar"); | ||
boolean artifactCreated = artifact.createNewFile(); | ||
JavaProject javaProject = JavaProject.builder() | ||
.localRepositoryBaseDirectory(temporaryFolder.getRoot()) | ||
.build(); | ||
JKubeArtifactResolverService jKubeArtifactResolverService = new JKubeArtifactResolverService(javaProject); | ||
|
||
// When | ||
File resolveArtifact = jKubeArtifactResolverService.resolveArtifact("org.example", "test-artifact", "1.0.0", "jar"); | ||
|
||
// Then | ||
assertThat(artifactCreated).isTrue(); | ||
assertThat(artifact).isFile().exists(); | ||
assertThat(resolveArtifact).isEqualTo(artifact); | ||
} | ||
|
||
@Test | ||
public void resolveArtifact_whenArtifactPresentInMavenCache_thenReturnsArtifact() throws IOException { | ||
// Given | ||
File artifactParentDir = temporaryFolder.newFolder("org.example", "test-artifact", "1.0.0"); | ||
File artifact = new File(artifactParentDir, "test-artifact-1.0.0.jar"); | ||
boolean artifactCreated = artifact.createNewFile(); | ||
JavaProject javaProject = JavaProject.builder() | ||
.localRepositoryBaseDirectory(temporaryFolder.getRoot()) | ||
.build(); | ||
JKubeArtifactResolverService jKubeArtifactResolverService = new JKubeArtifactResolverService(javaProject); | ||
|
||
// When | ||
File resolveArtifact = jKubeArtifactResolverService.resolveArtifact("org.example", "test-artifact", "1.0.0", "jar"); | ||
|
||
// Then | ||
assertThat(artifactCreated).isTrue(); | ||
assertThat(artifact).isFile().exists(); | ||
assertThat(resolveArtifact).isEqualTo(artifact); | ||
} | ||
|
||
@Test | ||
public void resolveArtifact_whenNoArtifactPresent_thenThrowsException() { | ||
// Given | ||
JavaProject javaProject = JavaProject.builder() | ||
.localRepositoryBaseDirectory(temporaryFolder.getRoot()) | ||
.build(); | ||
JKubeArtifactResolverService jKubeArtifactResolverService = new JKubeArtifactResolverService(javaProject); | ||
|
||
// When | ||
IllegalStateException illegalStateException = assertThrows(IllegalStateException.class, | ||
() -> jKubeArtifactResolverService.resolveArtifact("org.example", "test-artifact", "1.0.0", "jar")); | ||
|
||
// Then | ||
assertThat(illegalStateException) | ||
.hasMessage("Cannot find artifact org.example-test-artifact.jar within the resolved resources"); | ||
} | ||
|
||
@Test | ||
public void resolveArtifact_whenNoArtifactPresentAndNoLocalRepository_thenThrowsException() { | ||
// Given | ||
JKubeArtifactResolverService jKubeArtifactResolverService = new JKubeArtifactResolverService(JavaProject.builder().build()); | ||
|
||
// When | ||
IllegalStateException illegalStateException = assertThrows(IllegalStateException.class, | ||
() -> jKubeArtifactResolverService.resolveArtifact("org.example", "test-artifact", "1.0.0", "jar")); | ||
|
||
// Then | ||
assertThat(illegalStateException) | ||
.hasMessage("Cannot find artifact org.example-test-artifact.jar within the resolved resources"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.