Search in sources :

Example 51 with WorkspaceImpl

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

the class WorkspaceManagerTest method shouldBeAbleToStartTemporaryWorkspace.

@Test
public void shouldBeAbleToStartTemporaryWorkspace() throws Exception {
    mockAnyWorkspaceStart();
    workspaceManager.startWorkspace(createConfig(), NAMESPACE, true);
    verify(runtimes).startAsync(workspaceCaptor.capture(), anyString(), anyBoolean());
    final WorkspaceImpl captured = workspaceCaptor.getValue();
    assertTrue(captured.isTemporary());
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) Test(org.testng.annotations.Test)

Example 52 with WorkspaceImpl

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

the class WorkspaceManagerTest method shouldCreateWorkspaceSnapshotUsingDefaultValueForAutoRestore.

@Test
public void shouldCreateWorkspaceSnapshotUsingDefaultValueForAutoRestore() throws Exception {
    // given
    workspaceManager = new WorkspaceManager(workspaceDao, runtimes, eventService, accountManager, true, false, snapshotDao, sharedPool);
    final WorkspaceImpl workspace = createAndMockWorkspace();
    mockRuntime(workspace, RUNNING);
    SnapshotImpl oldSnapshot = mock(SnapshotImpl.class);
    when(snapshotDao.getSnapshot(eq(workspace.getId()), eq(workspace.getConfig().getDefaultEnv()), anyString())).thenReturn(oldSnapshot);
    // when
    workspaceManager.stopWorkspace(workspace.getId());
    // then
    captureRunAsyncCallsAndRunSynchronously();
    verify(runtimes).snapshot(workspace.getId());
    verify(runtimes).stop(workspace.getId());
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) SnapshotImpl(org.eclipse.che.api.machine.server.model.impl.SnapshotImpl) Test(org.testng.annotations.Test)

Example 53 with WorkspaceImpl

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

the class WorkspaceManagerTest method shouldBeAbleToRemoveMachinesSnapshots.

@Test
public void shouldBeAbleToRemoveMachinesSnapshots() throws Exception {
    // given
    String testWsId = "testWsId";
    String testNamespace = "testNamespace";
    WorkspaceImpl workspaceMock = mock(WorkspaceImpl.class);
    when(workspaceDao.get(testWsId)).thenReturn(workspaceMock);
    when(workspaceMock.getNamespace()).thenReturn(testNamespace);
    SnapshotImpl.SnapshotBuilder snapshotBuilder = SnapshotImpl.builder().generateId().setEnvName("env").setDev(true).setMachineName("machine1").setWorkspaceId(testWsId).setType("docker").setMachineSource(new MachineSourceImpl("image"));
    SnapshotImpl snapshot1 = snapshotBuilder.build();
    SnapshotImpl snapshot2 = snapshotBuilder.generateId().setDev(false).setMachineName("machine2").build();
    when(snapshotDao.findSnapshots(testWsId)).thenReturn(asList(snapshot1, snapshot2));
    // when
    workspaceManager.removeSnapshots(testWsId);
    // then
    captureExecuteCallsAndRunSynchronously();
    verify(runtimes).removeBinaries(asList(snapshot1, snapshot2));
    InOrder snapshotDaoInOrder = inOrder(snapshotDao);
    snapshotDaoInOrder.verify(snapshotDao).removeSnapshot(snapshot1.getId());
    snapshotDaoInOrder.verify(snapshotDao).removeSnapshot(snapshot2.getId());
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) InOrder(org.mockito.InOrder) SnapshotImpl(org.eclipse.che.api.machine.server.model.impl.SnapshotImpl) MachineSourceImpl(org.eclipse.che.api.machine.server.model.impl.MachineSourceImpl) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.testng.annotations.Test)

Example 54 with WorkspaceImpl

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

the class WorkspaceManagerTest method shouldBeAbleToGetWorkspaceByKeyNamespaceOptionalPreviousFormat.

@Test
public void shouldBeAbleToGetWorkspaceByKeyNamespaceOptionalPreviousFormat() throws Exception {
    WorkspaceImpl workspace = createAndMockWorkspace();
    WorkspaceImpl result = workspaceManager.getWorkspace(":" + workspace.getConfig().getName());
    assertEquals(result, workspace);
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) Test(org.testng.annotations.Test)

Example 55 with WorkspaceImpl

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

the class WorkspaceManagerTest method shouldBeAbleToStopMachine.

@Test
public void shouldBeAbleToStopMachine() throws Exception {
    // given
    final WorkspaceImpl workspace = createAndMockWorkspace();
    WorkspaceRuntimeImpl runtime = mockRuntime(workspace, RUNNING);
    MachineImpl machine = runtime.getMachines().get(0);
    // when
    workspaceManager.stopMachine(workspace.getId(), machine.getId());
    // then
    verify(runtimes).stopMachine(workspace.getId(), machine.getId());
}
Also used : 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) 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