Search in sources :

Example 51 with Context

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

the class MavenProjectEnricherTest method testGeneratedResources.

@Test
public void testGeneratedResources() {
    ProjectEnricher projectEnricher = new ProjectEnricher(context);
    KubernetesListBuilder builder = createListWithDeploymentConfig();
    projectEnricher.adapt(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"));
    Map<String, String> selectors = projectEnricher.getSelector(Kind.DEPLOYMENT_CONFIG);
    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) KubernetesList(io.fabric8.kubernetes.api.model.KubernetesList) Test(org.junit.Test)

Example 52 with Context

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

the class RevisionHistoryEnricherTest method testDefaultRevisionHistoryLimit.

@Test
public void testDefaultRevisionHistoryLimit() throws JsonProcessingException {
    // Given
    KubernetesListBuilder builder = new KubernetesListBuilder().addNewDeploymentItem().endDeploymentItem();
    RevisionHistoryEnricher enricher = new RevisionHistoryEnricher(context);
    // When
    enricher.addMissingResources(builder);
    // Then
    assertRevisionHistory(builder.build(), Configs.asInt(RevisionHistoryEnricher.Config.limit.def()));
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) Test(org.junit.Test)

Example 53 with Context

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

the class RevisionHistoryEnricherTest method testCustomRevisionHistoryLimit.

@Test
public void testCustomRevisionHistoryLimit() throws JsonProcessingException {
    // Setup mock behaviour
    final String revisionNumber = "10";
    new Expectations() {

        {
            context.getConfig();
            result = prepareEnricherConfig(revisionNumber);
        }
    };
    // Given
    KubernetesListBuilder builder = new KubernetesListBuilder().addNewDeploymentItem().endDeploymentItem();
    RevisionHistoryEnricher enricher = new RevisionHistoryEnricher(context);
    // When
    enricher.addMissingResources(builder);
    // Then
    assertRevisionHistory(builder.build(), Integer.parseInt(revisionNumber));
}
Also used : Expectations(mockit.Expectations) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) Test(org.junit.Test)

Example 54 with Context

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

the class PrometheusEnricherTest method testNoDefinedPrometheusPort.

@Test
public void testNoDefinedPrometheusPort() throws Exception {
    final ProcessorConfig config = new ProcessorConfig(null, null, Collections.singletonMap(PrometheusEnricher.ENRICHER_NAME, new TreeMap()));
    final BuildImageConfiguration imageConfig = new BuildImageConfiguration.Builder().build();
    // Setup mock behaviour
    new Expectations() {

        {
            context.getConfig();
            result = config;
            imageConfiguration.getBuildConfiguration();
            result = imageConfig;
            context.getImages();
            result = Arrays.asList(imageConfiguration);
        }
    };
    PrometheusEnricher enricher = new PrometheusEnricher(context);
    Map<String, String> annotations = enricher.getAnnotations(Kind.SERVICE);
    assertNull(annotations);
}
Also used : Expectations(mockit.Expectations) TreeMap(java.util.TreeMap) ProcessorConfig(io.fabric8.maven.core.config.ProcessorConfig) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) Test(org.junit.Test)

Example 55 with Context

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

the class DockerRegistrySecretEnricherTest method testDockerRegistryWithBadAnnotation.

@Test
public void testDockerRegistryWithBadAnnotation() {
    DockerRegistrySecretEnricher enricher = new DockerRegistrySecretEnricher(context);
    new Expectations() {

        {
            {
                context.getSettings();
                returns(new Settings());
            }
        }
    };
    KubernetesListBuilder builder = new KubernetesListBuilder();
    Secret secret = createBaseSecret(true);
    secret.getMetadata().getAnnotations().put(annotation, "docker1.io");
    builder.addToSecretItems(createBaseSecret(true));
    KubernetesList expected = builder.build();
    enricher.addMissingResources(builder);
    assertEquals(expected, builder.build());
}
Also used : Expectations(mockit.Expectations) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) Secret(io.fabric8.kubernetes.api.model.Secret) KubernetesList(io.fabric8.kubernetes.api.model.KubernetesList) Settings(org.apache.maven.settings.Settings) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)135 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)58 Async (io.vertx.ext.unit.Async)52 Expectations (mockit.Expectations)34 Probe (io.fabric8.kubernetes.api.model.Probe)33 Reconciliation (io.strimzi.controller.cluster.Reconciliation)24 File (java.io.File)23 Git (org.eclipse.jgit.api.Git)23 GitContext (io.fabric8.api.GitContext)21 IOException (java.io.IOException)21 ConfigMapOperator (io.strimzi.controller.cluster.operator.resource.ConfigMapOperator)20 ServiceOperator (io.strimzi.controller.cluster.operator.resource.ServiceOperator)20 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)18 HashMap (java.util.HashMap)17 LockHandle (io.fabric8.api.LockHandle)15 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)15 NonNamespaceOperation (io.fabric8.kubernetes.client.dsl.NonNamespaceOperation)15 ProcessorConfig (io.fabric8.maven.core.config.ProcessorConfig)15 MixedOperation (io.fabric8.kubernetes.client.dsl.MixedOperation)14 Resource (io.fabric8.kubernetes.client.dsl.Resource)14