use of com.sequenceiq.cloudbreak.service.upgrade.image.PackageLocationFilter in project cloudbreak by hortonworks.
the class EntitlementDrivenPackageLocationFilterTest method testRejectedImageMultipleRejectingFilters.
@Test
public void testRejectedImageMultipleRejectingFilters() {
Set<PackageLocationFilter> filters = Set.of(createRejectingFilter(), createRejectingFilter(), createRejectingFilter());
EntitlementDrivenPackageLocationFilter underTest = new EntitlementDrivenPackageLocationFilter(entitlementService, filters);
List<Image> images = List.of(this.image1, image2);
ImageFilterResult imageFilterResult = new ImageFilterResult(images);
ImageFilterResult actual = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.filter(imageFilterResult, imageFilterParams));
assertTrue(actual.getImages().isEmpty());
assertEquals("There are no eligible images to upgrade because the location of the packages is not appropriate.", actual.getReason());
}
use of com.sequenceiq.cloudbreak.service.upgrade.image.PackageLocationFilter in project cloudbreak by hortonworks.
the class EntitlementDrivenPackageLocationFilterTest method testAcceptedImageMultipleFilters.
@Test
public void testAcceptedImageMultipleFilters() {
Set<PackageLocationFilter> filters = Set.of(createAcceptingFilter(), createAcceptingFilter(), createAcceptingFilter(), createAcceptingFilter());
EntitlementDrivenPackageLocationFilter underTest = new EntitlementDrivenPackageLocationFilter(entitlementService, filters);
List<Image> images = List.of(this.image1, image2);
ImageFilterResult imageFilterResult = new ImageFilterResult(images);
ImageFilterResult actual = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.filter(imageFilterResult, imageFilterParams));
assertEquals(images, actual.getImages());
assertTrue(actual.getReason().isEmpty());
filters.forEach(filter -> verify(filter, times(2)).filterImage(any(Image.class), any(Image.class), any(ImageFilterParams.class)));
}
use of com.sequenceiq.cloudbreak.service.upgrade.image.PackageLocationFilter in project cloudbreak by hortonworks.
the class EntitlementDrivenPackageLocationFilterTest method createAcceptingFilter.
private PackageLocationFilter createAcceptingFilter() {
PackageLocationFilter filter = mock(PackageLocationFilter.class);
lenient().when(filter.filterImage(any(Image.class), any(Image.class), any(ImageFilterParams.class))).thenReturn(Boolean.TRUE);
return filter;
}
use of com.sequenceiq.cloudbreak.service.upgrade.image.PackageLocationFilter in project cloudbreak by hortonworks.
the class EntitlementDrivenPackageLocationFilterTest method createRejectingFilter.
private PackageLocationFilter createRejectingFilter() {
PackageLocationFilter filter = mock(PackageLocationFilter.class);
lenient().when(filter.filterImage(any(Image.class), any(Image.class), any(ImageFilterParams.class))).thenReturn(Boolean.FALSE);
return filter;
}
use of com.sequenceiq.cloudbreak.service.upgrade.image.PackageLocationFilter in project cloudbreak by hortonworks.
the class EntitlementDrivenPackageLocationFilterTest method testEntitlementEnabled.
@Test
public void testEntitlementEnabled() {
PackageLocationFilter filter = mock(PackageLocationFilter.class);
when(entitlementService.isInternalRepositoryForUpgradeAllowed(anyString())).thenReturn(Boolean.TRUE);
lenient().when(imageFilterParams.getCurrentImage()).thenReturn(currentImage);
EntitlementDrivenPackageLocationFilter underTest = new EntitlementDrivenPackageLocationFilter(entitlementService, Set.of(filter));
List<Image> images = List.of(this.image1, image2);
ImageFilterResult imageFilterResult = new ImageFilterResult(images);
ImageFilterResult actual = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.filter(imageFilterResult, imageFilterParams));
assertEquals(images, actual.getImages());
assertTrue(actual.getReason().isEmpty());
verify(filter, never()).filterImage(any(Image.class), any(Image.class), any(ImageFilterParams.class));
}
Aggregations