use of org.eclipse.che.api.workspace.server.spi.environment.InternalRecipe in project devspaces-images by redhat-developer.
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 devspaces-images by redhat-developer.
the class KubernetesEnvironmentFactoryTest method ignoreIgressesWhenRecipeContainsThem.
@Test
public void ignoreIgressesWhenRecipeContainsThem() throws Exception {
when(k8sRecipeParser.parse(any(InternalRecipe.class))).thenReturn(asList(new IngressBuilder().withNewMetadata().withName("ingress1").endMetadata().build(), new IngressBuilder().withNewMetadata().withName("ingress2").endMetadata().build()));
final KubernetesEnvironment parsed = k8sEnvFactory.doCreate(internalRecipe, emptyMap(), emptyList());
assertTrue(parsed.getIngresses().isEmpty());
assertEquals(parsed.getWarnings().size(), 1);
assertEquals(parsed.getWarnings().get(0), new WarningImpl(INGRESSES_IGNORED_WARNING_CODE, INGRESSES_IGNORED_WARNING_MESSAGE));
}
use of org.eclipse.che.api.workspace.server.spi.environment.InternalRecipe in project devspaces-images by redhat-developer.
the class KubernetesEnvironmentFactoryTest 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 k8sEnv = k8sEnvFactory.doCreate(internalRecipe, emptyMap(), emptyList());
// then
assertEquals(k8sEnv.getDeploymentsCopy().size(), 1);
assertEquals(k8sEnv.getDeploymentsCopy().get("deployment-test"), deployment);
assertEquals(k8sEnv.getPodsData().size(), 1);
assertEquals(k8sEnv.getPodsData().get("deployment-test").getMetadata(), podTemplate.getMetadata());
assertEquals(k8sEnv.getPodsData().get("deployment-test").getSpec(), podTemplate.getSpec());
}
use of org.eclipse.che.api.workspace.server.spi.environment.InternalRecipe in project devspaces-images by redhat-developer.
the class KubernetesEnvironmentFactoryTest 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));
k8sEnvFactory.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 exceptionOnObjectWithNoMetadataSpecified.
@Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "MyObject metadata must not be null")
public void exceptionOnObjectWithNoMetadataSpecified() throws Exception {
HasMetadata object = mock(HasMetadata.class);
when(object.getKind()).thenReturn("MyObject");
when(object.getMetadata()).thenReturn(null);
when(k8sRecipeParser.parse(any(InternalRecipe.class))).thenReturn(singletonList(object));
osEnvFactory.doCreate(internalRecipe, emptyMap(), emptyList());
}
Aggregations