use of com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.request.CustomImageCatalogV4UpdateImageRequest in project cloudbreak by hortonworks.
the class CustomImageCatalogV4UpdateImageRequestToCustomImageConverterTest method shouldAllowNulls.
@Test
public void shouldAllowNulls() {
CustomImageCatalogV4UpdateImageRequest source = new CustomImageCatalogV4UpdateImageRequest();
source.setSourceImageId(null);
source.setBaseParcelUrl(null);
source.setImageType(null);
source.setVmImages(null);
CustomImage result = victim.convert(source);
assertNull(result.getCustomizedImageId());
assertNull(result.getBaseParcelUrl());
assertNull(result.getImageType());
assertNull(result.getVmImage());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.request.CustomImageCatalogV4UpdateImageRequest in project cloudbreak by hortonworks.
the class CustomImageCatalogV4UpdateImageRequestToCustomImageConverterTest method shouldConvert.
@Test
public void shouldConvert() {
CustomImageCatalogV4UpdateImageRequest source = new CustomImageCatalogV4UpdateImageRequest();
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.api.endpoint.v4.customimage.request.CustomImageCatalogV4UpdateImageRequest 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.request.CustomImageCatalogV4UpdateImageRequest in project cloudbreak by hortonworks.
the class CustomImageCatalogV4UpdateImageRequestToCustomImageConverterTest method shouldThrowExceptionInCaseOfInvalidImageType.
@Test
public void shouldThrowExceptionInCaseOfInvalidImageType() {
CustomImageCatalogV4UpdateImageRequest source = new CustomImageCatalogV4UpdateImageRequest();
source.setImageType(INVALID_IMAGE_TYPE);
assertThrows(IllegalArgumentException.class, () -> victim.convert(source));
}
Aggregations