Search in sources :

Example 21 with StatusNotification

use of org.eclipse.che.ide.api.notification.StatusNotification in project che by eclipse.

the class RunTestXMLAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    final StatusNotification notification = new StatusNotification("Running Tests...", PROGRESS, FLOAT_MODE);
    notificationManager.notify(notification);
    final Project project = appContext.getRootProject();
    Map<String, String> parameters = new HashMap<>();
    parameters.put("updateClasspath", "true");
    parameters.put("testngXML", project.getPath() + "/" + MavenAttributes.DEFAULT_TEST_RESOURCES_FOLDER + "/testng.xml");
    Promise<TestResult> testResultPromise = service.getTestResult(project.getPath(), "testng", parameters);
    testResultPromise.then(new Operation<TestResult>() {

        @Override
        public void apply(TestResult result) throws OperationException {
            notification.setStatus(SUCCESS);
            if (result.isSuccess()) {
                notification.setTitle("Test runner executed successfully");
                notification.setContent("All tests are passed");
            } else {
                notification.setTitle("Test runner executed successfully with test failures.");
                notification.setContent(result.getFailureCount() + " test(s) failed.\n");
            }
            presenter.handleResponse(result);
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError exception) throws OperationException {
            final String errorMessage = (exception.getMessage() != null) ? exception.getMessage() : "Failed to run test cases";
            notification.setContent(errorMessage);
            notification.setStatus(FAIL);
        }
    });
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) HashMap(java.util.HashMap) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) TestResult(org.eclipse.che.api.testing.shared.TestResult) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 22 with StatusNotification

use of org.eclipse.che.ide.api.notification.StatusNotification in project che by eclipse.

the class RunTestActionDelegate method doRunTests.

public void doRunTests(ActionEvent e, Map<String, String> parameters) {
    final StatusNotification notification = new StatusNotification("Running Tests...", PROGRESS, FLOAT_MODE);
    source.getNotificationManager().notify(notification);
    final Project project = source.getAppContext().getRootProject();
    parameters.put("updateClasspath", "true");
    Promise<TestResult> testResultPromise = source.getService().getTestResult(project.getPath(), "junit", parameters, notification);
    testResultPromise.then(new Operation<TestResult>() {

        @Override
        public void apply(TestResult result) throws OperationException {
            notification.setStatus(SUCCESS);
            if (result.isSuccess()) {
                notification.setTitle("Test runner executed successfully");
                notification.setContent("All tests are passed");
            } else {
                notification.setTitle("Test runner executed successfully with test failures.");
                notification.setContent(result.getFailureCount() + " test(s) failed.\n");
            }
            source.getPresenter().handleResponse(result);
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError exception) throws OperationException {
            final String errorMessage = (exception.getMessage() != null) ? exception.getMessage() : "Failed to run test cases";
            notification.setContent(errorMessage);
            notification.setStatus(FAIL);
        }
    });
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) TestResult(org.eclipse.che.api.testing.shared.TestResult) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 23 with StatusNotification

use of org.eclipse.che.ide.api.notification.StatusNotification in project che by eclipse.

the class RunAllTestAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    final StatusNotification notification = new StatusNotification("Running Tests...", PROGRESS, FLOAT_MODE);
    notificationManager.notify(notification);
    final Project project = appContext.getRootProject();
    Map<String, String> parameters = new HashMap<>();
    parameters.put("updateClasspath", "true");
    Promise<TestResult> testResultPromise = service.getTestResult(project.getPath(), "testng", parameters);
    testResultPromise.then(new Operation<TestResult>() {

        @Override
        public void apply(TestResult result) throws OperationException {
            notification.setStatus(SUCCESS);
            if (result.isSuccess()) {
                notification.setTitle("Test runner executed successfully");
                notification.setContent("All tests are passed");
            } else {
                notification.setTitle("Test runner executed successfully with test failures.");
                notification.setContent(result.getFailureCount() + " test(s) failed.\n");
            }
            presenter.handleResponse(result);
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError exception) throws OperationException {
            final String errorMessage = (exception.getMessage() != null) ? exception.getMessage() : "Failed to run test cases";
            notification.setContent(errorMessage);
            notification.setStatus(FAIL);
        }
    });
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) HashMap(java.util.HashMap) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) TestResult(org.eclipse.che.api.testing.shared.TestResult) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 24 with StatusNotification

use of org.eclipse.che.ide.api.notification.StatusNotification in project che by eclipse.

the class RunClassTestAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    final StatusNotification notification = new StatusNotification("Running Tests...", PROGRESS, FLOAT_MODE);
    notificationManager.notify(notification);
    final Project project = appContext.getRootProject();
    EditorPartPresenter editorPart = editorAgent.getActiveEditor();
    final VirtualFile file = editorPart.getEditorInput().getFile();
    String fqn = JavaUtil.resolveFQN(file);
    Map<String, String> parameters = new HashMap<>();
    parameters.put("fqn", fqn);
    parameters.put("runClass", "true");
    parameters.put("updateClasspath", "true");
    Promise<TestResult> testResultPromise = service.getTestResult(project.getPath(), "testng", parameters);
    testResultPromise.then(new Operation<TestResult>() {

        @Override
        public void apply(TestResult result) throws OperationException {
            notification.setStatus(SUCCESS);
            if (result.isSuccess()) {
                notification.setTitle("Test runner executed successfully");
                notification.setContent("All tests are passed");
            } else {
                notification.setTitle("Test runner executed successfully with test failures.");
                notification.setContent(result.getFailureCount() + " test(s) failed.\n");
            }
            presenter.handleResponse(result);
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError exception) throws OperationException {
            final String errorMessage = (exception.getMessage() != null) ? exception.getMessage() : "Failed to run test cases";
            notification.setContent(errorMessage);
            notification.setStatus(FAIL);
        }
    });
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) HashMap(java.util.HashMap) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) TestResult(org.eclipse.che.api.testing.shared.TestResult) Operation(org.eclipse.che.api.promises.client.Operation) Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 25 with StatusNotification

use of org.eclipse.che.ide.api.notification.StatusNotification in project che by eclipse.

the class DebuggerPresenter method onDebuggerAttached.

@Override
public void onDebuggerAttached(final DebuggerDescriptor debuggerDescriptor, Promise<Void> connect) {
    final String address = debuggerDescriptor.getAddress();
    final StatusNotification notification = notificationManager.notify(constant.debuggerConnectingTitle(address), PROGRESS, FLOAT_MODE);
    connect.then(new Operation<Void>() {

        @Override
        public void apply(Void arg) throws OperationException {
            DebuggerPresenter.this.debuggerDescriptor = debuggerDescriptor;
            notification.setTitle(constant.debuggerConnectedTitle());
            notification.setContent(constant.debuggerConnectedDescription(address));
            notification.setStatus(SUCCESS);
            showAndUpdateView();
            showDebuggerPanel();
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            notification.setTitle(constant.failedToConnectToRemoteDebuggerDescription(address, arg.getMessage()));
            notification.setStatus(FAIL);
            notification.setDisplayMode(FLOAT_MODE);
        }
    });
}
Also used : PromiseError(org.eclipse.che.api.promises.client.PromiseError) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Aggregations

StatusNotification (org.eclipse.che.ide.api.notification.StatusNotification)28 Operation (org.eclipse.che.api.promises.client.Operation)20 OperationException (org.eclipse.che.api.promises.client.OperationException)20 PromiseError (org.eclipse.che.api.promises.client.PromiseError)20 Project (org.eclipse.che.ide.api.resources.Project)12 Resource (org.eclipse.che.ide.api.resources.Resource)7 CLIOutputResponse (org.eclipse.che.plugin.svn.shared.CLIOutputResponse)7 TestResult (org.eclipse.che.api.testing.shared.TestResult)6 Test (org.junit.Test)6 HashMap (java.util.HashMap)5 Promise (org.eclipse.che.api.promises.client.Promise)4 GitOutputConsole (org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole)3 NotificationListener (org.eclipse.che.ide.api.notification.NotificationListener)2 Credentials (org.eclipse.che.ide.api.subversion.Credentials)2 Path (org.eclipse.che.ide.resource.Path)2 Depth (org.eclipse.che.plugin.svn.shared.Depth)2 URL (com.google.gwt.http.client.URL)1 MatchResult (com.google.gwt.regexp.shared.MatchResult)1 RegExp (com.google.gwt.regexp.shared.RegExp)1 Label (com.google.gwt.user.client.ui.Label)1