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;
}
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());
}
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);
}
Aggregations