Search in sources :

Example 21 with MachineConfigDto

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

the class ProcessesPanelPresenterTest method shouldHideStopProcessButtonAtAddingTerminal.

@Test
public void shouldHideStopProcessButtonAtAddingTerminal() 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);
    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);
    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.addCommandOutput(MACHINE_ID, outputConsole);
    presenter.onAddTerminal(MACHINE_ID, presenter);
    verify(terminalFactory).create(eq(machine), eq(presenter));
    verify(terminal).getView();
    verify(view, times(2)).setProcessesData(anyObject());
    verify(view, times(2)).selectNode(anyObject());
    verify(view).addWidget(anyString(), anyString(), anyObject(), eq(terminalWidget), anyBoolean());
    verify(view, times(1)).addProcessNode(anyObject());
    verify(terminal).setVisible(eq(true));
    verify(terminal).connect();
    verify(terminal).setListener(anyObject());
    verify(view).setStopButtonVisibility(anyString(), eq(false));
}
Also used : MachineEntity(org.eclipse.che.ide.api.machine.MachineEntity) IsWidget(com.google.gwt.user.client.ui.IsWidget) MachineDto(org.eclipse.che.api.machine.shared.dto.MachineDto) ArrayList(java.util.ArrayList) MachineConfigDto(org.eclipse.che.api.machine.shared.dto.MachineConfigDto) ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode) TerminalPresenter(org.eclipse.che.ide.extension.machine.client.perspective.terminal.TerminalPresenter) Test(org.junit.Test)

Example 22 with MachineConfigDto

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

the class MachinePanelPresenterTest method setUp.

@Before
public void setUp() {
    when(entityFactory.createMachine(machineDtoFromAPI1)).thenReturn(machine1);
    when(entityFactory.createMachine(machineDtoFromAPI2)).thenReturn(machine2);
    MachineConfigDto machineConfig1 = mock(MachineConfigDto.class);
    MachineConfigDto machineConfig2 = mock(MachineConfigDto.class);
    when(selectedMachine1.getConfig()).thenReturn(machineConfig1);
    when(selectedMachine2.getConfig()).thenReturn(machineConfig2);
    when(entityFactory.createMachineNode(isNull(MachineTreeNode.class), anyString(), Matchers.<List<MachineTreeNode>>anyObject())).thenReturn(rootNode);
    //noinspection unchecked
    when(entityFactory.createMachineNode(eq(rootNode), eq(machine2), isNull(List.class))).thenReturn(machineNode2);
    //noinspection unchecked
    when(entityFactory.createMachineNode(eq(rootNode), eq(machine1), isNull(List.class))).thenReturn(machineNode1);
    presenter = new MachinePanelPresenter(view, entityFactory, locale, appliance, eventBus, resources, appContext);
    when(appContext.getWorkspace()).thenReturn(usersWorkspace);
    when(usersWorkspace.getRuntime()).thenReturn(workspaceRuntime);
    when(usersWorkspace.getId()).thenReturn(TEXT);
}
Also used : MachineConfigDto(org.eclipse.che.api.machine.shared.dto.MachineConfigDto) List(java.util.List) Before(org.junit.Before)

Example 23 with MachineConfigDto

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

the class ProcessesPanelPresenterTest method shouldReplaceCommandOutput.

@Test
public void shouldReplaceCommandOutput() throws Exception {
    MachineEntity machine = mock(MachineEntity.class);
    when(machine.getId()).thenReturn(MACHINE_ID);
    MachineConfigDto machineConfigDto = mock(MachineConfigDto.class);
    when(machine.getConfig()).thenReturn(machineConfigDto);
    List<ProcessTreeNode> children = new ArrayList<>();
    ProcessTreeNode commandNode = new ProcessTreeNode(COMMAND_NODE, null, PROCESS_NAME, null, children);
    children.add(commandNode);
    ProcessTreeNode machineNode = new ProcessTreeNode(MACHINE_NODE, null, machine, null, children);
    children.add(machineNode);
    when(machineNode.getId()).thenReturn(MACHINE_ID);
    String commandId = commandNode.getId();
    presenter.rootNode = new ProcessTreeNode(ROOT_NODE, null, null, null, children);
    presenter.consoles.put(commandId, outputConsole);
    when(outputConsole.isFinished()).thenReturn(true);
    when(outputConsole.getTitle()).thenReturn(PROCESS_NAME);
    presenter.addCommandOutput(MACHINE_ID, outputConsole);
    verify(outputConsole).go(acceptsOneWidgetCaptor.capture());
    IsWidget widget = mock(IsWidget.class);
    acceptsOneWidgetCaptor.getValue().setWidget(widget);
    verify(view).hideProcessOutput(eq(commandId));
    verify(view).addWidget(anyString(), anyString(), anyObject(), eq(widget), anyBoolean());
    verify(view, times(2)).selectNode(anyObject());
    verify(view).getNodeById(anyString());
}
Also used : MachineEntity(org.eclipse.che.ide.api.machine.MachineEntity) IsWidget(com.google.gwt.user.client.ui.IsWidget) ArrayList(java.util.ArrayList) MachineConfigDto(org.eclipse.che.api.machine.shared.dto.MachineConfigDto) ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

MachineConfigDto (org.eclipse.che.api.machine.shared.dto.MachineConfigDto)23 Test (org.testng.annotations.Test)13 Test (org.junit.Test)7 MachineDto (org.eclipse.che.api.machine.shared.dto.MachineDto)5 MachineEntity (org.eclipse.che.ide.api.machine.MachineEntity)5 IsWidget (com.google.gwt.user.client.ui.IsWidget)4 ArrayList (java.util.ArrayList)4 Matchers.anyString (org.mockito.Matchers.anyString)4 HashMap (java.util.HashMap)3 MachineSourceDto (org.eclipse.che.api.machine.shared.dto.MachineSourceDto)3 EnvironmentDto (org.eclipse.che.api.workspace.shared.dto.EnvironmentDto)3 WorkspaceConfigDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto)3 WorkspaceRuntimeDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceRuntimeDto)3 ProcessTreeNode (org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode)3 CommandOutputConsole (org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole)2 TerminalPresenter (org.eclipse.che.ide.extension.machine.client.perspective.terminal.TerminalPresenter)2 List (java.util.List)1 MachineLimitsDto (org.eclipse.che.api.machine.shared.dto.MachineLimitsDto)1 MachineProcessDto (org.eclipse.che.api.machine.shared.dto.MachineProcessDto)1 ServerConfDto (org.eclipse.che.api.machine.shared.dto.ServerConfDto)1