use of com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.request.CustomImageCatalogV4CreateImageRequest in project cloudbreak by hortonworks.
the class CustomImageCatalogV4ControllerTest method testCreateCustomImage.
@Test
public void testCreateCustomImage() {
CustomImageCatalogV4CreateImageRequest request = new CustomImageCatalogV4CreateImageRequest();
CustomImage customImage = new CustomImage();
CustomImage savedCustomImage = new CustomImage();
CustomImageCatalogV4CreateImageResponse expected = new CustomImageCatalogV4CreateImageResponse();
when(customImageCatalogV4CreateImageRequestToCustomImageConverter.convert(request)).thenReturn(customImage);
when(restRequestThreadLocalService.getRequestedWorkspaceId()).thenReturn(WORKSPACE_ID);
when(customImageCatalogService.createCustomImage(eq(WORKSPACE_ID), anyString(), eq(USER_CRN), eq(IMAGE_CATALOG_NAME), eq(customImage))).thenReturn(savedCustomImage);
when(customImageToCustomImageCatalogV4CreateImageResponseConverter.convert(savedCustomImage)).thenReturn(expected);
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> {
CustomImageCatalogV4CreateImageResponse actual = victim.createCustomImage(IMAGE_CATALOG_NAME, request, ACCOUNT_ID);
assertEquals(expected, actual);
});
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.request.CustomImageCatalogV4CreateImageRequest 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.api.endpoint.v4.customimage.request.CustomImageCatalogV4CreateImageRequest in project cloudbreak by hortonworks.
the class CustomImageCatalogV4CreateImageRequestToCustomImageConverterTest method shouldThrowExceptionInCaseOfInvalidImageType.
@Test
public void shouldThrowExceptionInCaseOfInvalidImageType() {
CustomImageCatalogV4CreateImageRequest source = new CustomImageCatalogV4CreateImageRequest();
source.setImageType(INVALID_IMAGE_TYPE);
assertThrows(IllegalArgumentException.class, () -> victim.convert(source));
}
Aggregations