Search in sources :

Example 1 with CustomImageCatalogV4UpdateImageResponse

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

Example 2 with CustomImageCatalogV4UpdateImageResponse

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

Example 3 with CustomImageCatalogV4UpdateImageResponse

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;
}
Also used : CustomImageCatalogV4UpdateImageResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4UpdateImageResponse)

Aggregations

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