use of io.fabric8.knative.serving.v1.ServiceBuilder in project fabric8 by jboss-fuse.
the class ConfigCompareServiceTest method testServicesLabelsNotEqual.
@Test
public void testServicesLabelsNotEqual() throws Exception {
Service entity1 = new ServiceBuilder().withNewMetadata().withName("foo").addToLabels("label1", "value1").addToLabels("label2", "value2").endMetadata().withNewSpec().addToSelector("label1", "value1").addToSelector("label2", "value2").addNewPort().withPort(123).withNewTargetPort(456).endPort().endSpec().build();
Service entity2 = new ServiceBuilder().withNewMetadata().withName("foo").addToLabels("label2", "value2").addToLabels("notSame", "value1").endMetadata().withNewSpec().addToSelector("label1", "value1").addToSelector("label2", "value2").addNewPort().withPort(123).withNewTargetPort(456).endPort().endSpec().build();
assertCompareConfig(entity1, entity2, false);
}
use of io.fabric8.knative.serving.v1.ServiceBuilder in project fabric8 by jboss-fuse.
the class ConfigCompareServiceTest method testServicesEqualWithStatusDifferences.
@Test
public void testServicesEqualWithStatusDifferences() throws Exception {
Service entity1 = new ServiceBuilder().withNewMetadata().withName("foo").addToLabels("label1", "value1").addToLabels("label2", "value2").withResourceVersion("1").endMetadata().withNewSpec().addToSelector("label1", "value1").addToSelector("label2", "value2").addNewPort().withPort(123).withNewTargetPort(456).endPort().endSpec().build();
Service entity2 = new ServiceBuilder().withNewMetadata().withName("foo").addToLabels("label2", "value2").addToLabels("label1", "value1").withResourceVersion("2").endMetadata().withNewSpec().addToSelector("label1", "value1").addToSelector("label2", "value2").addNewPort().withPort(123).withNewTargetPort(456).endPort().endSpec().build();
assertCompareConfig(entity1, entity2, true);
}
use of io.fabric8.knative.serving.v1.ServiceBuilder in project fabric8 by jboss-fuse.
the class ConfigCompareServiceTest method testServicesPortNotEqual.
@Test
public void testServicesPortNotEqual() throws Exception {
Service entity1 = new ServiceBuilder().withNewMetadata().withName("foo").addToLabels("label1", "value1").addToLabels("label2", "value2").endMetadata().withNewSpec().addToSelector("label1", "value1").addToSelector("label2", "value2").addNewPort().withPort(123).withNewTargetPort(456).endPort().endSpec().build();
Service entity2 = new ServiceBuilder().withNewMetadata().withName("foo").addToLabels("label2", "value2").addToLabels("label1", "value1").endMetadata().withNewSpec().addToSelector("label1", "value1").addToSelector("label2", "value2").addNewPort().withPort(456).withNewTargetPort(456).endPort().endSpec().build();
assertCompareConfig(entity1, entity2, false);
}
use of io.fabric8.knative.serving.v1.ServiceBuilder in project fabric8 by jboss-fuse.
the class ConfigCompareServiceTest method testServicesSelectorNotEqual.
@Test
public void testServicesSelectorNotEqual() throws Exception {
Service entity1 = new ServiceBuilder().withNewMetadata().withName("foo").addToLabels("label1", "value1").addToLabels("label2", "value2").endMetadata().withNewSpec().addToSelector("label1", "value1").addToSelector("label2", "value2").addNewPort().withPort(123).withNewTargetPort(456).endPort().endSpec().build();
Service entity2 = new ServiceBuilder().withNewMetadata().withName("foo").addToLabels("label2", "value2").addToLabels("label1", "value1").endMetadata().withNewSpec().addToSelector("label1", "value1").addToSelector("notSame", "value2").addNewPort().withPort(123).withNewTargetPort(456).endPort().endSpec().build();
assertCompareConfig(entity1, entity2, false);
}
use of io.fabric8.knative.serving.v1.ServiceBuilder in project fabric8 by jboss-fuse.
the class TemplatesTest method testCombineResourcesIntoTemplate.
@Test
public void testCombineResourcesIntoTemplate() throws Exception {
Service templateService = new ServiceBuilder().withNewMetadata().withName("templateService").endMetadata().build();
KubernetesList list = new KubernetesListBuilder().addNewServiceItem().withNewMetadata().withName("service1").endMetadata().endServiceItem().addNewTemplateItem().addNewParameter().withName("PARAM1").withValue("ABC").endParameter().addToObjects(templateService).endTemplateItem().addNewServiceItem().withNewMetadata().withName("service2").endMetadata().endServiceItem().build();
Object result = Templates.combineTemplates(list);
System.out.println("Combined as " + KubernetesHelper.toJson(result));
assertThat(result).isInstanceOf(Template.class);
}
Aggregations