@Test public void shouldStopProcessWithoutCloseCommanOutput() 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(false); presenter.consoles.put(PROCESS_ID, outputConsole); //noinspection ConstantConditions 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.onStopCommandProcess(commandNode); verify(outputConsole).stop(); verify(view, never()).hideProcessOutput(eq(PROCESS_ID)); verify(view, never()).removeProcessNode(eq(commandNode)); }
@Override public void onMachineDestroyed(MachineStateEvent event) { String destroyedMachineId = event.getMachineId(); ProcessTreeNode destroyedMachineNode = machineNodes.get(destroyedMachineId); if (destroyedMachineNode == null) { return; } rootChildren.remove(destroyedMachineNode); onCloseTerminal(destroyedMachineNode); onStopCommandProcess(destroyedMachineNode); view.setProcessesData(rootNode); }