Search in sources :

Example 1 with Runtime

use of org.eclipse.che.api.core.model.workspace.Runtime in project che-server by eclipse-che.

the class WorkspaceManagerTest method startsWorkspaceShouldCleanPreferences.

@Test
public void startsWorkspaceShouldCleanPreferences() throws Exception {
    final WorkspaceImpl workspace = createAndMockWorkspace();
    Runtime runtime = mockRuntime(workspace, WorkspaceStatus.RUNNING);
    workspace.setRuntime(runtime);
    mockAnyWorkspaceStart();
    workspaceManager.startWorkspace(workspace.getId(), workspace.getConfig().getDefaultEnv(), emptyMap());
    verify(runtimes).startAsync(workspace, workspace.getConfig().getDefaultEnv(), emptyMap());
    assertNotNull(workspace.getAttributes().get(UPDATED_ATTRIBUTE_NAME));
    verify(preferenceManager).remove("owner", Arrays.asList(LAST_ACTIVITY_TIME, LAST_ACTIVE_INFRASTRUCTURE_NAMESPACE));
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) Runtime(org.eclipse.che.api.core.model.workspace.Runtime) Test(org.testng.annotations.Test)

Example 2 with Runtime

use of org.eclipse.che.api.core.model.workspace.Runtime in project devspaces-images by redhat-developer.

the class WorkspaceManagerTest method startsWorkspaceShouldCleanPreferences.

@Test
public void startsWorkspaceShouldCleanPreferences() throws Exception {
    final WorkspaceImpl workspace = createAndMockWorkspace();
    Runtime runtime = mockRuntime(workspace, WorkspaceStatus.RUNNING);
    workspace.setRuntime(runtime);
    mockAnyWorkspaceStart();
    workspaceManager.startWorkspace(workspace.getId(), workspace.getConfig().getDefaultEnv(), emptyMap());
    verify(runtimes).startAsync(workspace, workspace.getConfig().getDefaultEnv(), emptyMap());
    assertNotNull(workspace.getAttributes().get(UPDATED_ATTRIBUTE_NAME));
    verify(preferenceManager).remove("owner", Arrays.asList(LAST_ACTIVITY_TIME, LAST_ACTIVE_INFRASTRUCTURE_NAMESPACE));
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) Runtime(org.eclipse.che.api.core.model.workspace.Runtime) Test(org.testng.annotations.Test)

Example 3 with Runtime

use of org.eclipse.che.api.core.model.workspace.Runtime in project che-server by eclipse-che.

the class RemoveWorkspaceBeforeAccountRemovedEventSubscriberTest method shouldThrowExceptionIfWorkspaceStopping.

@Test(expectedExceptions = ConflictException.class)
public void shouldThrowExceptionIfWorkspaceStopping() throws Exception {
    workspace.setStatus(WorkspaceStatus.STARTING);
    Runtime runtime = mock(Runtime.class);
    when(runtime.getOwner()).thenReturn(otherUser);
    workspace.setRuntime(runtime);
    EnvironmentContext.getCurrent().setSubject(SUBJECT);
    subscriber.onCascadeEvent(new BeforeAccountRemovedEvent(account));
    verify(workspaceManager).stopWorkspace(workspaceId, of(REMOVE_WORKSPACE_AFTER_STOP, "true"));
}
Also used : Runtime(org.eclipse.che.api.core.model.workspace.Runtime) BeforeAccountRemovedEvent(org.eclipse.che.account.event.BeforeAccountRemovedEvent) Test(org.testng.annotations.Test)

Example 4 with Runtime

use of org.eclipse.che.api.core.model.workspace.Runtime in project devspaces-images by redhat-developer.

the class RemoveWorkspaceBeforeAccountRemovedEventSubscriberTest method shouldThrowExceptionIfWorkspaceStopping.

@Test(expectedExceptions = ConflictException.class)
public void shouldThrowExceptionIfWorkspaceStopping() throws Exception {
    workspace.setStatus(WorkspaceStatus.STARTING);
    Runtime runtime = mock(Runtime.class);
    when(runtime.getOwner()).thenReturn(otherUser);
    workspace.setRuntime(runtime);
    EnvironmentContext.getCurrent().setSubject(SUBJECT);
    subscriber.onCascadeEvent(new BeforeAccountRemovedEvent(account));
    verify(workspaceManager).stopWorkspace(workspaceId, of(REMOVE_WORKSPACE_AFTER_STOP, "true"));
}
Also used : Runtime(org.eclipse.che.api.core.model.workspace.Runtime) BeforeAccountRemovedEvent(org.eclipse.che.account.event.BeforeAccountRemovedEvent) Test(org.testng.annotations.Test)

Aggregations

Runtime (org.eclipse.che.api.core.model.workspace.Runtime)4 Test (org.testng.annotations.Test)4 BeforeAccountRemovedEvent (org.eclipse.che.account.event.BeforeAccountRemovedEvent)2 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)2