use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.
the class CustomImageCatalogServiceTest method testCreateCustomImageShouldFailInCaseOfMissingSourceImage.
@Test
public void testCreateCustomImageShouldFailInCaseOfMissingSourceImage() throws TransactionService.TransactionExecutionException {
ImageCatalog imageCatalog = new ImageCatalog();
imageCatalog.setImageCatalogUrl(IMAGE_CATALOG_URL);
doAnswer(invocation -> ((Supplier<CustomImage>) invocation.getArgument(0)).get()).when(transactionService).required(any(Supplier.class));
when(imageCatalogService.getImageCatalogByName(WORKSPACE_ID, IMAGE_CATALOG_NAME)).thenReturn(imageCatalog);
assertThrows(BadRequestException.class, () -> victim.createCustomImage(WORKSPACE_ID, ACCOUNT_ID, CREATOR, IMAGE_CATALOG_NAME, null));
}
use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.
the class ImageCatalogService method getImages.
private List<Image> getImages(ImageType imageType, ImageCatalog imageCatalog, Set<String> providers) throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
List<Image> images = new ArrayList<>();
for (CustomImage customImage : imageCatalog.getCustomImages()) {
if (imageType == customImage.getImageType()) {
StatedImage sourceImage = getSourceImageByImageType(customImage);
Optional<String> provider = sourceImage.getImage().getImageSetsByProvider().keySet().stream().findFirst();
provider.ifPresent(p -> {
if (providers.stream().anyMatch(p::equalsIgnoreCase)) {
images.add(customImageProvider.mergeSourceImageAndCustomImageProperties(sourceImage, customImage, imageCatalog.getImageCatalogUrl(), imageCatalog.getName()).getImage());
}
});
}
}
return images;
}
Aggregations