Search in sources :

Example 1 with MachineProcessDto

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

the class ProcessesPanelPresenterTest method commandShouldBeRestoredWhenWsAgentIsStarted.

@Test
public void commandShouldBeRestoredWhenWsAgentIsStarted() throws Exception {
    WsAgentStateEvent event = mock(WsAgentStateEvent.class);
    MachineEntity machineEntity = mock(MachineEntity.class);
    MachineDto machine = mock(MachineDto.class);
    when(machineEntity.getId()).thenReturn(MACHINE_ID);
    when(machineEntity.getWorkspaceId()).thenReturn(WORKSPACE_ID);
    when(entityFactory.createMachine(machine)).thenReturn(machineEntity);
    MachineConfigDto machineConfigDto = mock(MachineConfigDto.class);
    when(machine.getConfig()).thenReturn(machineConfigDto);
    when(machineConfigDto.isDev()).thenReturn(true);
    when(machine.getStatus()).thenReturn(MachineStatus.RUNNING);
    List<MachineDto> machines = new ArrayList<>(2);
    machines.add(machine);
    when(workspaceRuntime.getMachines()).thenReturn(machines);
    MachineProcessDto machineProcessDto = mock(MachineProcessDto.class);
    when(machineProcessDto.getOutputChannel()).thenReturn(OUTPUT_CHANNEL);
    when(machineProcessDto.getPid()).thenReturn(PID);
    List<MachineProcessDto> processes = new ArrayList<>(1);
    processes.add(machineProcessDto);
    CommandOutputConsole outputConsole = mock(CommandOutputConsole.class);
    CommandType commandType = mock(CommandType.class);
    when(commandTypeRegistry.getCommandTypeById(anyString())).thenReturn(commandType);
    when(commandConsoleFactory.create(anyObject(), any(org.eclipse.che.api.core.model.machine.Machine.class))).thenReturn(outputConsole);
    presenter.onWsAgentStarted(event);
}
Also used : MachineEntity(org.eclipse.che.ide.api.machine.MachineEntity) ArrayList(java.util.ArrayList) MachineConfigDto(org.eclipse.che.api.machine.shared.dto.MachineConfigDto) MachineProcessDto(org.eclipse.che.api.machine.shared.dto.MachineProcessDto) DevMachine(org.eclipse.che.ide.api.machine.DevMachine) MachineDto(org.eclipse.che.api.machine.shared.dto.MachineDto) CommandType(org.eclipse.che.ide.api.command.CommandType) CommandOutputConsole(org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole) WsAgentStateEvent(org.eclipse.che.ide.api.machine.events.WsAgentStateEvent) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 MachineConfigDto (org.eclipse.che.api.machine.shared.dto.MachineConfigDto)1 MachineDto (org.eclipse.che.api.machine.shared.dto.MachineDto)1 MachineProcessDto (org.eclipse.che.api.machine.shared.dto.MachineProcessDto)1 CommandType (org.eclipse.che.ide.api.command.CommandType)1 DevMachine (org.eclipse.che.ide.api.machine.DevMachine)1 MachineEntity (org.eclipse.che.ide.api.machine.MachineEntity)1 WsAgentStateEvent (org.eclipse.che.ide.api.machine.events.WsAgentStateEvent)1 CommandOutputConsole (org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole)1 Test (org.junit.Test)1