Search in sources :

Example 1 with CustomImageCatalogV4GetResponse

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

the class ImageCatalogToCustomImageCatalogV4GetResponseConverter method convert.

public CustomImageCatalogV4GetResponse convert(ImageCatalog source) {
    CustomImageCatalogV4GetResponse result = new CustomImageCatalogV4GetResponse();
    result.setName(source.getName());
    result.setDescription(source.getDescription());
    result.setImages(source.getCustomImages().stream().map(this::getImage).collect(Collectors.toSet()));
    return result;
}
Also used : CustomImageCatalogV4GetResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4GetResponse)

Example 2 with CustomImageCatalogV4GetResponse

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

the class ImageCatalogToCustomImageCatalogV4GetResponseConverterTest method shouldConvert.

@Test
public void shouldConvert() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
    CustomImage customImage = getCustomImage(IMAGE_ID);
    ImageCatalog imageCatalog = new ImageCatalog();
    imageCatalog.setName(NAME);
    customImage.setImageType(ImageType.RUNTIME);
    customImage.setCustomizedImageId(SOURCE_IMAGE_ID);
    imageCatalog.setDescription(DESCRIPTION);
    imageCatalog.setCustomImages(Collections.singleton(customImage));
    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());
    CustomImageCatalogV4GetResponse result = victim.convert(imageCatalog);
    assertEquals(NAME, result.getName());
    assertEquals(DESCRIPTION, result.getDescription());
    assertEquals(1, result.getImages().size());
    CustomImageCatalogV4ImageListItemResponse imageResult = result.getImages().stream().findFirst().get();
    assertEquals(IMAGE_ID, imageResult.getImageId());
    assertEquals(SOURCE_IMAGE_ID, imageResult.getSourceImageId());
    assertNotNull(imageResult.getImageDate());
    assertEquals(SOURCE_IMAGE_DATE, imageResult.getSourceImageDate());
    assertEquals(CLOUD_PROVIDER, imageResult.getCloudProvider());
    assertNotNull(imageResult.getVersions());
    assertEquals(ImageType.RUNTIME.name(), imageResult.getImageType());
}
Also used : CustomImageCatalogV4ImageListItemResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4ImageListItemResponse) CustomImage(com.sequenceiq.cloudbreak.domain.CustomImage) CustomImageCatalogV4GetResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4GetResponse) ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog) Test(org.junit.jupiter.api.Test)

Example 3 with CustomImageCatalogV4GetResponse

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

the class CustomImageCatalogV4ControllerTest method testGet.

@Test
public void testGet() {
    ImageCatalog imageCatalog = new ImageCatalog();
    CustomImageCatalogV4GetResponse expected = new CustomImageCatalogV4GetResponse();
    when(restRequestThreadLocalService.getRequestedWorkspaceId()).thenReturn(WORKSPACE_ID);
    when(customImageCatalogService.getImageCatalog(WORKSPACE_ID, IMAGE_CATALOG_NAME)).thenReturn(imageCatalog);
    when(imageCatalogToCustomImageCatalogV4GetResponseConverter.convert(imageCatalog)).thenReturn(expected);
    CustomImageCatalogV4GetResponse actual = victim.get(IMAGE_CATALOG_NAME, ACCOUNT_ID);
    assertEquals(expected, actual);
}
Also used : CustomImageCatalogV4GetResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4GetResponse) ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog) Test(org.junit.jupiter.api.Test)

Aggregations

CustomImageCatalogV4GetResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4GetResponse)3 ImageCatalog (com.sequenceiq.cloudbreak.domain.ImageCatalog)2 Test (org.junit.jupiter.api.Test)2 CustomImageCatalogV4ImageListItemResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4ImageListItemResponse)1 CustomImage (com.sequenceiq.cloudbreak.domain.CustomImage)1