Search in sources :

Example 1 with MachineStateEvent

use of org.eclipse.che.ide.api.machine.events.MachineStateEvent in project che by eclipse.

the class MachinePanelPresenterTest method machineShouldBeSelectedWhenItIsRunning.

@Test
public void machineShouldBeSelectedWhenItIsRunning() {
    when(machine1.getId()).thenReturn("machine1");
    MachineStateEvent stateEvent = mock(MachineStateEvent.class);
    when(stateEvent.getMachine()).thenReturn(machine1);
    presenter.onMachineCreating(stateEvent);
    reset(view);
    presenter.onMachineRunning(stateEvent);
    verify(view).selectNode(machineNode1);
    assertThat(presenter.isMachineRunning(), is(true));
}
Also used : MachineStateEvent(org.eclipse.che.ide.api.machine.events.MachineStateEvent) Test(org.junit.Test)

Example 2 with MachineStateEvent

use of org.eclipse.che.ide.api.machine.events.MachineStateEvent in project che by eclipse.

the class ProcessesPanelPresenterTest method shouldAddMachineWhenMachineCreating.

@Test
public void shouldAddMachineWhenMachineCreating() throws Exception {
    MachineEntity machine = mock(MachineEntity.class);
    MachineConfigDto machineConfigDto = mock(MachineConfigDto.class);
    OutputConsole outputConsole = mock(OutputConsole.class);
    when(machineConfigDto.getName()).thenReturn(MACHINE_NAME);
    when(machine.getConfig()).thenReturn(machineConfigDto);
    when(appContext.getWorkspaceId()).thenReturn(WORKSPACE_ID);
    when(commandConsoleFactory.create(eq(MACHINE_NAME))).thenReturn(outputConsole);
    MachineStateEvent machineStateEvent = mock(MachineStateEvent.class);
    when(machineStateEvent.getMachine()).thenReturn(machine);
    verify(eventBus, times(8)).addHandler(anyObject(), machineStateHandlerCaptor.capture());
    MachineStateEvent.Handler machineStateHandler = machineStateHandlerCaptor.getAllValues().get(0);
    machineStateHandler.onMachineCreating(machineStateEvent);
    verify(outputConsole).go(acceptsOneWidgetCaptor.capture());
    IsWidget widget = mock(IsWidget.class);
    acceptsOneWidgetCaptor.getValue().setWidget(widget);
    verify(commandConsoleFactory).create(eq(MACHINE_NAME));
    verify(view).addWidget(anyString(), anyString(), anyObject(), anyObject(), anyBoolean());
    verify(view).setProcessesData(eq(presenter.rootNode));
}
Also used : MachineEntity(org.eclipse.che.ide.api.machine.MachineEntity) IsWidget(com.google.gwt.user.client.ui.IsWidget) MachineStateEvent(org.eclipse.che.ide.api.machine.events.MachineStateEvent) CommandOutputConsole(org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole) OutputConsole(org.eclipse.che.ide.api.outputconsole.OutputConsole) MachineConfigDto(org.eclipse.che.api.machine.shared.dto.MachineConfigDto) Test(org.junit.Test)

Example 3 with MachineStateEvent

use of org.eclipse.che.ide.api.machine.events.MachineStateEvent in project che by eclipse.

the class MachineStatusHandler method handleMachineRunning.

private void handleMachineRunning(final String machineId, final WorkspaceRuntimeDto workspaceRuntime) {
    final MachineEntity machine = getMachine(machineId, workspaceRuntime);
    if (machine == null) {
        return;
    }
    eventBus.fireEvent(new MachineStateEvent(machine, RUNNING));
}
Also used : MachineEntity(org.eclipse.che.ide.api.machine.MachineEntity) MachineStateEvent(org.eclipse.che.ide.api.machine.events.MachineStateEvent)

Example 4 with MachineStateEvent

use of org.eclipse.che.ide.api.machine.events.MachineStateEvent in project che by eclipse.

the class SshCategoryPresenter method disconnect.

/**
     * Destroys the machine.
     *
     * @param machine
     *         machine to destroy
     */
private void disconnect(final MachineEntity machine) {
    if (machine == null || machine.getStatus() != RUNNING) {
        updateTargets(null);
        return;
    }
    sshView.setConnectButtonText(null);
    eventBus.fireEvent(new MachineStateEvent(machine, DESTROYED));
    notificationManager.notify(machineLocale.targetsViewDisconnectSuccess(selectedTarget.getName()), SUCCESS, FLOAT_MODE);
    updateTargets(null);
}
Also used : MachineStateEvent(org.eclipse.che.ide.api.machine.events.MachineStateEvent)

Example 5 with MachineStateEvent

use of org.eclipse.che.ide.api.machine.events.MachineStateEvent in project che by eclipse.

the class MachineStatusHandler method handleMachineCreating.

private void handleMachineCreating(final String machineId, final WorkspaceRuntimeDto workspaceRuntime) {
    final MachineEntity machine = getMachine(machineId, workspaceRuntime);
    if (machine == null) {
        return;
    }
    eventBus.fireEvent(new MachineStateEvent(machine, CREATING));
}
Also used : MachineEntity(org.eclipse.che.ide.api.machine.MachineEntity) MachineStateEvent(org.eclipse.che.ide.api.machine.events.MachineStateEvent)

Aggregations

MachineStateEvent (org.eclipse.che.ide.api.machine.events.MachineStateEvent)7 Test (org.junit.Test)4 MachineEntity (org.eclipse.che.ide.api.machine.MachineEntity)3 IsWidget (com.google.gwt.user.client.ui.IsWidget)1 MachineConfigDto (org.eclipse.che.api.machine.shared.dto.MachineConfigDto)1 OutputConsole (org.eclipse.che.ide.api.outputconsole.OutputConsole)1 CommandOutputConsole (org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole)1