@Test public void testPPWrapperWithForceResult() { List<ExecutionPostProcessor> pp = new ArrayList<ExecutionPostProcessor>(); pp.add(mockedExecutionPostProcessor); String betterResult = "ILL TAKE YOUR RESULT AND TRUMP IT!"; when(mockedExecutionPostProcessor.invoke(any(ExecutionContext.class), any(OperationKey.class), any(Object[].class), any(ExecutionResult.class))).thenReturn(new InterceptorResult(InterceptorState.FORCE_ON_RESULT, betterResult)); VerifyingExecutionObserver obs = new VerifyingExecutionObserver(ExecutionResult.ResultType.Success, betterResult); PostProcessingInterceptorWrapper ppiw = new PostProcessingInterceptorWrapper(obs, pp, ctx, key, new Object[] {}); ppiw.onResult(new ExecutionResult("String")); obs = new VerifyingExecutionObserver(ExecutionResult.ResultType.Success); ppiw = new PostProcessingInterceptorWrapper(obs, pp, ctx, key, new Object[] {}); ppiw.onResult(new ExecutionResult(new CougarFrameworkException("Mr Blobby"))); obs = new VerifyingExecutionObserver(ExecutionResult.ResultType.Success); ppiw = new PostProcessingInterceptorWrapper(obs, pp, ctx, key, new Object[] {}); ppiw.onResult(new ExecutionResult(new DefaultSubscription())); }
@Override public void onResult(ExecutionResult executionResult) { InterceptorResult state = invokePostProcessors(executionResult); if (InterceptorState.FORCE_ON_RESULT.equals(state.getState())) { observer.onResult(new ExecutionResult(state.getResult())); } else if (InterceptorState.FORCE_ON_EXCEPTION.equals(state.getState())) { forceOnException(state); } else { observer.onResult(executionResult); } }
PostProcessingInterceptorWrapper implements ExecutionObserver { @Override public void onResult(ExecutionResult executionResult) { InterceptorResult state = invokePostProcessors(executionResult); if (InterceptorState.FORCE_ON_RESULT.equals(state.getState())) { observer.onResult(new ExecutionResult(state.getResult())); } else if (InterceptorState.FORCE_ON_EXCEPTION.equals(state.getState())) { forceOnException(state); } else { observer.onResult(executionResult); } } }
PostProcessingInterceptorWrapper implements ExecutionObserver { @Override public void onResult(ExecutionResult executionResult) { InterceptorResult state = invokePostProcessors(executionResult); if (InterceptorState.FORCE_ON_RESULT.equals(state.getState())) { observer.onResult(new ExecutionResult(state.getResult())); } else if (InterceptorState.FORCE_ON_EXCEPTION.equals(state.getState())) { forceOnException(state); } else { observer.onResult(executionResult); } } PostProcessingInterceptorWrapper(	ExecutionObserver observer,
									List<ExecutionPostProcessor> postProcessors,
									final ExecutionContext ctx,
									final OperationKey key,
									final Object [] args); }
PostProcessingInterceptorWrapper implements ExecutionObserver { @Override public void onResult(ExecutionResult executionResult) { InterceptorResult state = invokePostProcessors(executionResult); if (InterceptorState.FORCE_ON_RESULT.equals(state.getState())) { observer.onResult(new ExecutionResult(state.getResult())); } else if (InterceptorState.FORCE_ON_EXCEPTION.equals(state.getState())) { forceOnException(state); } else { observer.onResult(executionResult); } } PostProcessingInterceptorWrapper(	ExecutionObserver observer,
									List<ExecutionPostProcessor> postProcessors,
									final ExecutionContext ctx,
									final OperationKey key,
									final Object [] args); @Override void onResult(ExecutionResult executionResult); }
PostProcessingInterceptorWrapper implements ExecutionObserver { @Override public void onResult(ExecutionResult executionResult) { InterceptorResult state = invokePostProcessors(executionResult); if (InterceptorState.FORCE_ON_RESULT.equals(state.getState())) { observer.onResult(new ExecutionResult(state.getResult())); } else if (InterceptorState.FORCE_ON_EXCEPTION.equals(state.getState())) { forceOnException(state); } else { observer.onResult(executionResult); } } PostProcessingInterceptorWrapper(	ExecutionObserver observer,
									List<ExecutionPostProcessor> postProcessors,
									final ExecutionContext ctx,
									final OperationKey key,
									final Object [] args); @Override void onResult(ExecutionResult executionResult);  }