use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.
the class CustomImageCatalogV4CreateImageRequestToCustomImageConverterTest method shouldConvert.
@Test
public void shouldConvert() {
CustomImageCatalogV4CreateImageRequest source = new CustomImageCatalogV4CreateImageRequest();
source.setSourceImageId(SOURCE_IMAGE_ID);
source.setBaseParcelUrl(BASE_PARCEL_URL);
source.setImageType(VALID_IMAGE_TYPE);
source.setVmImages(Collections.singleton(getVmImageRequest(REGION, IMAGE_REFERENCE)));
CustomImage result = victim.convert(source);
assertEquals(SOURCE_IMAGE_ID, result.getCustomizedImageId());
assertEquals(BASE_PARCEL_URL, result.getBaseParcelUrl());
assertEquals(ImageType.RUNTIME, result.getImageType());
assertEquals(1, result.getVmImage().size());
VmImage vmImage = result.getVmImage().stream().findFirst().get();
assertEquals(REGION, vmImage.getRegion());
assertEquals(IMAGE_REFERENCE, vmImage.getImageReference());
}
use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.
the class CustomImageCatalogServiceTest method testGetCustomImage.
@Test
public void testGetCustomImage() {
CustomImage expected = new CustomImage();
expected.setName(IMAGE_NAME);
ImageCatalog imageCatalog = new ImageCatalog();
imageCatalog.setCustomImages(Collections.singleton(expected));
when(imageCatalogService.getImageCatalogByName(WORKSPACE_ID, IMAGE_CATALOG_NAME)).thenReturn(imageCatalog);
CustomImage actual = victim.getCustomImage(WORKSPACE_ID, IMAGE_CATALOG_NAME, IMAGE_NAME);
assertEquals(expected, actual);
}
use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.
the class CustomImageCatalogServiceTest method testUpdateCustomImageWithUpdatedVmImage.
@Test
public void testUpdateCustomImageWithUpdatedVmImage() throws TransactionService.TransactionExecutionException {
CustomImage updatedCustomImage = aCustomImage();
CustomImage savedCustomImage = new CustomImage();
VmImage vmImage = new VmImage();
vmImage.setRegion(REGION);
savedCustomImage.getVmImage().add(vmImage);
savedCustomImage.setName(IMAGE_NAME);
ImageCatalog imageCatalog = new ImageCatalog();
imageCatalog.getCustomImages().add(savedCustomImage);
doAnswer(invocation -> ((Supplier<CustomImage>) invocation.getArgument(0)).get()).when(transactionService).required(any(Supplier.class));
when(imageCatalogService.getImageCatalogByName(WORKSPACE_ID, IMAGE_CATALOG_NAME)).thenReturn(imageCatalog);
when(imageCatalogService.pureSave(imageCatalog)).thenReturn(imageCatalog);
CustomImage actual = victim.updateCustomImage(WORKSPACE_ID, CREATOR, IMAGE_CATALOG_NAME, updatedCustomImage);
assertEquals(1, imageCatalog.getCustomImages().size());
assertEquals(CUSTOMIZED_IMAGE_ID, actual.getCustomizedImageId());
assertEquals(BASE_PARCEL_URL, actual.getBaseParcelUrl());
assertEquals(ImageType.RUNTIME, actual.getImageType());
assertEquals(1, actual.getVmImage().size());
VmImage actualVmImage = actual.getVmImage().stream().findFirst().get();
assertNull(actualVmImage.getCreator());
assertEquals(REGION, actualVmImage.getRegion());
assertEquals(IMAGE_REFERENCE, actualVmImage.getImageReference());
}
use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.
the class CustomImageProviderTest 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(CUSTOM_IMAGE_DESCRIPTION);
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 CustomImageProviderTest method testMergeSourceImageAndCustomImagePropertiesInCaseOfRuntimeImage.
@Test
public void testMergeSourceImageAndCustomImagePropertiesInCaseOfRuntimeImage() throws Exception {
StatedImage statedImage = getStatedImageFromCatalog(V3_CB_CATALOG_FILE, "949bffa3-17d4-4076-9d5a-bf3d23c1086b");
CustomImage customImage = getCustomImage(ImageType.RUNTIME, CUSTOM_IMAGE_ID, CUSTOM_BASE_PARCEL_URL);
StatedImage image = underTest.mergeSourceImageAndCustomImageProperties(statedImage, customImage, CUSTOM_IMAGE_CATALOG_URL, CUSTOM_CATALOG_NAME);
assertEquals(customImage.getCreated(), image.getImage().getCreated());
assertEquals(customImage.getDescription(), image.getImage().getDescription());
assertEquals(CUSTOM_IMAGE_ID, image.getImage().getUuid());
assertEquals("https://myarchive.test.com/cm-public/7.2.2/redhat7/yum/", image.getImage().getRepo().get("redhat7"));
assertEquals("https://myarchive.test.com/cdp-public/7.2.2.0/parcels/", image.getImage().getStackDetails().getRepo().getStack().get("redhat7"));
assertFalse(image.getImage().getPreWarmParcels().contains(CUSTOM_BASE_PARCEL_URL));
assertFalse(image.getImage().getPreWarmCsd().contains(CUSTOM_BASE_PARCEL_URL));
assertTrue(image.getImage().getImageSetsByProvider().containsKey("aws"));
assertEquals(16, image.getImage().getImageSetsByProvider().get("aws").size());
}
Aggregations