use of com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4UpdateImageResponse 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.CustomImageCatalogV4UpdateImageResponse in project cloudbreak by hortonworks.
the class CustomImageCatalogV4ControllerTest method testUpdateCustomImage.
@Test
public void testUpdateCustomImage() {
CustomImageCatalogV4UpdateImageRequest request = new CustomImageCatalogV4UpdateImageRequest();
CustomImage customImage = new CustomImage();
CustomImage savedCustomImage = new CustomImage();
CustomImageCatalogV4UpdateImageResponse expected = new CustomImageCatalogV4UpdateImageResponse();
when(customImageCatalogV4UpdateImageRequestToCustomImageConverter.convert(request)).thenReturn(customImage);
when(restRequestThreadLocalService.getRequestedWorkspaceId()).thenReturn(WORKSPACE_ID);
when(customImageCatalogService.updateCustomImage(eq(WORKSPACE_ID), eq(USER_CRN), eq(IMAGE_CATALOG_NAME), eq(customImage))).thenReturn(savedCustomImage);
when(customImageToCustomImageCatalogV4UpdateImageResponseConverter.convert(savedCustomImage)).thenReturn(expected);
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> {
CustomImageCatalogV4UpdateImageResponse actual = victim.updateCustomImage(IMAGE_CATALOG_NAME, IMAGE_ID, request, ACCOUNT_ID);
assertEquals(expected, actual);
});
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4UpdateImageResponse in project cloudbreak by hortonworks.
the class CustomImageToCustomImageCatalogV4UpdateImageResponseConverter method convert.
public CustomImageCatalogV4UpdateImageResponse convert(CustomImage source) {
CustomImageCatalogV4UpdateImageResponse result = new CustomImageCatalogV4UpdateImageResponse();
result.setImageId(source.getName());
result.setImageType(source.getImageType() != null ? source.getImageType().name() : null);
result.setSourceImageId(source.getCustomizedImageId());
result.setBaseParcelUrl(source.getBaseParcelUrl());
result.setVmImages(getVmImages(source.getVmImage()));
return result;
}
Aggregations