DefaultWarpExecutor implements WarpExecutor { @Override public WarpResult execute(Activity activity, WarpContext warpContext) { try { setupServerInspection(); executeActivity(activity); awaitServerExecution(warpContext); checkActivityFailure(); return warpContext.getResult(); } finally { cleanup(); } }  @Override WarpResult execute(Activity activity, WarpContext warpContext);  }
@Test public void when_client_activity_fails_and_request_result_is_failure_then_server_failure_should_be_reported() { TestResult result = new TestResult(Status.FAILED, new RuntimeException("server")); when(warpContext.getFirstNonSuccessfulResult()).thenReturn(result); doThrow(new RuntimeException("client")).when(activity).perform(); try { executor.execute(activity, warpContext); fail("client activity should fail the request"); } catch (RuntimeException e) { String message = e.getMessage(); if (!"server".equals(message)) { throw e; } } }
@Test public void when_server_activity_fails_without_client_failure_then_server_failure_should_be_reported() { TestResult result = new TestResult(Status.FAILED, new RuntimeException("server")); when(warpContext.getFirstNonSuccessfulResult()).thenReturn(result); try { executor.execute(activity, warpContext); fail("server execution should fail the request"); } catch (RuntimeException e) { String message = e.getMessage(); if (!"server".equals(message)) { throw e; } } }
@Test public void when_client_activity_fails_without_server_failure_then_client_failure_should_be_reported() { doThrow(new RuntimeException("client")).when(activity).perform(); when(warpContext.getFirstNonSuccessfulResult()).thenReturn(null); try { executor.execute(activity, warpContext); fail("server execution should fail the request"); } catch (ActivityException e) { String message = e.getCause().getMessage(); if (!"client".equals(message)) { throw e; } } }