Search in sources :

Example 6 with MachineDto

use of org.eclipse.che.api.machine.shared.dto.MachineDto in project che by eclipse.

the class WorkspaceEventsHandlerTest method onWsAgentOutputEventReceivedTest.

@Test
public void onWsAgentOutputEventReceivedTest() throws Exception {
    WorkspaceRuntimeDto runtime = mock(WorkspaceRuntimeDto.class);
    WorkspaceConfigDto workspaceConfig = mock(WorkspaceConfigDto.class);
    when(workspace.getRuntime()).thenReturn(runtime);
    MachineDto devMachine = mock(MachineDto.class);
    when(devMachine.getWorkspaceId()).thenReturn(WORKSPACE_ID);
    when(devMachine.getId()).thenReturn(MACHINE_NAME);
    when(runtime.getDevMachine()).thenReturn(devMachine);
    when(runtime.getActiveEnv()).thenReturn(ACTIVE_ENV);
    when(workspace.getConfig()).thenReturn(workspaceConfig);
    Map<String, EnvironmentDto> environments = new HashMap<>(3);
    EnvironmentDto environment = mock(EnvironmentDto.class);
    environments.put(ACTIVE_ENV, environment);
    when(workspaceConfig.getEnvironments()).thenReturn(environments);
    MachineConfigDto devMachineConfig = mock(MachineConfigDto.class);
    when(devMachineConfig.getName()).thenReturn(MACHINE_NAME);
    workspaceEventsHandler.trackWorkspaceEvents(workspace, callback);
    workspaceEventsHandler.wsAgentLogSubscriptionHandler.onMessageReceived("");
    verify(eventBus).fireEvent(Matchers.<EnvironmentOutputEvent>anyObject());
}
Also used : WorkspaceRuntimeDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceRuntimeDto) MachineDto(org.eclipse.che.api.machine.shared.dto.MachineDto) HashMap(java.util.HashMap) EnvironmentDto(org.eclipse.che.api.workspace.shared.dto.EnvironmentDto) WorkspaceConfigDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto) MachineConfigDto(org.eclipse.che.api.machine.shared.dto.MachineConfigDto) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 7 with MachineDto

use of org.eclipse.che.api.machine.shared.dto.MachineDto in project che by eclipse.

the class SelectCommandComboBox method getMachines.

private List<MachineEntity> getMachines(Workspace workspace) {
    WorkspaceRuntime workspaceRuntime = workspace.getRuntime();
    if (workspaceRuntime == null) {
        return emptyList();
    }
    List<? extends Machine> runtimeMachines = workspaceRuntime.getMachines();
    List<MachineEntity> machines = new ArrayList<>(runtimeMachines.size());
    for (Machine machine : runtimeMachines) {
        if (machine instanceof MachineDto) {
            MachineEntity machineEntity = entityFactory.createMachine((MachineDto) machine);
            machines.add(machineEntity);
        }
    }
    return machines;
}
Also used : MachineEntity(org.eclipse.che.ide.api.machine.MachineEntity) MachineDto(org.eclipse.che.api.machine.shared.dto.MachineDto) WorkspaceRuntime(org.eclipse.che.api.core.model.workspace.WorkspaceRuntime) ArrayList(java.util.ArrayList) Machine(org.eclipse.che.api.core.model.machine.Machine)

Example 8 with MachineDto

use of org.eclipse.che.api.machine.shared.dto.MachineDto in project che by eclipse.

the class MachinePanelPresenter method getMachines.

private List<MachineEntity> getMachines(Workspace workspace) {
    WorkspaceRuntime workspaceRuntime = workspace.getRuntime();
    if (workspaceRuntime == null) {
        return emptyList();
    }
    List<? extends Machine> runtimeMachines = workspaceRuntime.getMachines();
    List<MachineEntity> machines = new ArrayList<>(runtimeMachines.size());
    for (Machine machine : runtimeMachines) {
        if (machine instanceof MachineDto) {
            MachineEntity machineEntity = entityFactory.createMachine((MachineDto) machine);
            machines.add(machineEntity);
        }
    }
    return machines;
}
Also used : MachineEntity(org.eclipse.che.ide.api.machine.MachineEntity) MachineDto(org.eclipse.che.api.machine.shared.dto.MachineDto) WorkspaceRuntime(org.eclipse.che.api.core.model.workspace.WorkspaceRuntime) ArrayList(java.util.ArrayList) Machine(org.eclipse.che.api.core.model.machine.Machine)

Example 9 with MachineDto

use of org.eclipse.che.api.machine.shared.dto.MachineDto in project che by eclipse.

the class WorkspaceEventsHandlerTest method shouldSubscribeOnWsAgentOutputWhenWorkspaceIsRunningAfterRefreshPage.

@Test
public void shouldSubscribeOnWsAgentOutputWhenWorkspaceIsRunningAfterRefreshPage() throws Exception {
    WorkspaceRuntimeDto runtime = mock(WorkspaceRuntimeDto.class);
    WorkspaceConfigDto workspaceConfig = mock(WorkspaceConfigDto.class);
    when(workspace.getRuntime()).thenReturn(runtime);
    MachineDto devMachine = mock(MachineDto.class);
    when(devMachine.getWorkspaceId()).thenReturn(WORKSPACE_ID);
    when(devMachine.getId()).thenReturn(MACHINE_NAME);
    when(runtime.getDevMachine()).thenReturn(devMachine);
    when(runtime.getActiveEnv()).thenReturn(ACTIVE_ENV);
    when(workspace.getConfig()).thenReturn(workspaceConfig);
    Map<String, EnvironmentDto> environments = new HashMap<>(3);
    EnvironmentDto environment = mock(EnvironmentDto.class);
    environments.put(ACTIVE_ENV, environment);
    when(workspaceConfig.getEnvironments()).thenReturn(environments);
    MachineConfigDto devMachineConfig = mock(MachineConfigDto.class);
    when(devMachineConfig.getName()).thenReturn(MACHINE_NAME);
    workspaceEventsHandler.trackWorkspaceEvents(workspace, callback);
    verify(messageBus).subscribe(eq(WS_AGENT_LOG_CHANNEL), (MessageHandler) anyObject());
}
Also used : WorkspaceRuntimeDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceRuntimeDto) MachineDto(org.eclipse.che.api.machine.shared.dto.MachineDto) HashMap(java.util.HashMap) EnvironmentDto(org.eclipse.che.api.workspace.shared.dto.EnvironmentDto) WorkspaceConfigDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto) MachineConfigDto(org.eclipse.che.api.machine.shared.dto.MachineConfigDto) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 10 with MachineDto

use of org.eclipse.che.api.machine.shared.dto.MachineDto in project che by eclipse.

the class GdbConfigurationPagePresenter method getMachines.

private List<Machine> getMachines() {
    Workspace workspace = appContext.getWorkspace();
    if (workspace == null || workspace.getRuntime() == null) {
        return emptyList();
    }
    List<? extends Machine> runtimeMachines = workspace.getRuntime().getMachines();
    List<Machine> machines = new ArrayList<>(runtimeMachines.size());
    for (Machine currentMachine : runtimeMachines) {
        if (currentMachine instanceof MachineDto) {
            Machine machine = entityFactory.createMachine((MachineDto) currentMachine);
            machines.add(machine);
        }
    }
    return machines;
}
Also used : MachineDto(org.eclipse.che.api.machine.shared.dto.MachineDto) ArrayList(java.util.ArrayList) Machine(org.eclipse.che.api.core.model.machine.Machine) Workspace(org.eclipse.che.api.core.model.workspace.Workspace)

Aggregations

MachineDto (org.eclipse.che.api.machine.shared.dto.MachineDto)13 ArrayList (java.util.ArrayList)7 MachineConfigDto (org.eclipse.che.api.machine.shared.dto.MachineConfigDto)6 MachineEntity (org.eclipse.che.ide.api.machine.MachineEntity)6 Test (org.junit.Test)5 Machine (org.eclipse.che.api.core.model.machine.Machine)4 WorkspaceRuntime (org.eclipse.che.api.core.model.workspace.WorkspaceRuntime)3 WorkspaceRuntimeDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceRuntimeDto)3 IsWidget (com.google.gwt.user.client.ui.IsWidget)2 HashMap (java.util.HashMap)2 ServerDto (org.eclipse.che.api.machine.shared.dto.ServerDto)2 EnvironmentDto (org.eclipse.che.api.workspace.shared.dto.EnvironmentDto)2 WorkspaceConfigDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto)2 DevMachine (org.eclipse.che.ide.api.machine.DevMachine)2 CommandOutputConsole (org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole)2 TerminalPresenter (org.eclipse.che.ide.extension.machine.client.perspective.terminal.TerminalPresenter)2 ProcessTreeNode (org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode)2 Matchers.anyString (org.mockito.Matchers.anyString)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Sets (com.google.common.collect.Sets)1