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);
}
use of com.jayway.restassured.response.Response in project che by eclipse.
the class WorkspaceServiceTest method shouldStopWorkspace.
@Test
public void shouldStopWorkspace() 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).when().delete(SECURE_PATH + "/workspace/" + workspace.getId() + "/runtime");
assertEquals(response.getStatusCode(), 204);
verify(wsManager).stopWorkspace(workspace.getId(), null);
}
use of com.jayway.restassured.response.Response in project che by eclipse.
the class WorkspaceServiceTest method shouldUpdateCommand.
@Test
public void shouldUpdateCommand() throws Exception {
final WorkspaceImpl workspace = createWorkspace(createConfigDto());
when(wsManager.getWorkspace(workspace.getId())).thenReturn(workspace);
when(wsManager.updateWorkspace(any(), any())).thenReturn(workspace);
final CommandDto commandDto = createCommandDto();
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").body(commandDto).when().put(SECURE_PATH + "/workspace/" + workspace.getId() + "/command/" + commandDto.getName());
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 stateOfWsAgentShouldBeChecked.
@Test
public void stateOfWsAgentShouldBeChecked() throws Exception {
final WorkspaceImpl workspace = createWorkspace(createConfigDto());
workspace.setStatus(RUNNING);
WsAgentHealthStateDto wsAgentState = newDto(WsAgentHealthStateDto.class);
WorkspaceRuntimeImpl runtime = mock(WorkspaceRuntimeImpl.class);
MachineImpl machine = mock(MachineImpl.class);
when(runtime.getDevMachine()).thenReturn(machine);
when(wsAgentHealthChecker.check(machine)).thenReturn(wsAgentState);
workspace.setRuntime(runtime);
when(wsManager.getWorkspace(workspace.getId())).thenReturn(workspace);
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().get(SECURE_PATH + "/workspace/" + workspace.getId() + "/check");
verify(wsAgentHealthChecker).check(machine);
assertEquals(RUNNING, wsAgentState.getWorkspaceStatus());
assertEquals(200, response.getStatusCode());
}
Aggregations