use of org.eclipse.che.api.workspace.server.spi.environment.InternalRecipe in project devspaces-images by redhat-developer.
the class OpenShiftEnvironmentFactoryTest 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));
osEnvFactory.doCreate(internalRecipe, emptyMap(), emptyList());
}
use of org.eclipse.che.api.workspace.server.spi.environment.InternalRecipe in project devspaces-images by redhat-developer.
the class OpenShiftEnvironmentFactoryTest method addRoutesWhenRecipeContainsThem.
@Test
public void addRoutesWhenRecipeContainsThem() throws Exception {
Route route = new RouteBuilder().withNewMetadata().withName("test-route").endMetadata().build();
when(k8sRecipeParser.parse(any(InternalRecipe.class))).thenReturn(singletonList(route));
final OpenShiftEnvironment parsed = osEnvFactory.doCreate(internalRecipe, emptyMap(), emptyList());
assertEquals(parsed.getRoutes().size(), 1);
assertEquals(parsed.getRoutes().get("test-route").getMetadata().getName(), route.getMetadata().getName());
}
use of org.eclipse.che.api.workspace.server.spi.environment.InternalRecipe in project devspaces-images by redhat-developer.
the class OpenShiftEnvironmentFactoryTest method exceptionOnObjectWithNoKindSpecified.
@Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "Environment contains object without specified kind field")
public void exceptionOnObjectWithNoKindSpecified() throws Exception {
HasMetadata object = mock(HasMetadata.class);
when(object.getKind()).thenReturn(null);
when(k8sRecipeParser.parse(any(InternalRecipe.class))).thenReturn(singletonList(object));
osEnvFactory.doCreate(internalRecipe, emptyMap(), emptyList());
}
use of org.eclipse.che.api.workspace.server.spi.environment.InternalRecipe in project devspaces-images by redhat-developer.
the class KubernetesEnvironmentFactoryTest 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 = k8sEnvFactory.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 devspaces-images by redhat-developer.
the class KubernetesEnvironmentFactoryTest method shouldCreateK8sEnvironmentWithPVCsFromRecipe.
@Test
public void shouldCreateK8sEnvironmentWithPVCsFromRecipe() throws Exception {
// given
PersistentVolumeClaim pvc1 = new PersistentVolumeClaimBuilder().withNewMetadata().withName("pvc1").endMetadata().build();
PersistentVolumeClaim pvc2 = new PersistentVolumeClaimBuilder().withNewMetadata().withName("pvc2").endMetadata().build();
when(k8sRecipeParser.parse(any(InternalRecipe.class))).thenReturn(asList(pvc1, pvc2));
// when
KubernetesEnvironment k8sEnv = k8sEnvFactory.doCreate(internalRecipe, emptyMap(), emptyList());
// then
assertEquals(k8sEnv.getPersistentVolumeClaims().size(), 2);
assertEquals(k8sEnv.getPersistentVolumeClaims().get("pvc1"), pvc1);
assertEquals(k8sEnv.getPersistentVolumeClaims().get("pvc2"), pvc2);
}
Aggregations