use of com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3 in project cloudbreak by hortonworks.
the class CachedImageCatalogWrapperProviderTest method testReadImageCatalogFromFile.
@Test
public void testReadImageCatalogFromFile() throws Exception {
String path = getPath(CB_IMAGE_CATALOG_V2_JSON);
ReflectionTestUtils.setField(underTest, "etcConfigDir", path);
ReflectionTestUtils.setField(underTest, "enabledLinuxTypes", Collections.emptyList());
CloudbreakImageCatalogV3 catalog = underTest.getImageCatalogWrapper(CB_IMAGE_CATALOG_V2_JSON).getImageCatalog();
assertNotNull(catalog);
Optional<CloudbreakVersion> ver = catalog.getVersions().getCloudbreakVersions().stream().filter(v -> v.getVersions().contains(CB_VERSION)).findFirst();
Assertions.assertTrue(ver.isPresent(), "Check that the parsed ImageCatalog contains the desired version of Cloudbreak.");
List<String> imageIds = ver.get().getImageIds();
assertNotNull(imageIds);
Optional<String> imageIdOptional = imageIds.stream().findFirst();
Assertions.assertTrue(imageIdOptional.isPresent(), "Check that the parsed ImageCatalog contains image reference for the Cloudbreak version.");
String imageId = imageIdOptional.get();
boolean baseImageFound = false;
if (catalog.getImages().getBaseImages() != null) {
baseImageFound = catalog.getImages().getBaseImages().stream().anyMatch(i -> i.getUuid().equals(imageId));
}
Assertions.assertTrue(baseImageFound, "Check that the parsed ImageCatalog contains image for the Cloudbreak version.");
}
use of com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3 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());
}
use of com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3 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());
}
use of com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3 in project cloudbreak by hortonworks.
the class ImageProviderTest method testGetCurrentImageFromCatalogShouldThrowExceptionWhenTheCurrentImageIsNotFound.
@Test
public void testGetCurrentImageFromCatalogShouldThrowExceptionWhenTheCurrentImageIsNotFound() {
CloudbreakImageCatalogV3 imageCatalog = createImageCatalog(List.of("other-image1", "other-image2"));
Exception exception = assertThrows(CloudbreakImageNotFoundException.class, () -> underTest.getCurrentImageFromCatalog(CURRENT_IMAGE_ID, imageCatalog));
assertEquals("Image not found with id: current-image", exception.getMessage());
}
use of com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3 in project cloudbreak by hortonworks.
the class PrefixMatcherServiceTest method getVersions.
private static Collection<CloudbreakVersion> getVersions(String catalogFilePath) throws IOException {
String catalogJson = FileReaderUtils.readFileFromClasspath(catalogFilePath);
CloudbreakImageCatalogV3 catalog = JsonUtil.readValue(catalogJson, CloudbreakImageCatalogV3.class);
return catalog.getVersions().getCloudbreakVersions();
}
Aggregations