### Question:
FeatureService { public List<FeatureDTO> retrieveStateOf(List<String> codes) { return codes.stream() .filter(code -> this.featureCollection.get(code).isPresent()) .map(code -> new FeatureDTO(code, this.featureActivator.getState(code))) .collect(Collectors.toList()); }  List<FeatureDTO> listAll(); DetailledFeatureDTO find(String code); FeatureDTO findDefaultOf(String code); List<FeatureDTO> retrieveStateOf(List<String> codes); void update(List<FeatureDTO> featuresToUpdate); void reset(List<String> featuresToReset); boolean isEnabled(String featureCode);  }### Answer:
@Test public void retrieveStateOf_should_return_the_features_of_code() { List<String> wantedCodes = new ArrayList<>(); wantedCodes.add("my-feature"); wantedCodes.add("test"); wantedCodes.add("test-yep"); Mockito.doReturn(Optional.of(given_a_feature("my-feature", "desc", "name"))).when(featureCollectionMock).get("my-feature"); Mockito.doReturn(Optional.of(given_a_feature("test", "desc", "name"))).when(featureCollectionMock).get("test"); Mockito.doReturn(Optional.of(given_a_feature("test-yep", "desc", "name"))).when(featureCollectionMock).get("test-yep"); Mockito.doReturn(true).when(featureActivatorMock).getState("my-feature"); Mockito.doReturn(false).when(featureActivatorMock).getState("test"); Mockito.doReturn(true).when(featureActivatorMock).getState("test-yep"); List<FeatureDTO> featuresDTO = cut.retrieveStateOf(wantedCodes); Assertions.assertThat(featuresDTO).hasSize(3); Assertions.assertThat(featuresDTO.get(0)).isEqualTo(new FeatureDTO("my-feature", true)); Assertions.assertThat(featuresDTO.get(1)).isEqualTo(new FeatureDTO("test", false)); Assertions.assertThat(featuresDTO.get(2)).isEqualTo(new FeatureDTO("test-yep", true)); }
@Test public void retrieveStateOf_should_return_empty_list_on_empty_params() { List<String> wantedCodes = new ArrayList<>(); List<FeatureDTO> featuresDTO = cut.retrieveStateOf(wantedCodes); Assertions.assertThat(featuresDTO).hasSize(0); }
@Test public void retrieveStateOf_should_exclude_non_existing() { List<String> wantedCodes = new ArrayList<>(); wantedCodes.add("my-feature"); wantedCodes.add("nope"); wantedCodes.add("test-yep"); Mockito.doReturn(Optional.of(given_a_feature("my-feature", "desc", "name"))).when(featureCollectionMock).get("my-feature"); Mockito.doReturn(Optional.of(given_a_feature("test-yep", "desc", "name"))).when(featureCollectionMock).get("test-yep"); Mockito.doReturn(true).when(featureActivatorMock).getState("my-feature"); Mockito.doReturn(true).when(featureActivatorMock).getState("test-yep"); List<FeatureDTO> featuresDTO = cut.retrieveStateOf(wantedCodes); Assertions.assertThat(featuresDTO).hasSize(2); Assertions.assertThat(featuresDTO.get(0)).isEqualTo(new FeatureDTO("my-feature", true)); Assertions.assertThat(featuresDTO.get(1)).isEqualTo(new FeatureDTO("test-yep", true)); }