Search in sources :

Example 6 with MachineConfigDto

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);
}
Also used : MachineConfigDto(org.eclipse.che.api.machine.shared.dto.MachineConfigDto) Test(org.testng.annotations.Test)

Example 7 with MachineConfigDto

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));
}
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 8 with MachineConfigDto

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());
}
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 9 with MachineConfigDto

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);
}
Also used : MachineEntity(org.eclipse.che.ide.api.machine.MachineEntity) ArrayList(java.util.ArrayList) MachineConfigDto(org.eclipse.che.api.machine.shared.dto.MachineConfigDto) MachineProcessDto(org.eclipse.che.api.machine.shared.dto.MachineProcessDto) DevMachine(org.eclipse.che.ide.api.machine.DevMachine) MachineDto(org.eclipse.che.api.machine.shared.dto.MachineDto) CommandType(org.eclipse.che.ide.api.command.CommandType) CommandOutputConsole(org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole) WsAgentStateEvent(org.eclipse.che.ide.api.machine.events.WsAgentStateEvent) Test(org.junit.Test)

Example 10 with MachineConfigDto

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);
        }
    });
}
Also used : PromiseError(org.eclipse.che.api.promises.client.PromiseError) MachineLimitsDto(org.eclipse.che.api.machine.shared.dto.MachineLimitsDto) MachineConfigDto(org.eclipse.che.api.machine.shared.dto.MachineConfigDto) MachineSourceDto(org.eclipse.che.api.machine.shared.dto.MachineSourceDto) OperationException(org.eclipse.che.api.promises.client.OperationException)

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