Search in sources :

Example 6 with Versions

use of com.sequenceiq.cloudbreak.cloud.model.catalog.Versions in project cloudbreak by hortonworks.

the class VersionBasedImageCatalogServiceTest method testGetCdhImagesForCbVersionShouldReturnsImagesWhenThereAreMultipleSupportedImagesAreAvailableForCbVersion.

@Test
public void testGetCdhImagesForCbVersionShouldReturnsImagesWhenThereAreMultipleSupportedImagesAreAvailableForCbVersion() {
    ReflectionTestUtils.setField(victim, "cbVersion", CURRENT_CB_VERSION);
    Image properImage1 = createImage(PROPER_IMAGE_ID);
    Image properImage2 = createImage(PROPER_IMAGE_ID_2);
    Image otherImage = createImage(OTHER_IMAGE_ID);
    when(imageCatalogV3.getImages()).thenReturn(images);
    when(images.getCdhImages()).thenReturn(List.of(properImage1, otherImage, properImage2));
    Versions versions = createCbVersions();
    when(cloudbreakVersionListProvider.getVersions(any())).thenReturn(versions.getCloudbreakVersions());
    List<Image> actual = victim.getImageFilterResult(imageCatalogV3).getImages();
    assertTrue(actual.contains(properImage1));
    assertTrue(actual.contains(properImage2));
    assertEquals(2, actual.size());
}
Also used : Versions(com.sequenceiq.cloudbreak.cloud.model.catalog.Versions) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) Test(org.junit.jupiter.api.Test)

Example 7 with Versions

use of com.sequenceiq.cloudbreak.cloud.model.catalog.Versions in project cloudbreak by hortonworks.

the class VersionBasedImageCatalogServiceTest method testGetCdhImagesForCbVersionShouldReturnsEmptyListWhenThereAreNoSupportedImagesForCbVersion.

@Test
public void testGetCdhImagesForCbVersionShouldReturnsEmptyListWhenThereAreNoSupportedImagesForCbVersion() {
    ReflectionTestUtils.setField(victim, "cbVersion", "2.18");
    Image properImage = createImage(PROPER_IMAGE_ID);
    Image otherImage = createImage(OTHER_IMAGE_ID);
    when(imageCatalogV3.getImages()).thenReturn(images);
    when(prefixMatcherService.prefixMatchForCBVersion(eq("2.18"), any())).thenReturn(new PrefixMatchImages(Collections.emptySet(), Collections.emptySet(), Collections.emptySet()));
    when(images.getCdhImages()).thenReturn(List.of(properImage, otherImage));
    Versions versions = createCbVersions();
    when(cloudbreakVersionListProvider.getVersions(any())).thenReturn(versions.getCloudbreakVersions());
    List<Image> actual = victim.getImageFilterResult(imageCatalogV3).getImages();
    assertTrue(actual.isEmpty());
}
Also used : PrefixMatchImages(com.sequenceiq.cloudbreak.service.image.PrefixMatchImages) Versions(com.sequenceiq.cloudbreak.cloud.model.catalog.Versions) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) Test(org.junit.jupiter.api.Test)

Example 8 with Versions

use of com.sequenceiq.cloudbreak.cloud.model.catalog.Versions in project cloudbreak by hortonworks.

the class VersionBasedImageCatalogServiceTest method testGetFreeipaImagesForCbVersionShouldReturnsImagesWhenThereAreMultipleSupportedImagesAreAvailableForCbVersion.

@Test
public void testGetFreeipaImagesForCbVersionShouldReturnsImagesWhenThereAreMultipleSupportedImagesAreAvailableForCbVersion() {
    ReflectionTestUtils.setField(victim, "cbVersion", CURRENT_CB_VERSION);
    Image properImage1 = createImage(PROPER_IMAGE_ID);
    Image properImage2 = createImage(PROPER_IMAGE_ID_2);
    Image otherImage = createImage(OTHER_IMAGE_ID);
    when(imageCatalogV3.getImages()).thenReturn(images);
    when(images.getFreeIpaImages()).thenReturn(List.of(properImage1, otherImage, properImage2));
    Versions versions = createFreeipaVersions();
    when(cloudbreakVersionListProvider.getVersions(any())).thenReturn(versions.getFreeipaVersions());
    List<Image> actual = victim.getImageFilterResult(imageCatalogV3).getImages();
    assertTrue(actual.contains(properImage1));
    assertTrue(actual.contains(properImage2));
    assertEquals(2, actual.size());
}
Also used : Versions(com.sequenceiq.cloudbreak.cloud.model.catalog.Versions) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) Test(org.junit.jupiter.api.Test)

Example 9 with Versions

use of com.sequenceiq.cloudbreak.cloud.model.catalog.Versions in project cloudbreak by hortonworks.

the class VersionBasedImageCatalogServiceTest method testValidateCbImagesWhichAnyStoredInVersionBlock.

@Test
public void testValidateCbImagesWhichAnyStoredInVersionBlock() {
    Image properImage1 = createImage(PROPER_IMAGE_ID);
    Image properImage2 = createImage(PROPER_IMAGE_ID_2);
    when(images.getCdhImages()).thenReturn(List.of(properImage1, properImage2));
    Versions versions = createCbVersions();
    when(cloudbreakVersionListProvider.getVersions(any())).thenReturn(versions.getCloudbreakVersions());
    Exception exception = assertThrows(CloudbreakImageCatalogException.class, () -> victim.validate(createCatalog(versions)));
    assertEquals("Images with ids: " + OTHER_IMAGE_ID + " is not present in cdh-images block", exception.getMessage());
}
Also used : Versions(com.sequenceiq.cloudbreak.cloud.model.catalog.Versions) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) Test(org.junit.jupiter.api.Test)

Example 10 with Versions

use of com.sequenceiq.cloudbreak.cloud.model.catalog.Versions in project cloudbreak by hortonworks.

the class VersionBasedImageCatalogServiceTest method testGetFreeipaImagesForCbVersionShouldReturnsImagesWhenThereAreSupportedImagesForCbVersion.

@Test
public void testGetFreeipaImagesForCbVersionShouldReturnsImagesWhenThereAreSupportedImagesForCbVersion() {
    ReflectionTestUtils.setField(victim, "cbVersion", CURRENT_CB_VERSION);
    Image properImage = createImage(PROPER_IMAGE_ID);
    Image otherImage = createImage(OTHER_IMAGE_ID);
    when(imageCatalogV3.getImages()).thenReturn(images);
    when(images.getFreeIpaImages()).thenReturn(List.of(properImage, otherImage));
    Versions versions = createFreeipaVersions();
    when(cloudbreakVersionListProvider.getVersions(any())).thenReturn(versions.getFreeipaVersions());
    List<Image> actual = victim.getImageFilterResult(imageCatalogV3).getImages();
    assertTrue(actual.contains(properImage));
    assertEquals(1, actual.size());
}
Also used : Versions(com.sequenceiq.cloudbreak.cloud.model.catalog.Versions) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) Test(org.junit.jupiter.api.Test)

Aggregations

Versions (com.sequenceiq.cloudbreak.cloud.model.catalog.Versions)13 Test (org.junit.jupiter.api.Test)11 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)10 CloudbreakImageCatalogV3 (com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3)3 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)3 CloudbreakVersion (com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakVersion)2 PrefixMatchImages (com.sequenceiq.cloudbreak.service.image.PrefixMatchImages)2 Test (org.junit.Test)2