use of org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode in project che by eclipse.
the class ProcessesPanelPresenterTest method stopButtonStateShouldBeRefreshedWhenConsoleHasRunningProcess.
@Test
public void stopButtonStateShouldBeRefreshedWhenConsoleHasRunningProcess() {
ProcessTreeNode commandNode = mock(ProcessTreeNode.class);
when(commandNode.getId()).thenReturn(PROCESS_ID);
when(outputConsole.isFinished()).thenReturn(false);
presenter.consoles.put(PROCESS_ID, outputConsole);
presenter.onTreeNodeSelected(commandNode);
verify(view).setStopButtonVisibility(PROCESS_ID, true);
}
use of org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode in project che by eclipse.
the class ProcessesPanelPresenterTest method shouldShowTerminalWhenTerminalNodeSelected.
@Test
public void shouldShowTerminalWhenTerminalNodeSelected() throws Exception {
TerminalPresenter terminal = mock(TerminalPresenter.class);
presenter.terminals.put(PROCESS_ID, terminal);
ProcessTreeNode terminalNode = mock(ProcessTreeNode.class);
when(terminalNode.getId()).thenReturn(PROCESS_ID);
presenter.onTreeNodeSelected(terminalNode);
verify(view).showProcessOutput(eq(PROCESS_ID));
verify(view, never()).setStopButtonVisibility(PROCESS_ID, true);
}
use of org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode in project che by eclipse.
the class ProcessesPanelPresenterTest method shouldAddTerminal.
@Test
public void shouldAddTerminal() throws Exception {
MachineDto machineDto = mock(MachineDto.class);
MachineEntity machine = mock(MachineEntity.class);
when(machine.getId()).thenReturn(MACHINE_ID);
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<>(1);
machines.add(machineDto);
when(workspaceRuntime.getMachines()).thenReturn(machines);
when(entityFactory.createMachine(machineDto)).thenReturn(machine);
presenter.rootNode = new ProcessTreeNode(ROOT_NODE, null, null, null, new ArrayList<ProcessTreeNode>());
TerminalPresenter terminal = mock(TerminalPresenter.class);
when(terminalFactory.create(machine, presenter)).thenReturn(terminal);
IsWidget terminalWidget = mock(IsWidget.class);
when(terminal.getView()).thenReturn(terminalWidget);
when(terminalWidget.asWidget()).thenReturn(widget);
presenter.onAddTerminal(MACHINE_ID, presenter);
verify(terminalFactory).create(eq(machine), eq(presenter));
verify(workspaceAgent).setActivePart(presenter);
verify(terminal).getView();
verify(view, times(2)).setProcessesData(anyObject());
verify(view).selectNode(anyObject());
verify(view).addWidget(anyString(), anyString(), anyObject(), eq(terminalWidget), anyBoolean());
verify(view).addProcessNode(anyObject());
verify(terminal).setVisible(eq(true));
verify(terminal).connect();
verify(terminal).setListener(anyObject());
}
use of org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode in project che by eclipse.
the class ProcessesPanelPresenterTest method shouldDisplayStopProcessButtonAtAddingCommand.
@Test
public void shouldDisplayStopProcessButtonAtAddingCommand() throws Exception {
ProcessTreeNode machineNode = mock(ProcessTreeNode.class);
when(machineNode.getId()).thenReturn(MACHINE_ID);
List<ProcessTreeNode> children = new ArrayList<>();
children.add(machineNode);
presenter.rootNode = new ProcessTreeNode(ROOT_NODE, null, null, null, children);
ProcessTreeNode selectedCommandNode = new ProcessTreeNode(COMMAND_NODE, null, PROCESS_NAME, null, children);
children.add(selectedCommandNode);
when(outputConsole.isFinished()).thenReturn(false);
presenter.consoles.clear();
presenter.addCommandOutput(MACHINE_ID, outputConsole);
verify(view, never()).hideProcessOutput(anyString());
verify(outputConsole).go(acceptsOneWidgetCaptor.capture());
IsWidget widget = mock(IsWidget.class);
acceptsOneWidgetCaptor.getValue().setWidget(widget);
verify(view).addProcessNode(anyObject());
verify(view).addWidget(anyString(), anyString(), anyObject(), eq(widget), anyBoolean());
verify(view, times(2)).selectNode(anyObject());
verify(view).setProcessesData(anyObject());
verify(view).getNodeById(anyString());
verify(view).setStopButtonVisibility(anyString(), eq(true));
}
use of org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode in project che by eclipse.
the class ProcessesPanelPresenterTest method shouldCloseCommandOutputWhenCommandHasFinished.
@Test
public void shouldCloseCommandOutputWhenCommandHasFinished() throws Exception {
ProcessTreeNode machineNode = mock(ProcessTreeNode.class);
ProcessTreeNode commandNode = mock(ProcessTreeNode.class);
when(machineNode.getId()).thenReturn(MACHINE_ID);
List<ProcessTreeNode> children = new ArrayList<>();
children.add(machineNode);
presenter.rootNode = new ProcessTreeNode(ROOT_NODE, null, null, null, children);
when(outputConsole.isFinished()).thenReturn(true);
presenter.consoles.put(PROCESS_ID, outputConsole);
machineNode.getChildren().add(commandNode);
when(commandNode.getId()).thenReturn(PROCESS_ID);
when(view.getNodeIndex(anyString())).thenReturn(0);
when(machineNode.getChildren()).thenReturn(children);
when(commandNode.getParent()).thenReturn(machineNode);
presenter.onCloseCommandOutputClick(commandNode);
verify(commandNode, times(3)).getId();
verify(commandNode).getParent();
verify(view).getNodeIndex(eq(PROCESS_ID));
verify(view).hideProcessOutput(eq(PROCESS_ID));
verify(view).removeProcessNode(eq(commandNode));
verify(view).setProcessesData(anyObject());
}
Aggregations