Search in sources :

Example 1 with Versions

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

the class CloudbreakVersionListProviderTest method testGetVersionsWithFreeipaVersions.

@Test
public void testGetVersionsWithFreeipaVersions() {
    CloudbreakImageCatalogV3 catalog = new CloudbreakImageCatalogV3(null, new Versions(null, freeipaVersions()));
    List<CloudbreakVersion> versions = underTest.getVersions(catalog);
    assertEquals(1, versions.size());
    assertEquals(FREEIPA_VERSIONS, versions.get(0).getVersions());
    assertEquals(FREEIPA_IMAGE_IDS, versions.get(0).getImageIds());
    assertTrue(versions.get(0).getDefaults().isEmpty());
}
Also used : Versions(com.sequenceiq.cloudbreak.cloud.model.catalog.Versions) CloudbreakVersion(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakVersion) CloudbreakImageCatalogV3(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3) Test(org.junit.Test)

Example 2 with Versions

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

the class CloudbreakVersionListProviderTest method testGetVersionsWithCloudbreakVersions.

@Test
public void testGetVersionsWithCloudbreakVersions() {
    CloudbreakImageCatalogV3 catalog = new CloudbreakImageCatalogV3(null, new Versions(cloudbreakVersions(), null));
    List<CloudbreakVersion> versions = underTest.getVersions(catalog);
    assertEquals(1, versions.size());
    assertEquals(CLOUDBREAK_VERSIONS, versions.get(0).getVersions());
    assertEquals(CLOUDBREAK_IMAGE_IDS, versions.get(0).getImageIds());
    assertEquals(CLOUDBREAK_DEFAULTS, versions.get(0).getDefaults());
}
Also used : Versions(com.sequenceiq.cloudbreak.cloud.model.catalog.Versions) CloudbreakVersion(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakVersion) CloudbreakImageCatalogV3(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3) Test(org.junit.Test)

Example 3 with Versions

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

the class VersionBasedImageCatalogServiceTest method testGetFreeipaImagesForCbVersionShouldReturnsEmptyListWhenThereAreNoSupportedImagesForCbVersion.

@Test
public void testGetFreeipaImagesForCbVersionShouldReturnsEmptyListWhenThereAreNoSupportedImagesForCbVersion() {
    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.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.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 4 with Versions

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

the class VersionBasedImageCatalogServiceTest method testValidateWithEmptyVersionBlock.

@Test
public void testValidateWithEmptyVersionBlock() {
    CloudbreakImageCatalogV3 catalog = createCatalog(new Versions(Collections.emptyList(), Collections.emptyList()));
    when(cloudbreakVersionListProvider.getVersions(any())).thenReturn(catalog.getVersions().getCloudbreakVersions());
    Exception exception = assertThrows(CloudbreakImageCatalogException.class, () -> victim.validate(catalog));
    assertEquals("Cloudbreak versions cannot be NULL", exception.getMessage());
}
Also used : Versions(com.sequenceiq.cloudbreak.cloud.model.catalog.Versions) CloudbreakImageCatalogV3(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) Test(org.junit.jupiter.api.Test)

Example 5 with Versions

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

the class VersionBasedImageCatalogServiceTest method testValidateFreeipaImagesWhichAllStoredInVersionBlock.

@Test
public void testValidateFreeipaImagesWhichAllStoredInVersionBlock() throws CloudbreakImageCatalogException {
    Image properImage1 = createImage(PROPER_IMAGE_ID);
    Image properImage2 = createImage(PROPER_IMAGE_ID_2);
    Image otherImage = createImage(OTHER_IMAGE_ID);
    when(images.getFreeIpaImages()).thenReturn(List.of(properImage1, properImage2, otherImage));
    Versions versions = createFreeipaVersions();
    when(cloudbreakVersionListProvider.getVersions(any())).thenReturn(versions.getFreeipaVersions());
    victim.validate(createCatalog(versions));
}
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