use of org.eclipse.che.api.workspace.server.spi.environment.InternalRecipe in project che-server by eclipse-che.
the class OpenShiftEnvironmentFactoryTest method shouldUseDeploymentNameAsPodTemplateNameIfItIsMissing.
@Test
public void shouldUseDeploymentNameAsPodTemplateNameIfItIsMissing() throws Exception {
// given
PodTemplateSpec podTemplate = new PodTemplateSpecBuilder().withNewSpec().endSpec().build();
Deployment deployment = new DeploymentBuilder().withNewMetadata().withName("deployment-test").endMetadata().withNewSpec().withTemplate(podTemplate).endSpec().build();
when(k8sRecipeParser.parse(any(InternalRecipe.class))).thenReturn(asList(deployment));
// when
final KubernetesEnvironment k8sEnv = osEnvFactory.doCreate(internalRecipe, emptyMap(), emptyList());
// then
Deployment deploymentTest = k8sEnv.getDeploymentsCopy().get("deployment-test");
assertNotNull(deploymentTest);
PodTemplateSpec resultPodTemplate = deploymentTest.getSpec().getTemplate();
assertEquals(resultPodTemplate.getMetadata().getName(), "deployment-test");
}
use of org.eclipse.che.api.workspace.server.spi.environment.InternalRecipe in project che-server by eclipse-che.
the class OpenShiftEnvironmentFactoryTest method shouldCreateOpenShiftEnvironmentWithServicesFromRecipe.
@Test
public void shouldCreateOpenShiftEnvironmentWithServicesFromRecipe() throws Exception {
// given
Service service1 = new ServiceBuilder().withNewMetadata().withName("service1").endMetadata().build();
Service service2 = new ServiceBuilder().withNewMetadata().withName("service2").endMetadata().build();
when(k8sRecipeParser.parse(any(InternalRecipe.class))).thenReturn(asList(service1, service2));
// when
KubernetesEnvironment osEnv = osEnvFactory.doCreate(internalRecipe, emptyMap(), emptyList());
// then
assertEquals(osEnv.getServices().size(), 2);
assertEquals(osEnv.getServices().get("service1"), service1);
assertEquals(osEnv.getServices().get("service2"), service2);
}
use of org.eclipse.che.api.workspace.server.spi.environment.InternalRecipe in project che-server by eclipse-che.
the class OpenShiftEnvironmentFactoryTest method exceptionOnObjectsWithTheSameNameAndKind.
@Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "Environment can not contain two 'Service' objects with the same name 'db'")
public void exceptionOnObjectsWithTheSameNameAndKind() throws Exception {
HasMetadata object1 = new ServiceBuilder().withNewMetadata().withName("db").endMetadata().build();
HasMetadata object2 = new ServiceBuilder().withNewMetadata().withName("db").endMetadata().build();
when(k8sRecipeParser.parse(any(InternalRecipe.class))).thenReturn(asList(object1, object2));
osEnvFactory.doCreate(internalRecipe, emptyMap(), emptyList());
}
use of org.eclipse.che.api.workspace.server.spi.environment.InternalRecipe in project che-server by eclipse-che.
the class KubernetesEnvironmentFactoryTest method addConfigMapsWhenRecipeContainsThem.
@Test
public void addConfigMapsWhenRecipeContainsThem() throws Exception {
ConfigMap configMap = new ConfigMapBuilder().withNewMetadata().withName("test-configmap").endMetadata().build();
when(k8sRecipeParser.parse(any(InternalRecipe.class))).thenReturn(singletonList(configMap));
final KubernetesEnvironment parsed = k8sEnvFactory.doCreate(internalRecipe, emptyMap(), emptyList());
assertEquals(parsed.getConfigMaps().size(), 1);
assertEquals(parsed.getConfigMaps().get("test-configmap"), configMap);
}
use of org.eclipse.che.api.workspace.server.spi.environment.InternalRecipe in project che-server by eclipse-che.
the class KubernetesEnvironmentFactoryTest method exceptionOnObjectWithNoNameSpecified.
@Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "MyObject name must not be null")
public void exceptionOnObjectWithNoNameSpecified() throws Exception {
HasMetadata object = mock(HasMetadata.class);
when(object.getKind()).thenReturn("MyObject");
when(object.getMetadata()).thenReturn(new ObjectMetaBuilder().withName(null).build());
when(k8sRecipeParser.parse(any(InternalRecipe.class))).thenReturn(singletonList(object));
k8sEnvFactory.doCreate(internalRecipe, emptyMap(), emptyList());
}
Aggregations