use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.
the class TestServiceClientTest method cancelledTestsBecauseCompilationFailed.
@Test
public void cancelledTestsBecauseCompilationFailed() {
Promise<CommandImpl> compileCommandPromise = createCommandPromise(new CommandImpl("test-compile", "mvn test-compile -f ${current.project.path}", "mvn"));
when(devMachine.getDescriptor()).thenReturn(machine);
Promise<TestResult> result = testServiceClient.runTestsAfterCompilation(projectPath, testFramework, parameters, statusNotification, compileCommandPromise);
triggerProcessEvents(processStartResponse(true), processStarted(), processStdErr("A small warning"), processStdOut("BUILD FAILURE"), processDied());
verify(testServiceClient, never()).sendTests(anyString(), anyString(), anyMapOf(String.class, String.class));
verify(statusNotification).setContent("Compiling the project before starting the test session.");
result.catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError promiseError) throws OperationException {
Throwable cause = promiseError.getCause();
Assert.assertNotNull(cause);
Assert.assertEquals(TestServiceClient.PROJECT_BUILD_FAILED_MESSAGE, cause.getMessage());
}
});
}
use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.
the class DeleteResourceManager method onConfirm.
private ConfirmCallback onConfirm(final Resource[] resources, final AsyncCallback<Void> callback) {
return new ConfirmCallback() {
@Override
public void accepted() {
if (resources == null) {
//sometimes we may occur NPE here while reading length
callback.onFailure(new IllegalStateException());
return;
}
Promise<?>[] deleteAll = new Promise<?>[resources.length];
for (int i = 0; i < resources.length; i++) {
final Resource resource = resources[i];
deleteAll[i] = resource.delete().catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify("Failed to delete '" + resource.getName() + "'", error.getMessage(), FAIL, StatusNotification.DisplayMode.FLOAT_MODE);
}
});
}
promiseProvider.all(deleteAll).then(new Operation<JsArrayMixed>() {
@Override
public void apply(JsArrayMixed arg) throws OperationException {
callback.onSuccess(null);
}
});
}
};
}
use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.
the class DebuggerTest method testAttachDebugger.
@Test
public void testAttachDebugger() throws Exception {
debugger.setDebugSession(null);
final String debugSessionJson = "debugSession";
doReturn(debugSessionJson).when(dtoFactory).toJson(debugSessionDto);
doReturn(mock(StartActionDto.class)).when(dtoFactory).createDto(StartActionDto.class);
Map<String, String> connectionProperties = mock(Map.class);
Promise<DebugSessionDto> promiseDebuggerInfo = mock(Promise.class);
doReturn(promiseDebuggerInfo).when(service).connect("id", connectionProperties);
doReturn(promiseVoid).when(promiseDebuggerInfo).then((Function<DebugSessionDto, Void>) any());
doReturn(promiseVoid).when(promiseVoid).catchError((Operation<PromiseError>) any());
Promise<Void> result = debugger.connect(connectionProperties);
assertEquals(promiseVoid, result);
verify(promiseDebuggerInfo).then(argumentCaptorFunctionJavaDebugSessionVoid.capture());
argumentCaptorFunctionJavaDebugSessionVoid.getValue().apply(debugSessionDto);
verify(promiseVoid).catchError(operationPromiseErrorCaptor.capture());
try {
operationPromiseErrorCaptor.getValue().apply(promiseError);
fail("Operation Exception expected");
} catch (OperationException e) {
verify(promiseError).getMessage();
verify(promiseError).getCause();
}
verify(observer).onDebuggerAttached(debuggerDescriptor, promiseVoid);
assertTrue(debugger.isConnected());
verify(localStorage).setItem(eq(AbstractDebugger.LOCAL_STORAGE_DEBUGGER_SESSION_KEY), eq(debugSessionJson));
verify(messageBus).subscribe(eq("id:events:"), any(SubscriptionHandler.class));
}
use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.
the class EvaluateExpressionPresenter method onEvaluateClicked.
/** {@inheritDoc} */
@Override
public void onEvaluateClicked() {
Debugger debugger = debuggerManager.getActiveDebugger();
if (debugger != null) {
view.setEnableEvaluateButton(false);
debugger.evaluate(view.getExpression()).then(new Operation<String>() {
@Override
public void apply(String result) throws OperationException {
view.setResult(result);
view.setEnableEvaluateButton(true);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
view.setResult(constant.evaluateExpressionFailed(error.getMessage()));
view.setEnableEvaluateButton(true);
}
});
}
}
use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.
the class LibEntryPresenter method go.
@Override
public void go(final AcceptsOneWidget container) {
final Resource resource = appContext.getResource();
Preconditions.checkState(resource != null);
final Optional<Project> project = resource.getRelatedProject();
isPlainJava = JAVAC.equals(project.get().getType());
setReadOnlyMod();
container.setWidget(view);
if (!categories.isEmpty()) {
view.renderLibraries();
return;
}
classpathContainer.getClasspathEntries(project.get().getPath()).then(new Operation<List<ClasspathEntryDto>>() {
@Override
public void apply(List<ClasspathEntryDto> arg) throws OperationException {
categories.clear();
for (ClasspathEntryDto entry : arg) {
if (CONTAINER == entry.getEntryKind() || LIBRARY == entry.getEntryKind()) {
categories.put(entry.getPath(), entry);
}
}
view.setData(categories);
view.renderLibraries();
}
});
}
Aggregations