Search in sources :

Example 1 with CustomImageCatalogV4UpdateImageRequest

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

Example 2 with CustomImageCatalogV4UpdateImageRequest

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

Example 3 with CustomImageCatalogV4UpdateImageRequest

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);
    });
}
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 4 with CustomImageCatalogV4UpdateImageRequest

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

Aggregations

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