Search in sources :

Example 41 with JavaProject

use of org.eclipse.jkube.kit.common.JavaProject in project jkube by eclipse.

the class ContainerHandlerTest method registryHandling.

@Test
public void registryHandling() {
    // container name with alias
    final BuildConfiguration buildImageConfiguration = BuildConfiguration.builder().build();
    String[] testData = { "docker.io/test/test-app:1.2", "docker-alternate.io", null, null, "docker.io/test/test-app:1.2", "test/test-app:1.2", "docker-image-config.io", "docker-pull.io", "docker-default.io", "docker-image-config.io/test/test-app:1.2", "test/test-app", null, "docker-pull.io", "docker-default.io", "docker-pull.io/test/test-app:latest", "test/test-app", null, null, "docker-default.io", "docker-default.io/test/test-app:latest" };
    for (int i = 0; i < testData.length; i += 5) {
        JavaProject testProject = JavaProject.builder().properties(new Properties()).build();
        Properties testProps = new Properties();
        if (testData[i + 2] != null) {
            testProps.put("jkube.docker.pull.registry", testData[i + 2]);
        }
        if (testData[i + 3] != null) {
            testProps.put("jkube.docker.registry", testData[i + 3]);
        }
        Properties properties = testProject.getProperties();
        properties.putAll(testProps);
        testProject.setProperties(properties);
        ContainerHandler handler = createContainerHandler(testProject);
        // container name with alias
        ImageConfiguration imageConfiguration = ImageConfiguration.builder().build(buildImageConfiguration).name(testData[i]).registry(testData[i + 1]).build();
        images.clear();
        images.add(imageConfiguration);
        containers = handler.getContainers(config, images);
        assertNotNull(containers);
        assertEquals(testData[i + 4], containers.get(0).getImage());
    }
}
Also used : BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) JavaProject(org.eclipse.jkube.kit.common.JavaProject) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) Properties(java.util.Properties) Test(org.junit.Test)

Example 42 with JavaProject

use of org.eclipse.jkube.kit.common.JavaProject in project jkube by eclipse.

the class DekorateUtilTest method useDekorate_withDekorateDependency_returnsTrue.

@Test
public void useDekorate_withDekorateDependency_returnsTrue() {
    // Given
    JavaProject javaProject = JavaProject.builder().dependency(Dependency.builder().groupId("io.dekorate").artifactId("kubernetes-annotations").version("0.10.5").build()).build();
    // When
    boolean result = DekorateUtil.useDekorate(javaProject);
    // Then
    assertThat(result).isTrue();
}
Also used : JavaProject(org.eclipse.jkube.kit.common.JavaProject) Test(org.junit.Test)

Example 43 with JavaProject

use of org.eclipse.jkube.kit.common.JavaProject in project jkube by eclipse.

the class DekorateUtilTest method useDekorate_withNoDekorateDependency_returnsFalse.

@Test
public void useDekorate_withNoDekorateDependency_returnsFalse() {
    // Given
    JavaProject javaProject = JavaProject.builder().build();
    // When
    boolean result = DekorateUtil.useDekorate(javaProject);
    // Then
    assertThat(result).isFalse();
}
Also used : JavaProject(org.eclipse.jkube.kit.common.JavaProject) Test(org.junit.Test)

Example 44 with JavaProject

use of org.eclipse.jkube.kit.common.JavaProject in project jkube by eclipse.

the class JKubeProjectUtilTest method getProperty_whenSystemPropertyPresent_returnsSystemProperty.

@Test
public void getProperty_whenSystemPropertyPresent_returnsSystemProperty() {
    // Given
    new SystemMock().put("jkube.testProperty", "true");
    JavaProject javaProject = JavaProject.builder().build();
    // When
    String result = JKubeProjectUtil.getProperty("jkube.testProperty", javaProject);
    // Then
    assertThat(result).isEqualTo("true");
}
Also used : JavaProject(org.eclipse.jkube.kit.common.JavaProject) SystemMock(org.eclipse.jkube.kit.common.SystemMock) Test(org.junit.Test)

Example 45 with JavaProject

use of org.eclipse.jkube.kit.common.JavaProject in project jkube by eclipse.

the class JKubeProjectUtilTest method getFinalOutputArtifact_withArtifactAndBuildFinalNameAndPackaging_returnsArtifactFromJavaProject.

@Test
public void getFinalOutputArtifact_withArtifactAndBuildFinalNameAndPackaging_returnsArtifactFromJavaProject() throws IOException {
    // Given
    File artifactFile = new File(temporaryFolder.getRoot(), "foo-test-1.0.0.jar");
    boolean artifactFileCreated = artifactFile.createNewFile();
    JavaProject javaProject = JavaProject.builder().artifact(artifactFile).buildFinalName("foo-test-final").packaging("jar").build();
    // When
    File finalOutputArtifact = JKubeProjectUtil.getFinalOutputArtifact(javaProject);
    // Then
    assertThat(artifactFileCreated).isTrue();
    assertThat(finalOutputArtifact).hasName("foo-test-1.0.0.jar");
}
Also used : JavaProject(org.eclipse.jkube.kit.common.JavaProject) File(java.io.File) Test(org.junit.Test)

Aggregations

JavaProject (org.eclipse.jkube.kit.common.JavaProject)52 Test (org.junit.Test)43 File (java.io.File)16 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)9 DeploymentBuilder (io.fabric8.kubernetes.api.model.apps.DeploymentBuilder)9 Expectations (mockit.Expectations)9 HashMap (java.util.HashMap)7 Properties (java.util.Properties)6 Configuration (org.gradle.api.artifacts.Configuration)6 DeprecatableConfiguration (org.gradle.internal.deprecation.DeprecatableConfiguration)6 IOException (java.io.IOException)5 Collections (java.util.Collections)4 List (java.util.List)4 MavenProject (org.apache.maven.project.MavenProject)4 Plugin (org.eclipse.jkube.kit.common.Plugin)4 JKubeEnricherContext (org.eclipse.jkube.kit.enricher.api.JKubeEnricherContext)4 ArrayList (java.util.ArrayList)3 Optional (java.util.Optional)3 Collectors (java.util.stream.Collectors)3 StringUtils (org.apache.commons.lang3.StringUtils)3