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());
}
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());
}
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());
}
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);
}
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());
}
Aggregations