use of org.eclipse.che.api.machine.shared.dto.MachineConfigDto in project che by eclipse.
the class CheEnvironmentValidatorTest method shouldFailValidationIfEnvVarNameIsNull.
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Machine '.*' contains environment variable with null or empty name")
public void shouldFailValidationIfEnvVarNameIsNull() throws Exception {
MachineConfigDto config = createMachineConfig();
config.getEnvVariables().put(null, "value");
environmentValidator.validateMachine(config);
}
use of org.eclipse.che.api.machine.shared.dto.MachineConfigDto 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.api.machine.shared.dto.MachineConfigDto 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.api.machine.shared.dto.MachineConfigDto in project che by eclipse.
the class ProcessesPanelPresenterTest method commandShouldBeRestoredWhenWsAgentIsStarted.
@Test
public void commandShouldBeRestoredWhenWsAgentIsStarted() throws Exception {
WsAgentStateEvent event = mock(WsAgentStateEvent.class);
MachineEntity machineEntity = mock(MachineEntity.class);
MachineDto machine = mock(MachineDto.class);
when(machineEntity.getId()).thenReturn(MACHINE_ID);
when(machineEntity.getWorkspaceId()).thenReturn(WORKSPACE_ID);
when(entityFactory.createMachine(machine)).thenReturn(machineEntity);
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<>(2);
machines.add(machine);
when(workspaceRuntime.getMachines()).thenReturn(machines);
MachineProcessDto machineProcessDto = mock(MachineProcessDto.class);
when(machineProcessDto.getOutputChannel()).thenReturn(OUTPUT_CHANNEL);
when(machineProcessDto.getPid()).thenReturn(PID);
List<MachineProcessDto> processes = new ArrayList<>(1);
processes.add(machineProcessDto);
CommandOutputConsole outputConsole = mock(CommandOutputConsole.class);
CommandType commandType = mock(CommandType.class);
when(commandTypeRegistry.getCommandTypeById(anyString())).thenReturn(commandType);
when(commandConsoleFactory.create(anyObject(), any(org.eclipse.che.api.core.model.machine.Machine.class))).thenReturn(outputConsole);
presenter.onWsAgentStarted(event);
}
use of org.eclipse.che.api.machine.shared.dto.MachineConfigDto in project che by eclipse.
the class SshCategoryPresenter method connect.
/**
* Opens a connection to the selected target.
* Starts a machine based on the selected recipe.
*/
private void connect() {
sshView.setConnectButtonText(null);
connectTargetName = selectedTarget.getName();
connectNotification = notificationManager.notify(machineLocale.targetsViewConnectProgress(selectedTarget.getName()), PROGRESS, FLOAT_MODE);
String recipeURL = selectedTarget.getRecipe().getLink("get recipe script").getHref();
MachineLimitsDto limitsDto = dtoFactory.createDto(MachineLimitsDto.class).withRam(1024);
MachineSourceDto sourceDto = dtoFactory.createDto(MachineSourceDto.class).withType("ssh-config").withLocation(recipeURL);
MachineConfigDto configDto = dtoFactory.createDto(MachineConfigDto.class).withDev(false).withName(selectedTarget.getName()).withSource(sourceDto).withLimits(limitsDto).withType(getCategory());
Promise<Void> machinePromise = workspaceServiceClient.createMachine(appContext.getWorkspaceId(), configDto);
machinePromise.then(new Operation<Void>() {
@Override
public void apply(Void arg) throws OperationException {
}
});
machinePromise.catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError promiseError) throws OperationException {
onConnectingFailed(null);
}
});
}
Aggregations