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));
}
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));
}
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));
}
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);
}
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));
}
Aggregations