Search in sources :

Example 16 with Response

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);
}
Also used : Response(com.jayway.restassured.response.Response) WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) Test(org.testng.annotations.Test)

Example 17 with Response

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());
}
Also used : Response(com.jayway.restassured.response.Response) WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) CommandDto(org.eclipse.che.api.machine.shared.dto.CommandDto) Test(org.testng.annotations.Test)

Example 18 with Response

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());
}
Also used : Response(com.jayway.restassured.response.Response) WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) ExtendedMachineImpl(org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl) MachineImpl(org.eclipse.che.api.machine.server.model.impl.MachineImpl) WorkspaceRuntimeImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceRuntimeImpl) WsAgentHealthStateDto(org.eclipse.che.api.workspace.shared.dto.WsAgentHealthStateDto) Test(org.testng.annotations.Test)

Example 19 with Response

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);
}
Also used : Response(com.jayway.restassured.response.Response) SnapshotImpl(org.eclipse.che.api.machine.server.model.impl.SnapshotImpl) SnapshotDto(org.eclipse.che.api.machine.shared.dto.SnapshotDto) MachineSourceImpl(org.eclipse.che.api.machine.server.model.impl.MachineSourceImpl) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.testng.annotations.Test)

Example 20 with Response

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"));
}
Also used : Response(com.jayway.restassured.response.Response) TypeToken(com.google.gson.reflect.TypeToken) Gson(com.google.gson.Gson) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.testng.annotations.Test)

Aggregations

Response (com.jayway.restassured.response.Response)169 Test (org.testng.annotations.Test)129 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)35 AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)31 Test (org.junit.Test)31 Matchers.anyString (org.mockito.Matchers.anyString)21 ValidatableResponse (com.jayway.restassured.response.ValidatableResponse)19 CswTestCommons.getMetacardIdFromCswInsertResponse (org.codice.ddf.itests.common.csw.CswTestCommons.getMetacardIdFromCswInsertResponse)15 IOException (java.io.IOException)14 SkipUnstableTest (org.codice.ddf.itests.common.annotations.SkipUnstableTest)14 XPathExpressionException (javax.xml.xpath.XPathExpressionException)12 ImmutableMap (com.google.common.collect.ImmutableMap)11 Map (java.util.Map)11 Factory (org.eclipse.che.api.core.model.factory.Factory)11 FactoryDto (org.eclipse.che.api.factory.shared.dto.FactoryDto)11 UserImpl (org.eclipse.che.api.user.server.model.impl.UserImpl)11 DtoFactory (org.eclipse.che.dto.server.DtoFactory)11 WorkspaceDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceDto)9 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)9 InputStream (java.io.InputStream)6