### Question:
VersionBasedImageFilter { public ImageFilterResult getCdhImagesForCbVersion(Versions versions, List<Image> availableImages) { Set<String> imageIds = getImageIds(versions); LOGGER.debug("{} image id(s) found for Cloudbreak version: {}", imageIds.size(), cbVersion); String message = String.format("%d image id(s) found for Cloudbreak version: %s", imageIds.size(), cbVersion); List<Image> images = availableImages.stream() .filter(image -> imageIds.contains(image.getUuid())) .collect(Collectors.toList()); return new ImageFilterResult(new Images(null, images, null), message); }  ImageFilterResult getCdhImagesForCbVersion(Versions versions, List<Image> availableImages);  }### Answer:
@Test public void testGetCdhImagesForCbVersionShouldReturnsImagesWhenThereAreSupportedImagesForCbVersion() { ReflectionTestUtils.setField(underTest, "cbVersion", CURRENT_CB_VERSION); Versions versions = createVersions(); Image properImage = createImage(PROPER_IMAGE_ID); Image otherImage = createImage(OTHER_IMAGE_ID); List<Image> actual = underTest.getCdhImagesForCbVersion(versions, List.of(properImage, otherImage)).getAvailableImages().getCdhImages(); assertTrue(actual.contains(properImage)); assertEquals(1, actual.size()); }
@Test public void testGetCdhImagesForCbVersionShouldReturnsEmptyListWhenThereAreNoSupportedImagesForCbVersion() { ReflectionTestUtils.setField(underTest, "cbVersion", "2.18"); Versions versions = createVersions(); Image properImage = createImage(PROPER_IMAGE_ID); Image otherImage = createImage(OTHER_IMAGE_ID); when(prefixMatcherService.prefixMatchForCBVersion(eq("2.18"), any())) .thenReturn(new PrefixMatchImages(Collections.emptySet(), Collections.emptySet(), Collections.emptySet())); List<Image> actual = underTest.getCdhImagesForCbVersion(versions, List.of(properImage, otherImage)).getAvailableImages().getCdhImages(); assertTrue(actual.isEmpty()); }
@Test public void testGetCdhImagesForCbVersionShouldReturnsImagesWhenThereAreMultipleSupportedImagesAreAvailableForCbVersion() { ReflectionTestUtils.setField(underTest, "cbVersion", CURRENT_CB_VERSION); Versions versions = createVersions(); Image properImage1 = createImage(PROPER_IMAGE_ID); Image properImage2 = createImage(PROPER_IMAGE_ID_2); Image otherImage = createImage(OTHER_IMAGE_ID); List<Image> actual = underTest.getCdhImagesForCbVersion(versions, List.of(properImage1, otherImage, properImage2)).getAvailableImages().getCdhImages(); assertTrue(actual.contains(properImage1)); assertTrue(actual.contains(properImage2)); assertEquals(2, actual.size()); }