@Test
public void shouldDetermineIfACommandIsInProgress() throws Exception {

    final SystemCommand commandReceivedCommand = mock(SystemCommand.class);
    final SystemCommand commandInProgressCommand = mock(SystemCommand.class);
    final SystemCommand commandCompleteCommand = mock(SystemCommand.class);
    final SystemCommand commandFailedCommand = mock(SystemCommand.class);
    final SystemCommand notFoundCommand = mock(SystemCommand.class);
    final SystemCommandStatus commandReceivedStatus = mock(SystemCommandStatus.class);
    final SystemCommandStatus commandInProgressStatus = mock(SystemCommandStatus.class);
    final SystemCommandStatus commandCompleteStatus = mock(SystemCommandStatus.class);
    final SystemCommandStatus commandFailedStatus = mock(SystemCommandStatus.class);
    when(systemCommandStatusRepository.findLatestStatusByType(commandReceivedCommand)).thenReturn(of(commandReceivedStatus));
    when(systemCommandStatusRepository.findLatestStatusByType(commandInProgressCommand)).thenReturn(of(commandInProgressStatus));
    when(systemCommandStatusRepository.findLatestStatusByType(commandCompleteCommand)).thenReturn(of(commandCompleteStatus));
    when(systemCommandStatusRepository.findLatestStatusByType(commandFailedCommand)).thenReturn(of(commandFailedStatus));
    when(systemCommandStatusRepository.findLatestStatusByType(notFoundCommand)).thenReturn(empty());
    when(commandReceivedStatus.getCommandState()).thenReturn(COMMAND_RECEIVED);
    when(commandInProgressStatus.getCommandState()).thenReturn(COMMAND_IN_PROGRESS);
    when(commandCompleteStatus.getCommandState()).thenReturn(COMMAND_COMPLETE);
    when(commandFailedStatus.getCommandState()).thenReturn(COMMAND_FAILED);
    assertThat(systemCommandStateBean.commandInProgress(commandReceivedCommand), is(true));
    assertThat(systemCommandStateBean.commandInProgress(commandInProgressCommand), is(true));
    assertThat(systemCommandStateBean.commandInProgress(commandCompleteCommand), is(false));
    assertThat(systemCommandStateBean.commandInProgress(commandFailedCommand), is(false));
    assertThat(systemCommandStateBean.commandInProgress(notFoundCommand), is(false));
}