use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.
the class ImageCatalogServiceTest method setupCustomImageCatalog.
private void setupCustomImageCatalog(ImageType imageType, String customizedImageId, String baseParcelUrl) throws IOException, CloudbreakImageCatalogException {
ImageCatalog imageCatalog = getImageCatalog();
CustomImage customImage = getCustomImage(imageType, customizedImageId, baseParcelUrl);
imageCatalog.setCustomImages(Set.of(customImage));
setupImageCatalogProvider(CUSTOM_IMAGE_CATALOG_URL, imageType == ImageType.FREEIPA ? V3_FREEIPA_CATALOG_FILE : V3_CB_CATALOG_FILE);
ReflectionTestUtils.setField(underTest, ImageCatalogService.class, imageType == ImageType.FREEIPA ? "defaultFreeIpaCatalogUrl" : "defaultCatalogUrl", CUSTOM_IMAGE_CATALOG_URL, null);
when(imageCatalogRepository.findByNameAndWorkspaceId(anyString(), anyLong())).thenReturn(Optional.of(imageCatalog));
StatedImage statedImage = StatedImage.statedImage(getImage(), CUSTOM_IMAGE_CATALOG_URL, CUSTOM_CATALOG_NAME);
when(customImageProvider.mergeSourceImageAndCustomImageProperties(any(), any(), any(), any())).thenReturn(statedImage);
}
use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.
the class ImageCatalogServiceTest method getCustomImage.
private CustomImage getCustomImage(ImageType imageType, String customizedImageId, String baseParcelUrl) {
CustomImage customImage = new CustomImage();
customImage.setId(0L);
customImage.setName(CUSTOM_IMAGE_ID);
customImage.setDescription("Test image");
customImage.setImageType(imageType);
customImage.setCustomizedImageId(customizedImageId);
customImage.setBaseParcelUrl(baseParcelUrl);
return customImage;
}
use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.
the class ImageCatalogServiceTest method testGetImageShouldLookupCustomImageInCaseOfNullImageCatalogUrl.
@Test
public void testGetImageShouldLookupCustomImageInCaseOfNullImageCatalogUrl() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException, IOException {
ImageCatalog imageCatalog = new ImageCatalog();
CustomImage customImage = getCustomImage(ImageType.RUNTIME, "5b60b723-4beb-40b0-5cba-47ea9c9b6e53", CUSTOM_BASE_PARCEL_URL);
imageCatalog.setCustomImages(Set.of(customImage));
StatedImage statedImage = StatedImage.statedImage(getImage(), CUSTOM_IMAGE_CATALOG_URL, CUSTOM_CATALOG_NAME);
setupImageCatalogProvider(DEFAULT_CATALOG_URL, DEV_CATALOG_FILE);
when(restRequestThreadLocalService.getRequestedWorkspaceId()).thenReturn(WORKSPACE_ID);
when(imageCatalogRepository.findByNameAndWorkspaceId(CUSTOM_CATALOG_NAME, WORKSPACE_ID)).thenReturn(Optional.of(imageCatalog));
when(customImageProvider.mergeSourceImageAndCustomImageProperties(any(), any(), any(), any())).thenReturn(statedImage);
StatedImage actual = underTest.getImage(null, CUSTOM_CATALOG_NAME, CUSTOM_IMAGE_ID);
assertEquals(statedImage.getImage(), actual.getImage());
}
use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.
the class CustomImageCatalogServiceTest method testGetCustomImageShouldFailOnImageNotFound.
@Test
public void testGetCustomImageShouldFailOnImageNotFound() {
ImageCatalog imageCatalog = new ImageCatalog();
CustomImage expected = new CustomImage();
expected.setName(IMAGE_NAME);
when(imageCatalogService.getImageCatalogByName(WORKSPACE_ID, IMAGE_CATALOG_NAME)).thenReturn(imageCatalog);
assertThrows(NotFoundException.class, () -> victim.getCustomImage(WORKSPACE_ID, IMAGE_CATALOG_NAME, IMAGE_NAME));
}
use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.
the class CustomImageCatalogServiceTest method testGetSourceImage.
@Test
public void testGetSourceImage() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
CustomImage customImage = new CustomImage();
customImage.setCustomizedImageId(CUSTOMIZED_IMAGE_ID);
Image expected = createTestImage();
StatedImage statedImage = StatedImage.statedImage(expected, null, IMAGE_CATALOG_NAME);
when(imageCatalogService.getSourceImageByImageType(customImage)).thenReturn(statedImage);
Image actual = victim.getSourceImage(customImage);
assertEquals(expected, actual);
}
Aggregations