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