Search in sources :

Example 41 with ValidationException

use of org.eclipse.che.api.core.ValidationException 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());
}
Also used : ValidationException(org.eclipse.che.api.core.ValidationException) InternalRecipe(org.eclipse.che.api.workspace.server.spi.environment.InternalRecipe) Test(org.testng.annotations.Test)

Example 42 with ValidationException

use of org.eclipse.che.api.core.ValidationException in project devspaces-images by redhat-developer.

the class WorkspaceServiceTest method shouldReturnBadRequestOnInvalidDevfile.

@Test
public void shouldReturnBadRequestOnInvalidDevfile() throws Exception {
    final DevfileDto devfileDto = createDevfileDto();
    final WorkspaceImpl workspace = createWorkspace(devfileDto);
    when(wsManager.createWorkspace(any(Devfile.class), anyString(), any(), any())).thenThrow(new ValidationException("boom"));
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").body(devfileDto).when().post(SECURE_PATH + "/workspace/devfile" + "?namespace=test" + "&attribute=factoryId:factory123" + "&attribute=custom:custom:value");
    assertEquals(response.getStatusCode(), 400);
    String error = unwrapError(response);
    assertEquals(error, "boom");
}
Also used : Response(io.restassured.response.Response) WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) ValidationException(org.eclipse.che.api.core.ValidationException) DevfileDto(org.eclipse.che.api.workspace.shared.dto.devfile.DevfileDto) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Devfile(org.eclipse.che.api.core.model.workspace.devfile.Devfile) Test(org.testng.annotations.Test)

Aggregations

ValidationException (org.eclipse.che.api.core.ValidationException)42 Test (org.testng.annotations.Test)16 InfrastructureException (org.eclipse.che.api.workspace.server.spi.InfrastructureException)12 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)10 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)10 PodData (org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData)8 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)6 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)6 ObjectMeta (io.fabric8.kubernetes.api.model.ObjectMeta)6 Pod (io.fabric8.kubernetes.api.model.Pod)6 PodTemplateSpec (io.fabric8.kubernetes.api.model.PodTemplateSpec)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 ConflictException (org.eclipse.che.api.core.ConflictException)6 ServerException (org.eclipse.che.api.core.ServerException)6 WorkspaceStatus (org.eclipse.che.api.core.model.workspace.WorkspaceStatus)6 RuntimeIdentityImpl (org.eclipse.che.api.workspace.server.model.impl.RuntimeIdentityImpl)6 WorkspaceConfigImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl)6 InternalInfrastructureException (org.eclipse.che.api.workspace.server.spi.InternalInfrastructureException)6 Traced (org.eclipse.che.commons.annotation.Traced)6