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