Search in sources :

Example 11 with DeploymentBuilder

use of io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder in project fabric8-maven-plugin by fabric8io.

the class MavenIssueManagementEnricherTest method testMavenNoIssueManagement.

@Test
public void testMavenNoIssueManagement() {
    final MavenProject project = new MavenProject();
    // 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) MavenProject(org.apache.maven.project.MavenProject) DeploymentBuilder(io.fabric8.kubernetes.api.model.apps.DeploymentBuilder) Test(org.junit.Test)

Example 12 with DeploymentBuilder

use of io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder in project fabric8-maven-plugin by fabric8io.

the class MavenScmEnricherTest method testMavenScmOnlyConnection.

@Test
public void testMavenScmOnlyConnection() {
    final MavenProject project = new MavenProject();
    final Scm scm = new Scm();
    scm.setConnection("scm:git:git://github.com/fabric8io/fabric8-maven-plugin.git");
    project.setScm(scm);
    // Setup mock behaviour
    new Expectations() {

        {
            {
                context.getProject();
                result = project;
            }
        }
    };
    MavenScmEnricher mavenScmEnricher = new MavenScmEnricher(context);
    KubernetesListBuilder builder = new KubernetesListBuilder().withItems(new DeploymentBuilder().withNewMetadata().withName("foo").endMetadata().build());
    mavenScmEnricher.create(PlatformMode.kubernetes, builder);
    Map<String, String> scmAnnotations = builder.buildFirstItem().getMetadata().getAnnotations();
    assertNotNull(scmAnnotations);
    Assert.assertEquals(1, scmAnnotations.size());
    assertEquals("HEAD", scmAnnotations.get(Fabric8Annotations.SCM_TAG.value()));
}
Also used : Expectations(mockit.Expectations) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) MavenProject(org.apache.maven.project.MavenProject) Scm(org.apache.maven.model.Scm) DeploymentBuilder(io.fabric8.kubernetes.api.model.apps.DeploymentBuilder) Test(org.junit.Test)

Example 13 with DeploymentBuilder

use of io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder in project fabric8-maven-plugin by fabric8io.

the class MavenScmEnricherTest method testMavenNoScm.

@Test
public void testMavenNoScm() {
    final MavenProject project = new MavenProject();
    // Setup mock behaviour
    new Expectations() {

        {
            {
                context.getProject();
                result = project;
            }
        }
    };
    MavenScmEnricher mavenScmEnricher = new MavenScmEnricher(context);
    KubernetesListBuilder builder = new KubernetesListBuilder().withItems(new DeploymentBuilder().withNewMetadata().withName("foo").endMetadata().build());
    mavenScmEnricher.create(PlatformMode.kubernetes, builder);
    Map<String, String> scmAnnotations = builder.buildFirstItem().getMetadata().getAnnotations();
    assertNotNull(scmAnnotations);
}
Also used : Expectations(mockit.Expectations) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) MavenProject(org.apache.maven.project.MavenProject) DeploymentBuilder(io.fabric8.kubernetes.api.model.apps.DeploymentBuilder) Test(org.junit.Test)

Example 14 with DeploymentBuilder

use of io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder in project fabric8-maven-plugin by fabric8io.

the class MavenScmEnricherTest method testMavenScmOnlyDevConnection.

@Test
public void testMavenScmOnlyDevConnection() {
    final MavenProject project = new MavenProject();
    final Scm scm = new Scm();
    scm.setUrl("git://github.com/fabric8io/fabric8-maven-plugin.git");
    project.setScm(scm);
    // Setup mock behaviour
    new Expectations() {

        {
            {
                context.getProject();
                result = project;
            }
        }
    };
    MavenScmEnricher mavenScmEnricher = new MavenScmEnricher(context);
    KubernetesListBuilder builder = new KubernetesListBuilder().withItems(new DeploymentBuilder().withNewMetadata().withName("foo").endMetadata().build());
    mavenScmEnricher.create(PlatformMode.kubernetes, builder);
    Map<String, String> scmAnnotations = builder.buildFirstItem().getMetadata().getAnnotations();
    assertNotNull(scmAnnotations);
    Assert.assertEquals(2, scmAnnotations.size());
    assertEquals("git://github.com/fabric8io/fabric8-maven-plugin.git", scmAnnotations.get(Fabric8Annotations.SCM_URL.value()));
    assertEquals("HEAD", scmAnnotations.get(Fabric8Annotations.SCM_TAG.value()));
}
Also used : Expectations(mockit.Expectations) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) MavenProject(org.apache.maven.project.MavenProject) Scm(org.apache.maven.model.Scm) DeploymentBuilder(io.fabric8.kubernetes.api.model.apps.DeploymentBuilder) Test(org.junit.Test)

Example 15 with DeploymentBuilder

use of io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder in project fabric8-maven-plugin by fabric8io.

the class MavenProjectEnricherTest method testGeneratedResources.

@Test
public void testGeneratedResources() {
    ProjectLabelEnricher projectEnricher = new ProjectLabelEnricher(context);
    KubernetesListBuilder builder = createListWithDeploymentConfig();
    projectEnricher.enrich(PlatformMode.kubernetes, builder);
    KubernetesList list = builder.build();
    Map<String, String> labels = list.getItems().get(0).getMetadata().getLabels();
    assertNotNull(labels);
    assertEquals("groupId", labels.get("group"));
    assertEquals("artifactId", labels.get("app"));
    assertEquals("version", labels.get("version"));
    assertNull(labels.get("project"));
    builder = new KubernetesListBuilder().withItems(new DeploymentBuilder().build());
    projectEnricher.create(PlatformMode.kubernetes, builder);
    Deployment deployment = (Deployment) builder.buildFirstItem();
    Map<String, String> selectors = deployment.getSpec().getSelector().getMatchLabels();
    assertEquals("groupId", selectors.get("group"));
    assertEquals("artifactId", selectors.get("app"));
    assertNull(selectors.get("version"));
    assertNull(selectors.get("project"));
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) KubernetesList(io.fabric8.kubernetes.api.model.KubernetesList) DeploymentBuilder(io.fabric8.kubernetes.api.model.apps.DeploymentBuilder) Test(org.junit.Test)

Aggregations

DeploymentBuilder (io.fabric8.kubernetes.api.model.apps.DeploymentBuilder)100 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)69 Test (org.junit.jupiter.api.Test)29 Test (org.junit.Test)24 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)23 Test (org.testng.annotations.Test)22 Container (io.fabric8.kubernetes.api.model.Container)16 ContainerBuilder (io.fabric8.kubernetes.api.model.ContainerBuilder)16 PodTemplateSpec (io.fabric8.kubernetes.api.model.PodTemplateSpec)14 ArrayList (java.util.ArrayList)14 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)13 Pod (io.fabric8.kubernetes.api.model.Pod)13 PodBuilder (io.fabric8.kubernetes.api.model.PodBuilder)13 PodTemplateSpecBuilder (io.fabric8.kubernetes.api.model.PodTemplateSpecBuilder)13 DeploymentBuilder (io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder)13 ObjectMetaBuilder (io.fabric8.kubernetes.api.model.ObjectMetaBuilder)12 HashMap (java.util.HashMap)12 InternalRecipe (org.eclipse.che.api.workspace.server.spi.environment.InternalRecipe)12 Deployment (io.fabric8.kubernetes.api.model.extensions.Deployment)11 Expectations (mockit.Expectations)10