use of org.eclipse.che.api.workspace.shared.dto.devfile.DevfileDto in project che-server by eclipse-che.
the class WorkspaceServiceTest method shouldCreateWorkspaceFromDevfile.
@Test
public void shouldCreateWorkspaceFromDevfile() throws Exception {
final DevfileDto devfileDto = createDevfileDto();
final WorkspaceImpl workspace = createWorkspace(devfileDto);
when(wsManager.createWorkspace(any(Devfile.class), anyString(), any(), any())).thenReturn(workspace);
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(), 201);
assertEquals(new WorkspaceImpl(unwrapDto(response, WorkspaceDto.class), TEST_ACCOUNT), workspace);
verify(wsManager).createWorkspace(any(Devfile.class), eq("test"), eq(ImmutableMap.of("factoryId", "factory123", "custom", "custom:value")), any());
}
use of org.eclipse.che.api.workspace.shared.dto.devfile.DevfileDto in project devspaces-images by redhat-developer.
the class WorkspaceServiceTest method shouldCreateWorkspaceFromDevfile.
@Test
public void shouldCreateWorkspaceFromDevfile() throws Exception {
final DevfileDto devfileDto = createDevfileDto();
final WorkspaceImpl workspace = createWorkspace(devfileDto);
when(wsManager.createWorkspace(any(Devfile.class), anyString(), any(), any())).thenReturn(workspace);
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(), 201);
assertEquals(new WorkspaceImpl(unwrapDto(response, WorkspaceDto.class), TEST_ACCOUNT), workspace);
verify(wsManager).createWorkspace(any(Devfile.class), eq("test"), eq(ImmutableMap.of("factoryId", "factory123", "custom", "custom:value")), any());
}
use of org.eclipse.che.api.workspace.shared.dto.devfile.DevfileDto in project che-server by eclipse-che.
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");
}
use of org.eclipse.che.api.workspace.shared.dto.devfile.DevfileDto 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");
}
Aggregations