use of com.jayway.restassured.response.Response in project che by eclipse.
the class WorkspaceServiceTest method shouldReturnSnapshotsOnGetSnapshot.
@Test
public void shouldReturnSnapshotsOnGetSnapshot() throws Exception {
// given
String workspaceId = "testWsId1";
SnapshotImpl.SnapshotBuilder snapshotBuilder = SnapshotImpl.builder().setCreationDate(System.currentTimeMillis()).setDescription("description").setDev(true).setEnvName("envName").setId("snap1").setMachineName("machine1").setMachineSource(new MachineSourceImpl("type").setContent("content")).setType("type").setWorkspaceId(workspaceId);
SnapshotImpl snapshot1 = snapshotBuilder.build();
SnapshotImpl snapshot2 = snapshotBuilder.setDev(false).build();
List<SnapshotImpl> originSnapshots = Arrays.asList(snapshot1, snapshot2);
when(wsManager.getSnapshot(workspaceId)).thenReturn(originSnapshots);
// 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);
List<SnapshotImpl> newSnapshots = snapshotDtos.stream().map(SnapshotImpl::new).collect(Collectors.toList());
originSnapshots.forEach(snapshot -> snapshot.setMachineSource(null));
assertEquals(newSnapshots, originSnapshots);
verify(wsManager).getSnapshot(workspaceId);
}
use of com.jayway.restassured.response.Response in project che by eclipse.
the class WorkspaceServiceTest method shouldBeAbleToGetSettings.
@Test
public void shouldBeAbleToGetSettings() throws Exception {
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().get(SECURE_PATH + "/workspace/settings");
assertEquals(response.getStatusCode(), 200);
final Map<String, String> settings = new Gson().fromJson(response.print(), new TypeToken<Map<String, String>>() {
}.getType());
assertEquals(settings, //
ImmutableMap.of(//
"che.workspace.auto_snapshot", //
"true", //
"che.workspace.auto_restore", //
"false", "che.workspace.auto_start", "true"));
}
use of com.jayway.restassured.response.Response in project che by eclipse.
the class WorkspaceServiceTest method stateOfWsAgentShouldNotBeCheckedIfWsIsNotRunning.
@Test
public void stateOfWsAgentShouldNotBeCheckedIfWsIsNotRunning() throws Exception {
final WorkspaceImpl workspace = createWorkspace(createConfigDto());
workspace.setStatus(STARTING);
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, never()).check(any());
assertEquals(200, response.getStatusCode());
}
use of com.jayway.restassured.response.Response in project che by eclipse.
the class WorkspaceServiceTest method createShouldReturn400WhenConfigIsNotSent.
@Test
public void createShouldReturn400WhenConfigIsNotSent() throws Exception {
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").when().post(SECURE_PATH + "/workspace?attribute=stackId=stack123");
assertEquals(response.getStatusCode(), 400);
assertEquals(unwrapError(response), "Workspace configuration required");
}
use of com.jayway.restassured.response.Response in project che by eclipse.
the class WorkspaceServiceTest method shouldGetWorkspaces.
@Test
public void shouldGetWorkspaces() throws Exception {
final WorkspaceImpl workspace1 = createWorkspace(createConfigDto());
final WorkspaceImpl workspace2 = createWorkspace(createConfigDto(), STARTING);
when(wsManager.getWorkspaces(USER_ID, false)).thenReturn(asList(workspace1, workspace2));
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().get(SECURE_PATH + "/workspace");
assertEquals(response.getStatusCode(), 200);
assertEquals(unwrapDtoList(response, WorkspaceDto.class).stream().map(ws -> new WorkspaceImpl(ws, TEST_ACCOUNT)).collect(toList()), asList(workspace1, workspace2));
}
Aggregations