Search in sources :

Example 1 with CustomImageCatalogV4CreateImageResponse

use of com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4CreateImageResponse 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);
    });
}
Also used : CustomImageCatalogV4CreateImageRequest(com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.request.CustomImageCatalogV4CreateImageRequest) CustomImageCatalogV4CreateImageResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4CreateImageResponse) CustomImage(com.sequenceiq.cloudbreak.domain.CustomImage) Test(org.junit.jupiter.api.Test)

Example 2 with CustomImageCatalogV4CreateImageResponse

use of com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4CreateImageResponse in project cloudbreak by hortonworks.

the class CustomImageToCustomImageCatalogV4CreateImageResponseConverter method convert.

public CustomImageCatalogV4CreateImageResponse convert(CustomImage source) {
    CustomImageCatalogV4CreateImageResponse result = new CustomImageCatalogV4CreateImageResponse();
    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;
}
Also used : CustomImageCatalogV4CreateImageResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4CreateImageResponse)

Example 3 with CustomImageCatalogV4CreateImageResponse

use of com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4CreateImageResponse 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());
}
Also used : CustomImageCatalogV4CreateImageResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4CreateImageResponse) CustomImageCatalogV4VmImageResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4VmImageResponse) CustomImage(com.sequenceiq.cloudbreak.domain.CustomImage) Test(org.junit.jupiter.api.Test)

Aggregations

CustomImageCatalogV4CreateImageResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4CreateImageResponse)3 CustomImage (com.sequenceiq.cloudbreak.domain.CustomImage)2 Test (org.junit.jupiter.api.Test)2 CustomImageCatalogV4CreateImageRequest (com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.request.CustomImageCatalogV4CreateImageRequest)1 CustomImageCatalogV4VmImageResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4VmImageResponse)1