@Test
public void shouldFireFailedEventIfSuspensionFailed() throws Exception {

    final UUID commandId = randomUUID();
    final ZonedDateTime stateChangedAt = new UtcClock().now();
    final SuspensionCommand suspensionCommand = new SuspendCommand();
    final SuspensionResult failureResult_1 = mock(SuspensionResult.class);
    final SuspensionResult failureResult_2 = mock(SuspensionResult.class);
    final List<SuspensionResult> unsuccessfulResults = asList(failureResult_1, failureResult_2);
    final List<String> suspendableNames = asList("Suspendable_1", "Suspendable_2");
    when(failureResult_1.getMessage()).thenReturn("failure 1");
    when(failureResult_2.getMessage()).thenReturn("failure 2");
    when(suspensionResultsMapper.getSuspendablesNames(unsuccessfulResults)).thenReturn(suspendableNames);
    when(clock.now()).thenReturn(stateChangedAt);
    suspensionPostProcess.completeSuspensionWithFailures(unsuccessfulResults, commandId, suspensionCommand);
    final InOrder inOrder = inOrder(logger, systemCommandStateChangedEventFirer);
    inOrder.verify(logger).error("SUSPEND failed with the following 2 errors:");
    inOrder.verify(logger).error("SUSPEND Error: failure 1");
    inOrder.verify(logger).error("SUSPEND Error: failure 2");
    inOrder.verify(systemCommandStateChangedEventFirer).fire(systemCommandStateChangedEventCaptor.capture());
    final SystemCommandStateChangedEvent stateChangedEvent = systemCommandStateChangedEventCaptor.getValue();
    assertThat(stateChangedEvent.getCommandId(), is(commandId));
    assertThat(stateChangedEvent.getSystemCommand(), is(suspensionCommand));
    assertThat(stateChangedEvent.getCommandState(), is(COMMAND_FAILED));
    assertThat(stateChangedEvent.getStatusChangedAt(), is(stateChangedAt));
    assertThat(stateChangedEvent.getMessage(), is("SUSPEND failed. The following Suspendables failed: [Suspendable_1, Suspendable_2]"));
}