Search in sources :

Example 26 with ProcessorConfig

use of org.eclipse.jkube.kit.config.resource.ProcessorConfig in project jkube by eclipse.

the class FromSelectorTest method simple.

@Test
public void simple() {
    final TestCase[] testCases = new TestCase[] { new TestCase(OPENSHIFT, s2i, "s2i-prop", "istag-prop"), new TestCase(OPENSHIFT, docker, "docker-prop", "istag-prop"), new TestCase(null, s2i, "docker-prop", "istag-prop"), new TestCase(null, docker, "docker-prop", "istag-prop"), new TestCase(OPENSHIFT, null, "docker-prop", "istag-prop"), new TestCase(OPENSHIFT, null, "docker-prop", "istag-prop"), new TestCase(null, null, "docker-prop", "istag-prop"), new TestCase(null, null, "docker-prop", "istag-prop") };
    for (TestCase tc : testCases) {
        GeneratorContext ctx = GeneratorContext.builder().project(project).config(new ProcessorConfig()).logger(logger).runtimeMode(tc.runtimeMode).strategy(tc.strategy).build();
        FromSelector selector = new FromSelector.Default(ctx, "test");
        assertEquals(tc.expectedFrom, selector.getFrom());
        Map<String, String> fromExt = selector.getImageStreamTagFromExt();
        assertEquals(3, fromExt.size());
        assertEquals("ImageStreamTag", fromExt.get(JKubeBuildStrategy.SourceStrategy.kind.key()));
        assertEquals("openshift", fromExt.get(JKubeBuildStrategy.SourceStrategy.namespace.key()));
        assertEquals(tc.expectedName, fromExt.get(JKubeBuildStrategy.SourceStrategy.name.key()));
    }
}
Also used : ProcessorConfig(org.eclipse.jkube.kit.config.resource.ProcessorConfig) Test(org.junit.Test)

Example 27 with ProcessorConfig

use of org.eclipse.jkube.kit.config.resource.ProcessorConfig in project jkube by eclipse.

the class BaseGeneratorTest method setUp.

@Before
public void setUp() {
    properties = new Properties();
    config = new ProcessorConfig();
    // @formatter:off
    new Expectations() {

        {
            ctx.getProject().getProperties();
            result = properties;
            ctx.getConfig();
            result = config;
        }
    };
// @formatter:on
}
Also used : Expectations(mockit.Expectations) Properties(java.util.Properties) ProcessorConfig(org.eclipse.jkube.kit.config.resource.ProcessorConfig) Before(org.junit.Before)

Example 28 with ProcessorConfig

use of org.eclipse.jkube.kit.config.resource.ProcessorConfig in project jkube by eclipse.

the class PrometheusEnricherTest method testCustomPrometheusPath.

@Test
public void testCustomPrometheusPath() {
    // Given
    initContext(new ProcessorConfig(null, null, Collections.singletonMap("jkube-prometheus", Collections.singletonMap("prometheusPath", "/prometheus"))), ImageConfiguration.builder().build(BuildConfiguration.builder().ports(Arrays.asList("1337", null, " ", "9779", null)).build()).build());
    final KubernetesListBuilder builder = new KubernetesListBuilder().withItems(new ServiceBuilder().withNewMetadata().withName("foo").endMetadata().build());
    // When
    prometheusEnricher.create(PlatformMode.kubernetes, builder);
    // Then
    assertThat(builder.buildFirstItem().getMetadata().getAnnotations()).hasSize(3).containsEntry("prometheus.io/port", "9779").containsEntry("prometheus.io/scrape", "true").containsEntry("prometheus.io/path", "/prometheus");
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) ProcessorConfig(org.eclipse.jkube.kit.config.resource.ProcessorConfig) ServiceBuilder(io.fabric8.kubernetes.api.model.ServiceBuilder) Test(org.junit.Test)

Example 29 with ProcessorConfig

use of org.eclipse.jkube.kit.config.resource.ProcessorConfig in project jkube by eclipse.

the class ServiceDiscoveryEnricherTest method setUp.

@SuppressWarnings("ResultOfMethodCallIgnored")
@Before
public void setUp() {
    Map<String, Object> configMap = new HashMap<>();
    configMap.put("path", path);
    configMap.put("port", port);
    configMap.put("scheme", scheme);
    configMap.put("descriptionPath", descriptionPath);
    configMap.put("discoverable", discoverable);
    configMap.put("discoveryVersion", discoveryVersion);
    ProcessorConfig processorConfig = new ProcessorConfig(null, null, Collections.singletonMap("jkube-service-discovery", configMap));
    // Setup mock behaviour
    new Expectations() {

        {
            context.getConfiguration().getProcessorConfig();
            result = processorConfig;
        }
    };
    enricher = new ServiceDiscoveryEnricher(context);
    builder = new ServiceBuilder();
}
Also used : Expectations(mockit.Expectations) HashMap(java.util.HashMap) ProcessorConfig(org.eclipse.jkube.kit.config.resource.ProcessorConfig) ServiceBuilder(io.fabric8.kubernetes.api.model.ServiceBuilder) Before(org.junit.Before)

Example 30 with ProcessorConfig

use of org.eclipse.jkube.kit.config.resource.ProcessorConfig in project jkube by eclipse.

the class JavaExecGeneratorMainClassDeterminationTest method setUp.

@Before
public void setUp() {
    processorConfig = new ProcessorConfig();
    // @formatter:off
    new Expectations() {

        {
            project.getVersion();
            result = "1.33.7-SNAPSHOT";
            project.getOutputDirectory();
            result = "/the/output/directory";
        }
    };
// @formatter:on
}
Also used : Expectations(mockit.Expectations) ProcessorConfig(org.eclipse.jkube.kit.config.resource.ProcessorConfig) Before(org.junit.Before)

Aggregations

ProcessorConfig (org.eclipse.jkube.kit.config.resource.ProcessorConfig)33 Expectations (mockit.Expectations)22 Before (org.junit.Before)14 Test (org.junit.Test)13 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)12 Properties (java.util.Properties)12 TreeMap (java.util.TreeMap)6 Configuration (org.eclipse.jkube.kit.enricher.api.model.Configuration)6 ServiceBuilder (io.fabric8.kubernetes.api.model.ServiceBuilder)4 DeploymentBuilder (io.fabric8.kubernetes.api.model.apps.DeploymentBuilder)4 ArrayList (java.util.ArrayList)4 ImageConfiguration (org.eclipse.jkube.kit.config.image.ImageConfiguration)4 File (java.io.File)3 URLClassLoader (java.net.URLClassLoader)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ProjectClassLoaders (org.eclipse.jkube.kit.common.util.ProjectClassLoaders)3 BuildConfiguration (org.eclipse.jkube.kit.config.image.build.BuildConfiguration)3 TypeToken (com.google.common.reflect.TypeToken)2 Gson (com.google.gson.Gson)2