Search in sources :

Example 46 with Response

use of com.jayway.restassured.response.Response in project che by eclipse.

the class WorkspaceServiceTest method shouldUseUsernameAsNamespaceWhenStartingWorkspaceFromConfigWithoutNamespace.

@Test
public void shouldUseUsernameAsNamespaceWhenStartingWorkspaceFromConfigWithoutNamespace() throws Exception {
    final WorkspaceImpl workspace = createWorkspace(createConfigDto());
    when(wsManager.startWorkspace(anyObject(), anyString(), anyBoolean())).thenReturn(workspace);
    when(wsManager.getWorkspace(workspace.getId())).thenReturn(workspace);
    final WorkspaceDto workspaceDto = DtoConverter.asDto(workspace);
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").body(workspaceDto.getConfig()).when().post(SECURE_PATH + "/workspace/runtime" + "?temporary=true");
    assertEquals(response.getStatusCode(), 200);
    verify(validator).validateConfig(any());
    verify(wsManager).startWorkspace(any(), eq(NAMESPACE), eq(true));
}
Also used : Response(com.jayway.restassured.response.Response) WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) WorkspaceDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceDto) Test(org.testng.annotations.Test)

Example 47 with Response

use of com.jayway.restassured.response.Response in project che by eclipse.

the class WorkspaceServiceTest method shouldCreateWorkspace.

@Test
public void shouldCreateWorkspace() throws Exception {
    final WorkspaceConfigDto configDto = createConfigDto();
    final WorkspaceImpl workspace = createWorkspace(configDto);
    when(wsManager.createWorkspace(any(), any(), any())).thenReturn(workspace);
    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=factoryId:factory123" + "&attribute=custom:custom:value");
    assertEquals(response.getStatusCode(), 201);
    assertEquals(new WorkspaceImpl(unwrapDto(response, WorkspaceDto.class), TEST_ACCOUNT), workspace);
    verify(validator).validateConfig(any());
    verify(validator).validateAttributes(any());
    verify(wsManager).createWorkspace(anyObject(), eq("test"), eq(ImmutableMap.of("stackId", "stack123", "factoryId", "factory123", "custom", "custom:value")));
}
Also used : Response(com.jayway.restassured.response.Response) WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) WorkspaceConfigDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto) Test(org.testng.annotations.Test)

Example 48 with Response

use of com.jayway.restassured.response.Response in project che by eclipse.

the class WorkspaceServiceTest method shouldRespond404WhenUpdatingEnvironmentWhichDoesNotExist.

@Test
public void shouldRespond404WhenUpdatingEnvironmentWhichDoesNotExist() 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(createEnvDto()).when().put(SECURE_PATH + "/workspace/" + workspace.getId() + "/environment/fake");
    assertEquals(response.getStatusCode(), 404);
    assertEquals(unwrapError(response), "Workspace '" + workspace.getId() + "' doesn't contain environment 'fake'");
    verify(wsManager, never()).updateWorkspace(any(), any());
}
Also used : Response(com.jayway.restassured.response.Response) WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) Test(org.testng.annotations.Test)

Example 49 with Response

use of com.jayway.restassured.response.Response in project che by eclipse.

the class WorkspaceServiceTest method shouldRestoreWorkspace.

@Test
public void shouldRestoreWorkspace() 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=true");
    assertEquals(response.getStatusCode(), 200);
    assertEquals(new WorkspaceImpl(unwrapDto(response, WorkspaceDto.class), TEST_ACCOUNT), workspace);
    verify(wsManager).startWorkspace(workspace.getId(), workspace.getConfig().getDefaultEnv(), true);
}
Also used : Response(com.jayway.restassured.response.Response) WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) Test(org.testng.annotations.Test)

Example 50 with Response

use of com.jayway.restassured.response.Response in project che by eclipse.

the class WorkspaceServiceTest method shouldStartWorkspaceFromConfig.

@Test
public void shouldStartWorkspaceFromConfig() throws Exception {
    final WorkspaceImpl workspace = createWorkspace(createConfigDto());
    when(wsManager.startWorkspace(anyObject(), anyString(), anyBoolean())).thenReturn(workspace);
    when(wsManager.getWorkspace(workspace.getId())).thenReturn(workspace);
    final WorkspaceDto workspaceDto = DtoConverter.asDto(workspace);
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").body(workspaceDto.getConfig()).when().post(SECURE_PATH + "/workspace/runtime" + "?namespace=test" + "&temporary=true");
    assertEquals(response.getStatusCode(), 200);
    verify(validator).validateConfig(any());
    verify(wsManager).startWorkspace(any(), eq("test"), eq(true));
}
Also used : Response(com.jayway.restassured.response.Response) WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) WorkspaceDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceDto) Test(org.testng.annotations.Test)

Aggregations

Response (com.jayway.restassured.response.Response)214 Test (org.testng.annotations.Test)129 Test (org.junit.Test)73 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)35 AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)31 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)27 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 Matchers.containsString (org.hamcrest.Matchers.containsString)10 WorkspaceDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceDto)9