Search in sources :

Example 1 with ImageCatalog

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog in project cloudbreak by hortonworks.

the class FreeIpaImageProviderTest method setupImageCatalogProvider.

private ImageCatalog setupImageCatalogProvider(String catalogUrl, String catalogFile) throws IOException {
    String catalogJson = FileReaderUtils.readFileFromClasspath(catalogFile);
    ImageCatalog catalog = objectMapper.readValue(catalogJson, ImageCatalog.class);
    lenient().when(imageCatalogProvider.getImageCatalog(catalogUrl)).thenReturn(catalog);
    lenient().when(imageCatalogProvider.getImageCatalog(DEFAULT_CATALOG_URL)).thenReturn(catalog);
    return catalog;
}
Also used : ImageCatalog(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog)

Example 2 with ImageCatalog

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog in project cloudbreak by hortonworks.

the class ImageCatalogProviderTest method testReadImageCatalogFromFileWithoutVersionsButWithAdvertisedFlag.

@Test
public void testReadImageCatalogFromFileWithoutVersionsButWithAdvertisedFlag() {
    String path = getPath(IMAGE_CATALOG_WITHOUT_VERSIONS);
    ReflectionTestUtils.setField(underTest, "etcConfigDir", path);
    ReflectionTestUtils.setField(underTest, "enabledLinuxTypes", CB_CENTOS_7_FILTER);
    ImageCatalog catalog = underTest.getImageCatalog(IMAGE_CATALOG_WITHOUT_VERSIONS);
    List<com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image> images = catalog.getImages().getFreeipaImages();
    assertEquals(2, images.size());
    FreeIpaVersions freeIpaVersions = catalog.getVersions().getFreeIpaVersions().get(0);
    assertEquals(1, freeIpaVersions.getImageIds().size());
    assertEquals("91851893-8340-411d-afb7-e1b55107fb10", freeIpaVersions.getImageIds().get(0));
}
Also used : FreeIpaVersions(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.FreeIpaVersions) Image(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image) ImageCatalog(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog) Test(org.junit.Test)

Example 3 with ImageCatalog

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog in project cloudbreak by hortonworks.

the class ImageCatalogProviderTest method testImageCatalogFilterAllOs.

@Test
public void testImageCatalogFilterAllOs() {
    String path = getPath(IMAGE_CATALOG_FILTER_ALL_OS_JSON);
    ReflectionTestUtils.setField(underTest, "etcConfigDir", path);
    ReflectionTestUtils.setField(underTest, "enabledLinuxTypes", CB_CENTOS_7_FILTER);
    ImageCatalog actualCatalog = underTest.getImageCatalog(IMAGE_CATALOG_FILTER_ALL_OS_JSON);
    List<String> actualOsTypes = getImageCatalogOses(actualCatalog);
    assertEquals(Collections.emptyList(), actualOsTypes);
    assertEquals(Collections.emptyList(), mapToUuid(actualCatalog.getImages().getFreeipaImages()));
    assertEquals(0, actualCatalog.getImages().getFreeipaImages().size());
}
Also used : ImageCatalog(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog) Test(org.junit.Test)

Example 4 with ImageCatalog

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog in project cloudbreak by hortonworks.

the class ImageCatalogProviderTest method testReadImageCatalogFromFile.

@Test
public void testReadImageCatalogFromFile() {
    String path = getPath(IMAGE_CATALOG_JSON);
    ReflectionTestUtils.setField(underTest, "etcConfigDir", path);
    ReflectionTestUtils.setField(underTest, "enabledLinuxTypes", Collections.emptyList());
    ImageCatalog catalog = underTest.getImageCatalog(IMAGE_CATALOG_JSON);
    List<com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image> images = catalog.getImages().getFreeipaImages();
    assertEquals(4, images.size());
    assertEquals("61851893-8340-411d-afb7-e1b55107fb10", images.get(0).getUuid());
    FreeIpaVersions freeIpaVersions = catalog.getVersions().getFreeIpaVersions().get(0);
    assertEquals(2, freeIpaVersions.getImageIds().size());
    assertEquals("61851893-8340-411d-afb7-e1b55107fb10", freeIpaVersions.getImageIds().get(0));
    assertEquals(1, freeIpaVersions.getDefaults().size());
    assertEquals(List.of("71851893-8340-411d-afb7-e1b55107fb10"), freeIpaVersions.getDefaults());
    assertEquals(4, freeIpaVersions.getVersions().size());
}
Also used : FreeIpaVersions(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.FreeIpaVersions) Image(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image) ImageCatalog(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog) Test(org.junit.Test)

Example 5 with ImageCatalog

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog in project cloudbreak by hortonworks.

the class ImageCatalogProviderTest method testImageCatalogFilterOs.

@Test
public void testImageCatalogFilterOs() {
    String path = getPath(IMAGE_CATALOG_JSON);
    ReflectionTestUtils.setField(underTest, "etcConfigDir", path);
    ReflectionTestUtils.setField(underTest, "enabledLinuxTypes", CB_CENTOS_7_FILTER);
    ImageCatalog actualCatalog = underTest.getImageCatalog(IMAGE_CATALOG_JSON);
    List<String> actualOsTypes = getImageCatalogOses(actualCatalog);
    assertEquals(CB_CENTOS_7_FILTER, actualOsTypes);
    List<String> expectedImagesList = List.of("81851893-8340-411d-afb7-e1b55107fb10", "91851893-8340-411d-afb7-e1b55107fb10");
    assertEquals(expectedImagesList, mapToUuid(actualCatalog.getImages().getFreeipaImages()));
    assertEquals(List.of(), actualCatalog.getVersions().getFreeIpaVersions().get(0).getImageIds());
    assertEquals(List.of(), actualCatalog.getVersions().getFreeIpaVersions().get(0).getDefaults());
    assertEquals(2, actualCatalog.getImages().getFreeipaImages().size());
}
Also used : ImageCatalog(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog) Test(org.junit.Test)

Aggregations

ImageCatalog (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog)16 Image (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image)7 FreeIpaVersions (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.FreeIpaVersions)5 Test (org.junit.Test)5 ImageSettingsRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest)4 Stack (com.sequenceiq.freeipa.entity.Stack)4 ImageWrapper (com.sequenceiq.freeipa.dto.ImageWrapper)3 Images (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Images)2 Versions (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Versions)2 GenerateImageCatalogResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.imagecatalog.GenerateImageCatalogResponse)2 Test (org.junit.jupiter.api.Test)2 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)1 ImageSettingsBase (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsBase)1 ImageEntity (com.sequenceiq.freeipa.entity.ImageEntity)1 IOException (java.io.IOException)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 List (java.util.List)1