Search in sources :

Example 1 with CustomImageCatalogV4VmImageResponse

use of com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4VmImageResponse 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 CustomImageCatalogV4VmImageResponse

use of com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4VmImageResponse 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)

Example 3 with CustomImageCatalogV4VmImageResponse

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

the class CustomImageToCustomImageCatalogV4GetImageResponseConverterTest method shouldConvert.

@Test
public void shouldConvert() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
    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)));
    when(imageCatalogService.getSourceImageByImageType(customImage)).thenReturn(statedImage);
    when(statedImage.getImage()).thenReturn(image);
    when(image.getCreated()).thenReturn(SOURCE_IMAGE_DATE);
    when(image.getImageSetsByProvider()).thenReturn(Map.of(CLOUD_PROVIDER, Map.of()));
    when(imageVersionsConverter.convert(image)).thenReturn(Collections.emptyMap());
    CustomImageCatalogV4GetImageResponse 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());
    assertNotNull(result.getImageDate());
    assertEquals(SOURCE_IMAGE_DATE, result.getSourceImageDate());
    assertEquals(CLOUD_PROVIDER, result.getCloudProvider());
    assertNotNull(result.getVersions());
    CustomImageCatalogV4VmImageResponse vmImage = result.getVmImages().stream().findFirst().get();
    assertEquals(REGION, vmImage.getRegion());
    assertEquals(IMAGE_REFERENCE, vmImage.getImageReference());
}
Also used : CustomImageCatalogV4VmImageResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4VmImageResponse) CustomImage(com.sequenceiq.cloudbreak.domain.CustomImage) CustomImageCatalogV4GetImageResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4GetImageResponse) Test(org.junit.jupiter.api.Test)

Aggregations

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