use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.
the class CustomImageToCustomImageCatalogV4GetImageResponseConverterTest method shouldConvert.
@Test
public void shouldConvert() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
CustomImage customImage = new CustomImage();
customImage.setName(IMAGE_ID);
customImage.setImageType(ImageType.RUNTIME);
customImage.setBaseParcelUrl(BASE_PARCEL_URL);
customImage.setCustomizedImageId(SOURCE_IMAGE_ID);
customImage.setVmImage(Collections.singleton(getVmImage(REGION, IMAGE_REFERENCE)));
when(imageCatalogService.getSourceImageByImageType(customImage)).thenReturn(statedImage);
when(statedImage.getImage()).thenReturn(image);
when(image.getCreated()).thenReturn(SOURCE_IMAGE_DATE);
when(image.getImageSetsByProvider()).thenReturn(Map.of(CLOUD_PROVIDER, Map.of()));
when(imageVersionsConverter.convert(image)).thenReturn(Collections.emptyMap());
CustomImageCatalogV4GetImageResponse result = victim.convert(customImage);
assertEquals(IMAGE_ID, result.getImageId());
assertEquals(SOURCE_IMAGE_ID, result.getSourceImageId());
assertEquals(BASE_PARCEL_URL, result.getBaseParcelUrl());
assertEquals(ImageType.RUNTIME.name(), result.getImageType());
assertEquals(1, result.getVmImages().size());
assertNotNull(result.getImageDate());
assertEquals(SOURCE_IMAGE_DATE, result.getSourceImageDate());
assertEquals(CLOUD_PROVIDER, result.getCloudProvider());
assertNotNull(result.getVersions());
CustomImageCatalogV4VmImageResponse vmImage = result.getVmImages().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 ImageCatalogToCustomImageCatalogV4GetResponseConverterTest method shouldConvert.
@Test
public void shouldConvert() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
CustomImage customImage = getCustomImage(IMAGE_ID);
ImageCatalog imageCatalog = new ImageCatalog();
imageCatalog.setName(NAME);
customImage.setImageType(ImageType.RUNTIME);
customImage.setCustomizedImageId(SOURCE_IMAGE_ID);
imageCatalog.setDescription(DESCRIPTION);
imageCatalog.setCustomImages(Collections.singleton(customImage));
when(imageCatalogService.getSourceImageByImageType(customImage)).thenReturn(statedImage);
when(statedImage.getImage()).thenReturn(image);
when(image.getCreated()).thenReturn(SOURCE_IMAGE_DATE);
when(image.getImageSetsByProvider()).thenReturn(Map.of(CLOUD_PROVIDER, Map.of()));
when(imageVersionsConverter.convert(image)).thenReturn(Collections.emptyMap());
CustomImageCatalogV4GetResponse result = victim.convert(imageCatalog);
assertEquals(NAME, result.getName());
assertEquals(DESCRIPTION, result.getDescription());
assertEquals(1, result.getImages().size());
CustomImageCatalogV4ImageListItemResponse imageResult = result.getImages().stream().findFirst().get();
assertEquals(IMAGE_ID, imageResult.getImageId());
assertEquals(SOURCE_IMAGE_ID, imageResult.getSourceImageId());
assertNotNull(imageResult.getImageDate());
assertEquals(SOURCE_IMAGE_DATE, imageResult.getSourceImageDate());
assertEquals(CLOUD_PROVIDER, imageResult.getCloudProvider());
assertNotNull(imageResult.getVersions());
assertEquals(ImageType.RUNTIME.name(), imageResult.getImageType());
}
use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.
the class ImageCatalogToCustomImageCatalogV4GetResponseConverterTest method getCustomImage.
private CustomImage getCustomImage(String name) {
CustomImage customImage = new CustomImage();
customImage.setName(name);
return customImage;
}
use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.
the class CustomImageCatalogV4ControllerTest method testDeleteCustomImage.
@Test
public void testDeleteCustomImage() {
CustomImage customImage = new CustomImage();
CustomImageCatalogV4DeleteImageResponse expected = new CustomImageCatalogV4DeleteImageResponse();
when(restRequestThreadLocalService.getRequestedWorkspaceId()).thenReturn(WORKSPACE_ID);
when(customImageCatalogService.deleteCustomImage(WORKSPACE_ID, IMAGE_CATALOG_NAME, IMAGE_ID)).thenReturn(customImage);
when(customImageToCustomImageCatalogV4DeleteImageResponseConverter.convert(customImage)).thenReturn(expected);
CustomImageCatalogV4DeleteImageResponse actual = victim.deleteCustomImage(IMAGE_CATALOG_NAME, IMAGE_ID, ACCOUNT_ID);
assertEquals(expected, actual);
}
use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.
the class CustomImageCatalogV4ControllerTest method testGetCustomImage.
@Test
public void testGetCustomImage() {
CustomImage customImage = new CustomImage();
Image sourceImage = createTestImage();
CustomImageCatalogV4GetImageResponse expected = new CustomImageCatalogV4GetImageResponse();
expected.setSourceImageDate(12345L);
when(restRequestThreadLocalService.getRequestedWorkspaceId()).thenReturn(WORKSPACE_ID);
when(customImageCatalogService.getCustomImage(WORKSPACE_ID, IMAGE_CATALOG_NAME, IMAGE_ID)).thenReturn(customImage);
when(customImageToCustomImageCatalogV4GetImageResponseConverter.convert(customImage)).thenReturn(expected);
when(customImageCatalogService.getSourceImage(customImage)).thenReturn(sourceImage);
CustomImageCatalogV4GetImageResponse actual = victim.getCustomImage(IMAGE_CATALOG_NAME, IMAGE_ID, ACCOUNT_ID);
assertEquals(expected, actual);
}
Aggregations