Search in sources :

Example 46 with WorkspaceImpl

use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.

the class WorkspaceManagerTest method createsSnapshotBeforeStoppingWorkspace.

@Test
public void createsSnapshotBeforeStoppingWorkspace() throws Exception {
    WorkspaceImpl workspace = createAndMockWorkspace();
    mockRuntime(workspace, RUNNING);
    workspaceManager.stopWorkspace(workspace.getId(), true);
    captureRunAsyncCallsAndRunSynchronously();
    verify(runtimes).snapshot(workspace.getId());
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) Test(org.testng.annotations.Test)

Example 47 with WorkspaceImpl

use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.

the class WorkspaceManagerTest method workspaceUpdateShouldReturnWorkspaceWithStatusEqualToItsRuntimeStatus.

@Test
public void workspaceUpdateShouldReturnWorkspaceWithStatusEqualToItsRuntimeStatus() throws Exception {
    final WorkspaceImpl workspace = createAndMockWorkspace();
    mockRuntime(workspace, STARTING);
    final WorkspaceImpl updated = workspaceManager.updateWorkspace(workspace.getId(), workspace);
    assertEquals(updated.getStatus(), STARTING);
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) Test(org.testng.annotations.Test)

Example 48 with WorkspaceImpl

use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.

the class WorkspaceManagerTest method shouldBeAbleToGetWorkspacesByNamespace.

@Test
public void shouldBeAbleToGetWorkspacesByNamespace() throws Exception {
    // given
    final WorkspaceImpl workspace = createAndMockWorkspace();
    mockRuntime(workspace, RUNNING);
    // when
    final List<WorkspaceImpl> result = workspaceManager.getByNamespace(workspace.getNamespace(), true);
    // then
    assertEquals(result.size(), 1);
    final WorkspaceImpl res1 = result.get(0);
    assertEquals(res1.getStatus(), RUNNING, "Workspace status wasn't changed to the runtime instance status");
    assertFalse(res1.isTemporary(), "Workspace must be permanent");
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) Test(org.testng.annotations.Test)

Example 49 with WorkspaceImpl

use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.

the class WorkspaceManagerTest method shouldRemoveTemporaryWorkspaceAfterStartFailed.

@Test
public void shouldRemoveTemporaryWorkspaceAfterStartFailed() throws Exception {
    WorkspaceImpl workspace = createAndMockWorkspace();
    workspace.setTemporary(true);
    mockRuntime(workspace, RUNNING);
    doThrow(new ServerException("")).when(runtimes).stop(workspace.getId());
    workspaceManager.stopWorkspace(workspace.getId());
    captureRunAsyncCallsAndRunSynchronously();
    verify(workspaceDao).remove(workspace.getId());
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) ServerException(org.eclipse.che.api.core.ServerException) Test(org.testng.annotations.Test)

Example 50 with WorkspaceImpl

use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.

the class WorkspaceManagerTest method passedCreateSnapshotParameterIsUsedInPreferenceToAttribute.

@Test
public void passedCreateSnapshotParameterIsUsedInPreferenceToAttribute() throws Exception {
    final WorkspaceImpl workspace = createAndMockWorkspace();
    workspace.getAttributes().put(AUTO_CREATE_SNAPSHOT, "true");
    mockRuntime(workspace, RUNNING);
    workspaceManager.stopWorkspace(workspace.getId(), false);
    captureRunAsyncCallsAndRunSynchronously();
    verify(runtimes, never()).snapshot(workspace.getId());
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) Test(org.testng.annotations.Test)

Aggregations

WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)165 Test (org.testng.annotations.Test)130 Response (com.jayway.restassured.response.Response)34 WorkspaceRuntimeImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceRuntimeImpl)15 ServerException (org.eclipse.che.api.core.ServerException)14 SnapshotImpl (org.eclipse.che.api.machine.server.model.impl.SnapshotImpl)12 ApiOperation (io.swagger.annotations.ApiOperation)11 ApiResponses (io.swagger.annotations.ApiResponses)11 AccountImpl (org.eclipse.che.account.spi.AccountImpl)11 Path (javax.ws.rs.Path)10 Produces (javax.ws.rs.Produces)10 WorkspaceDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceDto)10 EnvironmentImpl (org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl)9 WorkspaceConfigImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl)9 NotFoundException (org.eclipse.che.api.core.NotFoundException)8 MachineImpl (org.eclipse.che.api.machine.server.model.impl.MachineImpl)8 Consumes (javax.ws.rs.Consumes)7 ConflictException (org.eclipse.che.api.core.ConflictException)7 ExtendedMachineImpl (org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl)7 ProjectConfigImpl (org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl)7