use of com.jayway.restassured.response.Response in project che by eclipse.
the class WorkspaceServiceTest method shouldNotRestoreWorkspace.
@Test
public void shouldNotRestoreWorkspace() throws Exception {
final WorkspaceImpl workspace = createWorkspace(createConfigDto());
when(wsManager.startWorkspace(any(), any(), any())).thenReturn(workspace);
when(wsManager.getWorkspace(workspace.getId())).thenReturn(workspace);
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().post(SECURE_PATH + "/workspace/" + workspace.getId() + "/runtime" + "?environment=" + workspace.getConfig().getDefaultEnv() + "&restore=false");
assertEquals(response.getStatusCode(), 200);
assertEquals(new WorkspaceImpl(unwrapDto(response, WorkspaceDto.class), TEST_ACCOUNT), workspace);
verify(wsManager).startWorkspace(workspace.getId(), workspace.getConfig().getDefaultEnv(), false);
}
use of com.jayway.restassured.response.Response in project che by eclipse.
the class WorkspaceServiceTest method shouldUpdateProject.
@Test
public void shouldUpdateProject() throws Exception {
final WorkspaceImpl workspace = createWorkspace(createConfigDto());
when(wsManager.getWorkspace(workspace.getId())).thenReturn(workspace);
when(wsManager.updateWorkspace(any(), any())).thenReturn(workspace);
final ProjectConfigDto projectDto = createProjectDto();
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").body(projectDto).when().put(SECURE_PATH + "/workspace/" + workspace.getId() + "/project" + projectDto.getPath());
assertEquals(response.getStatusCode(), 200);
verify(validator).validateConfig(workspace.getConfig());
verify(wsManager).updateWorkspace(any(), any());
}
use of com.jayway.restassured.response.Response in project che by eclipse.
the class WorkspaceServiceTest method shouldRelativizeLinksOnCreateWorkspace.
@Test
public void shouldRelativizeLinksOnCreateWorkspace() throws Exception {
final String initialLocation = "http://localhost:8080/api/recipe/idrecipe123456789/script";
final WorkspaceConfigDto configDto = createConfigDto();
configDto.getEnvironments().get(configDto.getDefaultEnv()).getRecipe().withLocation(initialLocation).withType("dockerfile");
ArgumentCaptor<WorkspaceConfigDto> captor = ArgumentCaptor.forClass(WorkspaceConfigDto.class);
when(wsManager.createWorkspace(captor.capture(), any(), any())).thenAnswer(invocation -> createWorkspace(captor.getValue()));
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").body(configDto).when().post(SECURE_PATH + "/workspace" + "?namespace=test" + "&attribute=stackId:stack123" + "&attribute=custom:custom:value");
assertEquals(response.getStatusCode(), 201);
String savedLocation = unwrapDto(response, WorkspaceDto.class).getConfig().getEnvironments().get(configDto.getDefaultEnv()).getRecipe().getLocation();
assertEquals(savedLocation, initialLocation.substring(API_ENDPOINT.length()));
}
use of com.jayway.restassured.response.Response in project che by eclipse.
the class WorkspaceServiceTest method shouldRespond404WhenUpdatingCommandWhichDoesNotExist.
@Test
public void shouldRespond404WhenUpdatingCommandWhichDoesNotExist() throws Exception {
final WorkspaceImpl workspace = createWorkspace(createConfigDto());
when(wsManager.getWorkspace(workspace.getId())).thenReturn(workspace);
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").body(createCommandDto()).when().put(SECURE_PATH + "/workspace/" + workspace.getId() + "/command/fake");
assertEquals(response.getStatusCode(), 404);
assertEquals(unwrapError(response), "Workspace '" + workspace.getId() + "' doesn't contain command 'fake'");
verify(wsManager, never()).updateWorkspace(any(), any());
}
use of com.jayway.restassured.response.Response in project che by eclipse.
the class WorkspaceServiceTest method shouldReturnEmptyListIfNotSnapshotsFound.
@Test
public void shouldReturnEmptyListIfNotSnapshotsFound() throws Exception {
// given
String workspaceId = "testWsId1";
when(wsManager.getSnapshot(workspaceId)).thenReturn(Collections.emptyList());
// when
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().get(SECURE_PATH + "/workspace/" + workspaceId + "/snapshot");
// then
assertEquals(response.getStatusCode(), 200);
List<SnapshotDto> snapshotDtos = unwrapDtoList(response, SnapshotDto.class);
assertTrue(snapshotDtos.isEmpty());
verify(wsManager).getSnapshot(workspaceId);
}
Aggregations