Search in sources :

Example 1 with PackageLocationFilter

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());
}
Also used : PackageLocationFilter(com.sequenceiq.cloudbreak.service.upgrade.image.PackageLocationFilter) ImageFilterResult(com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterResult) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) Test(org.junit.jupiter.api.Test)

Example 2 with PackageLocationFilter

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)));
}
Also used : PackageLocationFilter(com.sequenceiq.cloudbreak.service.upgrade.image.PackageLocationFilter) ImageFilterResult(com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterResult) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) Test(org.junit.jupiter.api.Test)

Example 3 with PackageLocationFilter

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;
}
Also used : PackageLocationFilter(com.sequenceiq.cloudbreak.service.upgrade.image.PackageLocationFilter) ImageFilterParams(com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterParams) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image)

Example 4 with PackageLocationFilter

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;
}
Also used : PackageLocationFilter(com.sequenceiq.cloudbreak.service.upgrade.image.PackageLocationFilter) ImageFilterParams(com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterParams) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image)

Example 5 with PackageLocationFilter

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));
}
Also used : PackageLocationFilter(com.sequenceiq.cloudbreak.service.upgrade.image.PackageLocationFilter) ImageFilterParams(com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterParams) ImageFilterResult(com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterResult) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) Test(org.junit.jupiter.api.Test)

Aggregations

Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)6 PackageLocationFilter (com.sequenceiq.cloudbreak.service.upgrade.image.PackageLocationFilter)6 ImageFilterResult (com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterResult)4 Test (org.junit.jupiter.api.Test)4 ImageFilterParams (com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterParams)3