Search in sources :

Example 16 with JavaProject

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

the class JKubeProjectUtilTest method getFinalOutputArtifact_withNothingProvided_returnsNull.

@Test
public void getFinalOutputArtifact_withNothingProvided_returnsNull() {
    // Given
    JavaProject javaProject = JavaProject.builder().build();
    // When
    File finalOutputArtifact = JKubeProjectUtil.getFinalOutputArtifact(javaProject);
    // Then
    assertThat(finalOutputArtifact).isNull();
}
Also used : JavaProject(org.eclipse.jkube.kit.common.JavaProject) File(java.io.File) Test(org.junit.Test)

Example 17 with JavaProject

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

the class JKubeProjectUtilTest method getFinalOutputArtifact_withProjectArtifactVersionPackagingBuildDir_returnsInferredArtifact.

@Test
public void getFinalOutputArtifact_withProjectArtifactVersionPackagingBuildDir_returnsInferredArtifact() throws IOException {
    // Given
    File artifactFile = new File(temporaryFolder.getRoot(), "foo-test-1.0.0.jar");
    boolean artifactFileCreated = artifactFile.createNewFile();
    JavaProject javaProject = JavaProject.builder().artifactId("foo-test").version("1.0.0").packaging("jar").buildDirectory(temporaryFolder.getRoot()).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)

Example 18 with JavaProject

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

the class MavenIssueManagementEnricherTest method testMavenIssueManagementOnlyUrl.

@Test
public void testMavenIssueManagementOnlyUrl() {
    final JavaProject project = JavaProject.builder().build();
    project.setIssueManagementUrl("https://github.com/fabric8org.eclipse.jkube-maven-plugin/issues/");
    // Setup mock behaviour
    new Expectations() {

        {
            {
                context.getProject();
                result = project;
            }
        }
    };
    MavenIssueManagementEnricher enricher = new MavenIssueManagementEnricher(context);
    KubernetesListBuilder builder = new KubernetesListBuilder().withItems(new DeploymentBuilder().withNewMetadata().withName("foo").endMetadata().build());
    enricher.create(PlatformMode.kubernetes, builder);
    Map<String, String> scmAnnotations = builder.buildFirstItem().getMetadata().getAnnotations();
    assertNotNull(scmAnnotations);
    assertTrue(scmAnnotations.isEmpty());
}
Also used : Expectations(mockit.Expectations) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) JavaProject(org.eclipse.jkube.kit.common.JavaProject) DeploymentBuilder(io.fabric8.kubernetes.api.model.apps.DeploymentBuilder) Test(org.junit.Test)

Example 19 with JavaProject

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

the class MavenIssueManagementEnricherTest method testMavenIssueManagementAll.

@Test
public void testMavenIssueManagementAll() {
    final JavaProject project = JavaProject.builder().build();
    project.setIssueManagementUrl("https://github.com/reactiverse/vertx-maven-plugin/issues/");
    project.setIssueManagementSystem("GitHub");
    // Setup mock behaviour
    new Expectations() {

        {
            {
                context.getProject();
                result = project;
            }
        }
    };
    MavenIssueManagementEnricher enricher = new MavenIssueManagementEnricher(context);
    KubernetesListBuilder builder = new KubernetesListBuilder().withItems(new DeploymentBuilder().withNewMetadata().withName("foo").endMetadata().build());
    enricher.create(PlatformMode.kubernetes, builder);
    Map<String, String> scmAnnotations = builder.buildFirstItem().getMetadata().getAnnotations();
    assertNotNull(scmAnnotations);
    Assert.assertEquals(2, scmAnnotations.size());
    assertEquals("GitHub", scmAnnotations.get(JKubeAnnotations.ISSUE_SYSTEM.value()));
    assertEquals("https://github.com/reactiverse/vertx-maven-plugin/issues/", scmAnnotations.get(JKubeAnnotations.ISSUE_TRACKER_URL.value()));
}
Also used : Expectations(mockit.Expectations) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) JavaProject(org.eclipse.jkube.kit.common.JavaProject) DeploymentBuilder(io.fabric8.kubernetes.api.model.apps.DeploymentBuilder) Test(org.junit.Test)

Example 20 with JavaProject

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

the class MavenIssueManagementEnricherTest method testMavenIssueManagementOnlySystem.

@Test
public void testMavenIssueManagementOnlySystem() {
    final JavaProject project = JavaProject.builder().build();
    project.setIssueManagementSystem("GitHub");
    // Setup mock behaviour
    new Expectations() {

        {
            {
                context.getProject();
                result = project;
            }
        }
    };
    MavenIssueManagementEnricher enricher = new MavenIssueManagementEnricher(context);
    KubernetesListBuilder builder = new KubernetesListBuilder().withItems(new DeploymentBuilder().withNewMetadata().withName("foo").endMetadata().build());
    enricher.create(PlatformMode.kubernetes, builder);
    Map<String, String> scmAnnotations = builder.buildFirstItem().getMetadata().getAnnotations();
    assertNotNull(scmAnnotations);
    assertTrue(scmAnnotations.isEmpty());
}
Also used : Expectations(mockit.Expectations) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) JavaProject(org.eclipse.jkube.kit.common.JavaProject) DeploymentBuilder(io.fabric8.kubernetes.api.model.apps.DeploymentBuilder) 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