use of org.eclipse.che.api.workspace.server.spi.environment.InternalRecipe in project devspaces-images by redhat-developer.
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 devspaces-images by redhat-developer.
the class OpenShiftEnvironmentFactoryTest method exceptionOnRecipeLoadError.
@Test(expectedExceptions = ValidationException.class)
public void exceptionOnRecipeLoadError() throws Exception {
when(k8sRecipeParser.parse(any(InternalRecipe.class))).thenThrow(new ValidationException("Could not parse recipe"));
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 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 devspaces-images by redhat-developer.
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 devspaces-images by redhat-developer.
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());
}
Aggregations