use of org.eclipse.che.api.workspace.server.spi.environment.InternalRecipe in project che-server by eclipse-che.
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 che-server by eclipse-che.
the class OpenShiftEnvironmentFactoryTest method addDeploymentsWhenRecipeContainsThem.
@Test
public void addDeploymentsWhenRecipeContainsThem() throws Exception {
// given
PodTemplateSpec podTemplate = new PodTemplateSpecBuilder().withNewMetadata().withName("deployment-pod").endMetadata().withNewSpec().endSpec().build();
Deployment deployment = new DeploymentBuilder().withNewMetadata().withName("deployment-test").endMetadata().withNewSpec().withTemplate(podTemplate).endSpec().build();
when(k8sRecipeParser.parse(any(InternalRecipe.class))).thenReturn(singletonList(deployment));
// when
final KubernetesEnvironment osEnv = osEnvFactory.doCreate(internalRecipe, emptyMap(), emptyList());
// then
assertEquals(osEnv.getDeploymentsCopy().size(), 1);
assertEquals(osEnv.getDeploymentsCopy().get("deployment-test"), deployment);
assertEquals(osEnv.getPodsData().size(), 1);
assertEquals(osEnv.getPodsData().get("deployment-test").getMetadata(), podTemplate.getMetadata());
assertEquals(osEnv.getPodsData().get("deployment-test").getSpec(), podTemplate.getSpec());
}
use of org.eclipse.che.api.workspace.server.spi.environment.InternalRecipe in project che-server by eclipse-che.
the class OpenShiftEnvironmentFactoryTest method addSecretsWhenRecipeContainsThem.
@Test
public void addSecretsWhenRecipeContainsThem() throws Exception {
Secret secret = new SecretBuilder().withNewMetadata().withName("test-secret").endMetadata().build();
when(k8sRecipeParser.parse(any(InternalRecipe.class))).thenReturn(singletonList(secret));
final OpenShiftEnvironment parsed = osEnvFactory.doCreate(internalRecipe, emptyMap(), emptyList());
assertEquals(parsed.getSecrets().size(), 1);
assertEquals(parsed.getSecrets().get("test-secret").getMetadata().getName(), secret.getMetadata().getName());
}
use of org.eclipse.che.api.workspace.server.spi.environment.InternalRecipe in project che-server by eclipse-che.
the class OpenShiftEnvironmentFactoryTest method shouldMergeDeploymentAndPodIntoOneDeployment.
@Test
public void shouldMergeDeploymentAndPodIntoOneDeployment() throws Exception {
// given
PodTemplateSpec podTemplate = new PodTemplateSpecBuilder().withNewMetadata().withName("deployment-pod").endMetadata().withNewSpec().endSpec().build();
Deployment deployment = new DeploymentBuilder().withNewMetadata().withName("deployment-test").endMetadata().withNewSpec().withTemplate(podTemplate).endSpec().build();
Pod pod = new PodBuilder().withNewMetadata().withName("bare-pod").endMetadata().withNewSpec().endSpec().build();
when(k8sRecipeParser.parse(any(InternalRecipe.class))).thenReturn(asList(deployment, pod));
Deployment merged = createEmptyDeployment("merged");
when(podMerger.merge(any())).thenReturn(merged);
// when
final KubernetesEnvironment k8sEnv = osEnvFactory.doCreate(internalRecipe, emptyMap(), emptyList());
// then
verify(podMerger).merge(asList(new PodData(pod), new PodData(deployment)));
assertEquals(k8sEnv.getPodsData().size(), 1);
assertTrue(k8sEnv.getPodsCopy().isEmpty());
assertEquals(k8sEnv.getDeploymentsCopy().size(), 1);
assertEquals(k8sEnv.getDeploymentsCopy().get("merged"), merged);
}
use of org.eclipse.che.api.workspace.server.spi.environment.InternalRecipe in project che-server by eclipse-che.
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());
}
Aggregations