Search in sources :

Example 1 with WorkspaceConfig

use of org.eclipse.che.api.core.model.workspace.WorkspaceConfig in project che by eclipse.

the class WorkspaceManagerTest method shouldBeAbleToGetWorkspacesAvailableForUser.

@Test
public void shouldBeAbleToGetWorkspacesAvailableForUser() throws Exception {
    // given
    final WorkspaceConfig config = createConfig();
    final WorkspaceImpl workspace1 = createAndMockWorkspace(config, NAMESPACE);
    final WorkspaceImpl workspace2 = createAndMockWorkspace(config, NAMESPACE_2);
    when(workspaceDao.getWorkspaces(NAMESPACE)).thenReturn(asList(workspace1, workspace2));
    mockRuntime(workspace1, STOPPED);
    mockRuntime(workspace2, RUNNING);
    // when
    final List<WorkspaceImpl> result = workspaceManager.getWorkspaces(NAMESPACE, true);
    // then
    assertEquals(result.size(), 2);
    final WorkspaceImpl res1 = result.get(0);
    assertEquals(res1.getStatus(), STOPPED);
    assertFalse(res1.isTemporary(), "Workspace must be permanent");
    final WorkspaceImpl res2 = result.get(1);
    assertEquals(res2.getStatus(), RUNNING, "Workspace status wasn't changed to the runtime instance status");
    assertFalse(res2.isTemporary(), "Workspace must be permanent");
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) WorkspaceConfig(org.eclipse.che.api.core.model.workspace.WorkspaceConfig) Test(org.testng.annotations.Test)

Example 2 with WorkspaceConfig

use of org.eclipse.che.api.core.model.workspace.WorkspaceConfig in project che by eclipse.

the class ProcessesPanelPresenter method hasAgent.

/**
     * Determines the agent is injected in the specified machine.
     *
     * @param machineName
     *          machine name
     * @param agent
     *          agent
     * @return
     *          <b>true</b> is the agent is injected, otherwise return <b>false</b>
     */
private boolean hasAgent(String machineName, String agent) {
    Workspace workspace = appContext.getWorkspace();
    if (workspace == null) {
        return false;
    }
    WorkspaceConfig workspaceConfig = workspace.getConfig();
    if (workspaceConfig == null) {
        return false;
    }
    Map<String, ? extends Environment> environments = workspaceConfig.getEnvironments();
    if (environments == null) {
        return false;
    }
    for (Environment environment : environments.values()) {
        ExtendedMachine extendedMachine = environment.getMachines().get(machineName);
        if (extendedMachine != null) {
            if (extendedMachine.getAgents() != null && extendedMachine.getAgents().contains(agent)) {
                return true;
            }
        }
    }
    return false;
}
Also used : WorkspaceConfig(org.eclipse.che.api.core.model.workspace.WorkspaceConfig) Environment(org.eclipse.che.api.core.model.workspace.Environment) ExtendedMachine(org.eclipse.che.api.core.model.workspace.ExtendedMachine) Workspace(org.eclipse.che.api.core.model.workspace.Workspace)

Example 3 with WorkspaceConfig

use of org.eclipse.che.api.core.model.workspace.WorkspaceConfig in project che by eclipse.

the class WorkspaceManagerTest method shouldBeAbleToCreateWorkspace.

@Test
public void shouldBeAbleToCreateWorkspace() throws Exception {
    final WorkspaceConfig cfg = createConfig();
    final WorkspaceImpl workspace = workspaceManager.createWorkspace(cfg, NAMESPACE);
    assertNotNull(workspace);
    assertFalse(isNullOrEmpty(workspace.getId()));
    assertEquals(workspace.getNamespace(), NAMESPACE);
    assertEquals(workspace.getConfig(), cfg);
    assertFalse(workspace.isTemporary());
    assertEquals(workspace.getStatus(), STOPPED);
    assertNotNull(workspace.getAttributes().get(CREATED_ATTRIBUTE_NAME));
    verify(workspaceDao).create(workspace);
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) WorkspaceConfig(org.eclipse.che.api.core.model.workspace.WorkspaceConfig) Test(org.testng.annotations.Test)

Aggregations

WorkspaceConfig (org.eclipse.che.api.core.model.workspace.WorkspaceConfig)3 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)2 Test (org.testng.annotations.Test)2 Environment (org.eclipse.che.api.core.model.workspace.Environment)1 ExtendedMachine (org.eclipse.che.api.core.model.workspace.ExtendedMachine)1 Workspace (org.eclipse.che.api.core.model.workspace.Workspace)1