use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceManagerTest method shouldBeAbleToCreateSnapshot.
@Test
public void shouldBeAbleToCreateSnapshot() throws Exception {
// then
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.createSnapshot(workspace.getId());
// then
verify(runtimes).snapshotAsync(workspace.getId());
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceManagerTest method shouldRecoverWorkspaceWhenRecoverParameterIsNullAndAutoRestoreAttributeIsSetAndSnapshotExists.
@Test
public void shouldRecoverWorkspaceWhenRecoverParameterIsNullAndAutoRestoreAttributeIsSetAndSnapshotExists() throws Exception {
final WorkspaceImpl workspace = createAndMockWorkspace();
workspace.getAttributes().put(AUTO_RESTORE_FROM_SNAPSHOT, "true");
mockStart(workspace);
SnapshotImpl.SnapshotBuilder snapshotBuilder = SnapshotImpl.builder().generateId().setEnvName("env").setDev(true).setMachineName("machine1").setWorkspaceId(workspace.getId()).setType("docker").setMachineSource(new MachineSourceImpl("image"));
SnapshotImpl snapshot1 = snapshotBuilder.build();
SnapshotImpl snapshot2 = snapshotBuilder.generateId().setDev(false).setMachineName("machine2").build();
when(snapshotDao.findSnapshots(workspace.getId())).thenReturn(asList(snapshot1, snapshot2));
workspaceManager.startWorkspace(workspace.getId(), workspace.getConfig().getDefaultEnv(), null);
verify(runtimes).startAsync(workspace, workspace.getConfig().getDefaultEnv(), true);
assertNotNull(workspace.getAttributes().get(UPDATED_ATTRIBUTE_NAME));
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceManagerTest method snapshottedAtAttributeIncludedToWorkspaceWhenGettingByUserId.
@Test
public void snapshottedAtAttributeIncludedToWorkspaceWhenGettingByUserId() throws Exception {
WorkspaceImpl workspace = createAndMockWorkspace();
mockSnapshots(workspace, 12345);
List<WorkspaceImpl> workspaces = workspaceManager.getWorkspaces(USER_ID, false);
assertEquals(workspaces.get(0).getAttributes().get(SNAPSHOTTED_AT_ATTRIBUTE_NAME), "12345");
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceManagerTest method shouldBeAbleToGetSnapshots.
@Test
public void shouldBeAbleToGetSnapshots() throws Exception {
final WorkspaceImpl workspace = createAndMockWorkspace();
final SnapshotImpl wsSnapshot = SnapshotImpl.builder().setDev(true).setEnvName("envName").setId("snap1").setMachineName("machine1").setWorkspaceId(workspace.getId()).build();
when(snapshotDao.findSnapshots(workspace.getId())).thenReturn(singletonList(wsSnapshot));
final List<SnapshotImpl> snapshots = workspaceManager.getSnapshot(workspace.getId());
assertEquals(snapshots.size(), 1);
assertEquals(snapshots.get(0), wsSnapshot);
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceManagerTest method shouldBeAbleToGetWorkspaceByKey.
@Test
public void shouldBeAbleToGetWorkspaceByKey() throws Exception {
WorkspaceImpl workspace = createAndMockWorkspace();
WorkspaceImpl result = workspaceManager.getWorkspace(workspace.getNamespace() + "/" + workspace.getConfig().getName());
assertEquals(result, workspace);
}
Aggregations