use of com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImagesV4Response in project cloudbreak by hortonworks.
the class ImagesToImagesV4ResponseConverterTest method testConvert.
@Test
public void testConvert() {
setupStackEntries();
ImagesV4Response result = underTest.convert(createSource());
assertEquals(1, result.getCdhImages().size());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImagesV4Response in project cloudbreak by hortonworks.
the class CoreImageProviderTest method testGetImages.
@Test
public void testGetImages() throws Exception {
ImagesV4Response imagesV4Response = new ImagesV4Response();
imagesV4Response.setFreeipaImages(List.of(anImageResponse()));
when(imageCatalogV4Endpoint.getImagesByName(WORKSPACE_ID_DEFAULT, CATALOG_NAME, null, PLATFORM, null, null, false)).thenReturn(imagesV4Response);
ImageSettingsRequest imageSettings = new ImageSettingsRequest();
imageSettings.setCatalog(CATALOG_NAME);
List<ImageWrapper> result = victim.getImages(imageSettings, "", PLATFORM);
assertEquals(1, result.size());
ImageWrapper imageWrapper = result.get(0);
assertEquals(CATALOG_NAME, imageWrapper.getCatalogName());
assertNull(imageWrapper.getCatalogUrl());
Image image = imageWrapper.getImage();
assertEquals(DATE, image.getDate());
assertEquals(DESCRIPTION, image.getDescription());
assertEquals(UUID, image.getUuid());
assertEquals(OS_TYPE, image.getOsType());
assertEquals(VM_IMAGE_REFERENCE, image.getImageSetsByProvider().get(PLATFORM).get(REGION));
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImagesV4Response in project cloudbreak by hortonworks.
the class CoreImageProvider method getImages.
@Override
public List<ImageWrapper> getImages(ImageSettingsRequest imageSettings, String region, String platform) {
try {
ImagesV4Response imagesV4Response = imageCatalogV4Endpoint.getImagesByName(WORKSPACE_ID_DEFAULT, imageSettings.getCatalog(), null, platform, null, null, false);
LOGGER.debug("Images received: {}", imagesV4Response);
return Optional.ofNullable(imagesV4Response.getFreeipaImages()).orElseGet(List::of).stream().map(this::convert).flatMap(Optional::stream).map(img -> new ImageWrapper(img, null, imageSettings.getCatalog())).collect(Collectors.toList());
} catch (WebApplicationException e) {
String errorMessage = messageExtractor.getErrorMessage(e);
LOGGER.warn("Fetching images failed with: {}", errorMessage, e);
return List.of();
} catch (Exception e) {
LOGGER.warn("Fetching images failed", e);
return List.of();
}
}
Aggregations