SuspensionFailedHandler { public SuspensionResult onSuspensionFailed( final UUID commandId, final SuspensionCommand suspensionCommand, final Suspendable suspendable, final Throwable exception) { final String message = format( "%s failed for %s. %s: %s", suspensionCommand.getName(), suspendable.getName(), exception.getClass().getName(), exception.getMessage()); logger.error(message, exception); return suspensionFailed( suspendable.getName(), commandId, message, suspensionCommand, exception ); }  SuspensionResult onSuspensionFailed(
            final UUID commandId,
            final SuspensionCommand suspensionCommand,
            final Suspendable suspendable,
            final Throwable exception);  }
@Test public void shouldLogErrorAndReturnAFailureResult() throws Exception { final UUID commandId = UUID.randomUUID(); final String suspendableName = "SuspendableName"; final SuspensionCommand suspensionCommand = new UnsuspendCommand(); final Suspendable suspendable = mock(Suspendable.class); final NullPointerException nullPointerException = new NullPointerException("Ooops"); when(suspendable.getName()).thenReturn(suspendableName); final SuspensionResult suspensionResult = suspensionFailedHandler.onSuspensionFailed( commandId, suspensionCommand, suspendable, nullPointerException ); assertThat(suspensionResult.getCommandId(), is(commandId)); assertThat(suspensionResult.getCommandState(), is(COMMAND_FAILED)); assertThat(suspensionResult.getMessage(), is("UNSUSPEND failed for SuspendableName. java.lang.NullPointerException: Ooops")); assertThat(suspensionResult.getSuspendableName(), is(suspendableName)); assertThat(suspensionResult.getSystemCommand(), is(suspensionCommand)); assertThat(suspensionResult.getException(), is(of(nullPointerException))); verify(logger).error("UNSUSPEND failed for SuspendableName. java.lang.NullPointerException: Ooops", nullPointerException); }