use of com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4VmImageResponse in project cloudbreak by hortonworks.
the class CustomImageToCustomImageCatalogV4UpdateImageResponseConverterTest method shouldConvert.
@Test
public void shouldConvert() {
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)));
CustomImageCatalogV4UpdateImageResponse 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());
CustomImageCatalogV4VmImageResponse vmImage = result.getVmImages().stream().findFirst().get();
assertEquals(REGION, vmImage.getRegion());
assertEquals(IMAGE_REFERENCE, vmImage.getImageReference());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4VmImageResponse in project cloudbreak by hortonworks.
the class CustomImageToCustomImageCatalogV4CreateImageResponseConverterTest method shouldConvert.
@Test
public void shouldConvert() {
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)));
CustomImageCatalogV4CreateImageResponse 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());
CustomImageCatalogV4VmImageResponse vmImage = result.getVmImages().stream().findFirst().get();
assertEquals(REGION, vmImage.getRegion());
assertEquals(IMAGE_REFERENCE, vmImage.getImageReference());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4VmImageResponse 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());
}
Aggregations