### Question:
ClusterUpgradeImageFilter { public ImageFilterResult filter(List<Image> images, Versions versions, Image currentImage, String cloudPlatform, boolean lockComponents, Map<String, String> activatedParcels) { ImageFilterResult imagesForCbVersion = getImagesForCbVersion(versions, images); List<Image> imageList = imagesForCbVersion.getAvailableImages().getCdhImages(); if (CollectionUtils.isEmpty(imageList)) { return imagesForCbVersion; } LOGGER.debug("{} image(s) found for the given CB version", imageList.size()); return filterImages(imageList, currentImage, cloudPlatform, lockComponents, activatedParcels); }  ImageFilterResult filter(List<Image> images, Versions versions, Image currentImage, String cloudPlatform, boolean lockComponents,
            Map<String, String> activatedParcels); static final String CM_PACKAGE_KEY; }### Answer:
@Test public void testFilterShouldNotReturnImageIfPackageFilterReturnFalse() { List<Image> properImages = List.of(properImage); ImageFilterResult imageFilterResult = new ImageFilterResult(new Images(null, properImages, null), ""); Predicate<Image> predicate = mock(Predicate.class); when(predicate.test(any())).thenReturn(Boolean.FALSE); when(entitlementDrivenPackageLocationFilter.filterImage(any(Image.class))).thenReturn(predicate); when(versionBasedImageFilter.getCdhImagesForCbVersion(supportedCbVersions, properImages)).thenReturn(imageFilterResult); ImageFilterResult actual = underTest.filter(properImages, supportedCbVersions, currentImage, CLOUD_PLATFORM, lockComponents, activatedParcels); assertTrue(actual.getAvailableImages().getCdhImages().isEmpty()); }
@Test public void testFilterShouldNotReturnImageIfCmAndStackFilterReturnFalse() { List<Image> properImages = List.of(properImage); ImageFilterResult imageFilterResult = new ImageFilterResult(new Images(null, properImages, null), ""); Predicate<Image> predicate = mock(Predicate.class); when(predicate.test(any())).thenReturn(Boolean.FALSE); when(cmAndStackVersionFilter.filterCmAndStackVersion(any(Image.class), anyBoolean(), anyMap(), any())).thenReturn(predicate); when(versionBasedImageFilter.getCdhImagesForCbVersion(supportedCbVersions, properImages)).thenReturn(imageFilterResult); ImageFilterResult actual = underTest.filter(properImages, supportedCbVersions, currentImage, CLOUD_PLATFORM, lockComponents, activatedParcels); assertTrue(actual.getAvailableImages().getCdhImages().isEmpty()); }
@Test public void testFilterShouldReturnTheProperImageWhenTheCurrentImageIsAlsoAvailable() { Image imageWithSameId = createImageWithCurrentImageId(); List<Image> availableImages = List.of(properImage, imageWithSameId); ImageFilterResult imageFilterResult = new ImageFilterResult(new Images(null, availableImages, null), ""); when(versionBasedImageFilter.getCdhImagesForCbVersion(supportedCbVersions, availableImages)).thenReturn(imageFilterResult); ImageFilterResult actual = underTest.filter(availableImages, supportedCbVersions, currentImage, CLOUD_PLATFORM, lockComponents, activatedParcels); assertTrue(actual.getAvailableImages().getCdhImages().contains(properImage)); assertEquals(1, actual.getAvailableImages().getCdhImages().size()); }