Search in sources :

Example 1 with DevMachine

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

the class ProjectServiceClientImplTest method setUp.

@Before
public void setUp() throws Exception {
    projectServiceClient = new ProjectServiceClientImpl(wsAgentStateController, loaderFactory, asyncRequestFactory, dtoFactory, dtoUnmarshallerFactory, appContext);
    DevMachine devMachine = mock(DevMachine.class);
    when(devMachine.getWsAgentBaseUrl()).thenReturn("");
    when(appContext.getDevMachine()).thenReturn(devMachine);
}
Also used : DevMachine(org.eclipse.che.ide.api.machine.DevMachine) Before(org.junit.Before)

Example 2 with DevMachine

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

the class JsonRpcWebSocketAgentEventListener method onWsAgentStopped.

@Override
public void onWsAgentStopped(WsAgentStateEvent event) {
    DevMachine devMachine = appContext.getDevMachine();
    String devMachineId = devMachine.getId();
    Log.debug(JsonRpcWebSocketAgentEventListener.class, "Web socket agent stopped event caught.");
    initializer.terminate("ws-agent");
    initializer.terminate(devMachineId);
}
Also used : DevMachine(org.eclipse.che.ide.api.machine.DevMachine)

Example 3 with DevMachine

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

the class DownloadWsActionTest method actionShouldBePerformed.

@Test
public void actionShouldBePerformed() throws Exception {
    String baseUrl = "baseUrl";
    DevMachine devMachine = mock(DevMachine.class);
    when(appContext.getDevMachine()).thenReturn(devMachine);
    when(devMachine.getWsAgentBaseUrl()).thenReturn(baseUrl);
    when(wsAgentURLModifier.modify(anyString())).thenReturn(baseUrl);
    action.actionPerformed(actionEvent);
    verify(downloadContainer).setUrl(eq(baseUrl));
}
Also used : DevMachine(org.eclipse.che.ide.api.machine.DevMachine) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 4 with DevMachine

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

the class BaseTest method disarm.

@Before
public void disarm() {
    when(project.getName()).thenReturn(PROJECT_NAME);
    when(project.getLocation()).thenReturn(Path.valueOf(PROJECT_PATH));
    when(gitOutputConsoleFactory.create(anyString())).thenReturn(console);
    when(file_1.getLocation()).thenReturn(Path.valueOf(FILE_1_PATH));
    when(file_2.getLocation()).thenReturn(Path.valueOf(FILE_2_PATH));
    when(folder_1.getLocation()).thenReturn(Path.valueOf(FOLDER_1_PATH));
    when(folder_2.getLocation()).thenReturn(Path.valueOf(FOLDER_2_PATH));
    when(promiseError.getMessage()).thenReturn("error");
    when(promiseError.getCause()).thenReturn(throwable);
    when(throwable.getMessage()).thenReturn("error");
    when(project.synchronize()).thenReturn(synchronizePromise);
    DevMachine devMachine = mock(DevMachine.class);
    when(devMachine.getId()).thenReturn("id");
    when(appContext.getDevMachine()).thenReturn(devMachine);
}
Also used : DevMachine(org.eclipse.che.ide.api.machine.DevMachine) Before(org.junit.Before)

Example 5 with DevMachine

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

the class AddToIndexPresenter method onAddClicked.

/** {@inheritDoc} */
@Override
public void onAddClicked() {
    DevMachine devMachine = appContext.getDevMachine();
    Resource[] resources = appContext.getResources();
    Path projectLocation = appContext.getRootProject().getLocation();
    Path[] paths = new Path[resources.length];
    for (int i = 0; i < resources.length; i++) {
        Path path = resources[i].getLocation().removeFirstSegments(projectLocation.segmentCount());
        paths[i] = path.segmentCount() == 0 ? Path.EMPTY : path;
    }
    final GitOutputConsole console = gitOutputConsoleFactory.create(constant.addToIndexCommandName());
    consolesPanelPresenter.addCommandOutput(devMachine.getId(), console);
    service.add(devMachine, projectLocation, view.isUpdated(), paths).then(new Operation<Void>() {

        @Override
        public void apply(Void arg) throws OperationException {
            console.print(constant.addSuccess());
            notificationManager.notify(constant.addSuccess());
            view.close();
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            console.printError(constant.addFailed());
            notificationManager.notify(constant.addFailed(), FAIL, FLOAT_MODE);
            view.close();
        }
    });
}
Also used : Path(org.eclipse.che.ide.resource.Path) DevMachine(org.eclipse.che.ide.api.machine.DevMachine) Resource(org.eclipse.che.ide.api.resources.Resource) Operation(org.eclipse.che.api.promises.client.Operation) PromiseError(org.eclipse.che.api.promises.client.PromiseError) GitOutputConsole(org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole) OperationException(org.eclipse.che.api.promises.client.OperationException)

Aggregations

DevMachine (org.eclipse.che.ide.api.machine.DevMachine)15 Operation (org.eclipse.che.api.promises.client.Operation)5 Before (org.junit.Before)5 OperationException (org.eclipse.che.api.promises.client.OperationException)4 PromiseError (org.eclipse.che.api.promises.client.PromiseError)4 Path (org.eclipse.che.ide.resource.Path)4 Test (org.junit.Test)4 List (java.util.List)3 Inject (com.google.inject.Inject)2 ArrayList (java.util.ArrayList)2 Machine (org.eclipse.che.api.core.model.machine.Machine)2 AppContext (org.eclipse.che.ide.api.app.AppContext)2 ProcessesPanelPresenter (org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter)2 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 GwtMockitoTestRunner (com.google.gwtmockito.GwtMockitoTestRunner)1 Singleton (com.google.inject.Singleton)1 Arrays (java.util.Arrays)1 Arrays.asList (java.util.Arrays.asList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1