use of io.fabric8.insight.metrics.model.Result in project fabric8-maven-plugin by fabric8io.
the class EnvVarHandlerTest method envVarHandlerTest.
@Test
public void envVarHandlerTest() {
// Some Environment Variable in Config
EnvVar var1 = new EnvVarBuilder().withName("TEST1").withValue("OK").build();
EnvVar var2 = new EnvVarBuilder().withName("TEST2").withValue("DONE").build();
EnvVar var3 = new EnvVarBuilder().withName("TEST3").withValue("").build();
env.clear();
env.put(var1.getName(), var1.getValue());
env.put(var2.getName(), var2.getValue());
env.put(var3.getName(), var3.getValue());
EnvVarHandler envVarHandler = new EnvVarHandler(project);
new Expectations() {
{
externalEnvVarHandler.getExportedEnvironmentVariables(project, env);
ret.putAll(env);
result = ret;
}
};
List<EnvVar> envVars = envVarHandler.getEnvironmentVariables(env);
assertNotNull(envVars);
assertEquals(4, envVars.size());
assertTrue(envVars.contains(var1));
assertTrue(envVars.contains(var2));
assertTrue(envVars.contains(var3));
assertTrue(envVars.contains(var4));
}
use of io.fabric8.insight.metrics.model.Result in project fabric8-maven-plugin by fabric8io.
the class DockerRegistrySecretEnricherTest method testDockerRegistry.
@Test
public void testDockerRegistry() {
new Expectations() {
{
{
context.getSettings();
result = createSettings();
}
}
};
DockerRegistrySecretEnricher enricher = new DockerRegistrySecretEnricher(context);
KubernetesListBuilder builder = new KubernetesListBuilder();
builder.addToSecretItems(createBaseSecret(true));
enricher.addMissingResources(builder);
KubernetesListBuilder expectedBuilder = new KubernetesListBuilder();
Secret expectedSecret = createBaseSecret(false);
expectedSecret.getData().put(SecretConstants.DOCKER_DATA_KEY, "eyJkb2NrZXIuaW8iOnsicGFzc3dvcmQiOiJwYXNzd29yZCIsImVtYWlsIjoiZm9vQGZvby5jb20iLCJ1c2VybmFtZSI6InVzZXJuYW1lIn19");
expectedBuilder.addToSecretItems(expectedSecret);
assertEquals(expectedBuilder.build(), builder.build());
}
use of io.fabric8.insight.metrics.model.Result in project fabric8-maven-plugin by fabric8io.
the class BaseGeneratorTest method addLatestTagIfSnapshot.
@Test
public void addLatestTagIfSnapshot() {
new Expectations() {
{
ctx.getProject();
result = project;
project.getVersion();
result = "1.2-SNAPSHOT";
}
};
BuildImageConfiguration.Builder builder = new BuildImageConfiguration.Builder();
BaseGenerator generator = createGenerator(null);
generator.addLatestTagIfSnapshot(builder);
;
BuildImageConfiguration config = builder.build();
List<String> tags = config.getTags();
assertEquals(1, tags.size());
assertTrue(tags.get(0).endsWith("latest"));
}
use of io.fabric8.insight.metrics.model.Result in project fabric8-maven-plugin by fabric8io.
the class EnricherManagerTest method enrichSimple.
@Test
public void enrichSimple() {
new Expectations() {
{
context.getConfig();
result = new ProcessorConfig(Arrays.asList("fmp-project"), null, new HashMap<String, TreeMap>());
}
};
EnricherManager manager = new EnricherManager(null, context);
KubernetesListBuilder builder = new KubernetesListBuilder();
builder.addNewReplicaSetItem().withNewSpec().withNewTemplate().withNewSpec().addNewContainer().withName("test").withImage("busybox").endContainer().endSpec().endTemplate().endSpec().endReplicaSetItem();
manager.enrich(builder);
KubernetesList list = builder.build();
assertEquals(1, list.getItems().size());
ReplicaSet pod = (ReplicaSet) list.getItems().get(0);
ObjectMeta metadata = pod.getMetadata();
assertNotNull(metadata);
Map<String, String> labels = metadata.getLabels();
assertNotNull(labels);
assertEquals("fabric8", labels.get("provider"));
}
use of io.fabric8.insight.metrics.model.Result in project fabric8-maven-plugin by fabric8io.
the class EnricherManagerTest method createDefaultResources.
@Test
public void createDefaultResources() {
new Expectations() {
{
context.getConfig();
result = new ProcessorConfig(Arrays.asList("fmp-controller"), null, null);
context.getImages();
result = new ImageConfiguration.Builder().alias("img1").name("img1").build();
}
};
EnricherManager manager = new EnricherManager(null, context);
KubernetesListBuilder builder = new KubernetesListBuilder();
manager.createDefaultResources(builder);
assertTrue(builder.build().getItems().size() > 0);
}
Aggregations