* Execution hook on failed execution with a fallback
*/
@Test
public void testExecutionHookRunFailureWithFallback() {
/* test with execute() */
TestHystrixCommand<Boolean> command = new KnownFailureTestCommandWithFallback(new TestCircuitBreaker());
command.execute();
// the run() method should run as we're not short-circuited or rejected
assertEquals(1, command.builder.executionHook.startRun.get());
// we should not have a response from run since run() failed
assertNull(command.builder.executionHook.runSuccessResponse);
// we should have an exception since run() failed
assertNotNull(command.builder.executionHook.runFailureException);
// the fallback() method should be run since run() failed
assertEquals(1, command.builder.executionHook.startFallback.get());
// a response since fallback is implemented
assertNotNull(command.builder.executionHook.fallbackSuccessResponse);
// null since it's implemented and succeeds
assertNull(command.builder.executionHook.fallbackFailureException);
// the execute() method was used
assertEquals(1, command.builder.executionHook.startExecute.get());
// we should have a response from execute() since we expect a fallback despite failure of run()
assertNotNull(command.builder.executionHook.endExecuteSuccessResponse);
// we should not have an exception because we expect a fallback
assertNull(command.builder.executionHook.endExecuteFailureException);
// thread execution
assertEquals(1, command.builder.executionHook.threadStart.get());
assertEquals(1, command.builder.executionHook.threadComplete.get());
/* test with queue() */
command = new KnownFailureTestCommandWithFallback(new TestCircuitBreaker());
try {
command.queue().get();
} catch (Exception e) {
throw new RuntimeException(e);
}