@Test public void testRejectedImageMultipleRejectingFilters() { Set<PackageLocationFilter> filters = Set.of(createRejectingFilter(), createRejectingFilter(), createRejectingFilter()); EntitlementDrivenPackageLocationFilter underTest = new EntitlementDrivenPackageLocationFilter(entitlementService, filters); Predicate<Image> imagePredicate = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.filterImage(mock(Image.class))); boolean result = imagePredicate.test(mock(Image.class)); assertFalse(result); }
public Predicate<Image> filterImage(Image currentImage) { String accountId = ThreadBasedUserCrnProvider.getAccountId(); if (entitlementService.isInternalRepositoryForUpgradeAllowed(INTERNAL_ACTOR_CRN, accountId)) { LOGGER.debug("Skipping image filtering based on repository url"); return image -> true; } else { return image -> filters.stream().allMatch(filter -> filter.filterImage(image, currentImage)); } }
EntitlementDrivenPackageLocationFilter { public Predicate<Image> filterImage(Image currentImage) { String accountId = ThreadBasedUserCrnProvider.getAccountId(); if (entitlementService.isInternalRepositoryForUpgradeAllowed(INTERNAL_ACTOR_CRN, accountId)) { LOGGER.debug("Skipping image filtering based on repository url"); return image -> true; } else { return image -> filters.stream().allMatch(filter -> filter.filterImage(image, currentImage)); } } }
EntitlementDrivenPackageLocationFilter { public Predicate<Image> filterImage(Image currentImage) { String accountId = ThreadBasedUserCrnProvider.getAccountId(); if (entitlementService.isInternalRepositoryForUpgradeAllowed(INTERNAL_ACTOR_CRN, accountId)) { LOGGER.debug("Skipping image filtering based on repository url"); return image -> true; } else { return image -> filters.stream().allMatch(filter -> filter.filterImage(image, currentImage)); } } EntitlementDrivenPackageLocationFilter(EntitlementService entitlementService, Set<PackageLocationFilter> filters); }
EntitlementDrivenPackageLocationFilter { public Predicate<Image> filterImage(Image currentImage) { String accountId = ThreadBasedUserCrnProvider.getAccountId(); if (entitlementService.isInternalRepositoryForUpgradeAllowed(INTERNAL_ACTOR_CRN, accountId)) { LOGGER.debug("Skipping image filtering based on repository url"); return image -> true; } else { return image -> filters.stream().allMatch(filter -> filter.filterImage(image, currentImage)); } } EntitlementDrivenPackageLocationFilter(EntitlementService entitlementService, Set<PackageLocationFilter> filters); Predicate<Image> filterImage(Image currentImage); }
EntitlementDrivenPackageLocationFilter { public Predicate<Image> filterImage(Image currentImage) { String accountId = ThreadBasedUserCrnProvider.getAccountId(); if (entitlementService.isInternalRepositoryForUpgradeAllowed(INTERNAL_ACTOR_CRN, accountId)) { LOGGER.debug("Skipping image filtering based on repository url"); return image -> true; } else { return image -> filters.stream().allMatch(filter -> filter.filterImage(image, currentImage)); } } EntitlementDrivenPackageLocationFilter(EntitlementService entitlementService, Set<PackageLocationFilter> filters); Predicate<Image> filterImage(Image currentImage);  }