use of io.fabric8.mockwebserver.Context in project fabric8-maven-plugin by fabric8io.
the class MavenProjectEnricherTest method testOldStyleGeneratedResources.
@Test
public void testOldStyleGeneratedResources() {
final Properties properties = new Properties();
properties.setProperty("fabric8.enricher.fmp-project.useProjectLabel", "true");
new Expectations() {
{
mavenProject.getProperties();
result = properties;
}
};
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("project"));
assertEquals("version", labels.get("version"));
assertNull(labels.get("app"));
Map<String, String> selectors = projectEnricher.getSelector(Kind.DEPLOYMENT_CONFIG);
assertEquals("groupId", selectors.get("group"));
assertEquals("artifactId", selectors.get("project"));
assertNull(selectors.get("version"));
assertNull(selectors.get("app"));
}
use of io.fabric8.mockwebserver.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"));
}
use of io.fabric8.mockwebserver.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()));
}
use of io.fabric8.mockwebserver.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));
}
use of io.fabric8.mockwebserver.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);
}
Aggregations