SuspensionResultsMapper { public List<SuspensionResult> getFailedResults(final List<SuspensionResult> suspensionResults) { return suspensionResults.stream() .filter(shutteringResult -> shutteringResult.getCommandState() == COMMAND_FAILED) .collect(toList()); }  List<SuspensionResult> getSuccessfulResults(final List<SuspensionResult> suspensionResults); List<SuspensionResult> getFailedResults(final List<SuspensionResult> suspensionResults); List<String> getSuspendablesNames(final List<SuspensionResult> suspensionResults);  }
@Test public void shouldGetTheSubListOfFailedResults() throws Exception { final SuspensionResult suspensionResult_1 = mock(SuspensionResult.class); final SuspensionResult suspensionResult_2 = mock(SuspensionResult.class); final SuspensionResult suspensionResult_3 = mock(SuspensionResult.class); final SuspensionResult suspensionResult_4 = mock(SuspensionResult.class); when(suspensionResult_1.getCommandState()).thenReturn(COMMAND_FAILED); when(suspensionResult_2.getCommandState()).thenReturn(COMMAND_COMPLETE); when(suspensionResult_3.getCommandState()).thenReturn(COMMAND_FAILED); when(suspensionResult_4.getCommandState()).thenReturn(COMMAND_IN_PROGRESS); final List<SuspensionResult> failedResults = suspensionResultsMapper.getFailedResults(asList( suspensionResult_1, suspensionResult_2, suspensionResult_3, suspensionResult_4)); assertThat(failedResults.size(), is(2)); assertThat(failedResults, hasItem(suspensionResult_1)); assertThat(failedResults, hasItem(suspensionResult_3)); }