Search in sources :

Example 96 with WorkspaceImpl

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());
}
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 97 with WorkspaceImpl

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));
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) SnapshotImpl(org.eclipse.che.api.machine.server.model.impl.SnapshotImpl) MachineSourceImpl(org.eclipse.che.api.machine.server.model.impl.MachineSourceImpl) Test(org.testng.annotations.Test)

Example 98 with WorkspaceImpl

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");
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) Test(org.testng.annotations.Test)

Example 99 with WorkspaceImpl

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);
}
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 100 with WorkspaceImpl

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