Search in sources :

Example 11 with CustomImage

use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.

the class CustomImageCatalogV4CreateImageRequestToCustomImageConverterTest method shouldConvert.

@Test
public void shouldConvert() {
    CustomImageCatalogV4CreateImageRequest source = new CustomImageCatalogV4CreateImageRequest();
    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 : CustomImageCatalogV4CreateImageRequest(com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.request.CustomImageCatalogV4CreateImageRequest) CustomImage(com.sequenceiq.cloudbreak.domain.CustomImage) VmImage(com.sequenceiq.cloudbreak.domain.VmImage) Test(org.junit.jupiter.api.Test)

Example 12 with CustomImage

use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.

the class CustomImageCatalogServiceTest method testGetCustomImage.

@Test
public void testGetCustomImage() {
    CustomImage expected = new CustomImage();
    expected.setName(IMAGE_NAME);
    ImageCatalog imageCatalog = new ImageCatalog();
    imageCatalog.setCustomImages(Collections.singleton(expected));
    when(imageCatalogService.getImageCatalogByName(WORKSPACE_ID, IMAGE_CATALOG_NAME)).thenReturn(imageCatalog);
    CustomImage actual = victim.getCustomImage(WORKSPACE_ID, IMAGE_CATALOG_NAME, IMAGE_NAME);
    assertEquals(expected, actual);
}
Also used : CustomImage(com.sequenceiq.cloudbreak.domain.CustomImage) ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog) Test(org.junit.jupiter.api.Test)

Example 13 with CustomImage

use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.

the class CustomImageCatalogServiceTest method testUpdateCustomImageWithUpdatedVmImage.

@Test
public void testUpdateCustomImageWithUpdatedVmImage() throws TransactionService.TransactionExecutionException {
    CustomImage updatedCustomImage = aCustomImage();
    CustomImage savedCustomImage = new CustomImage();
    VmImage vmImage = new VmImage();
    vmImage.setRegion(REGION);
    savedCustomImage.getVmImage().add(vmImage);
    savedCustomImage.setName(IMAGE_NAME);
    ImageCatalog imageCatalog = new ImageCatalog();
    imageCatalog.getCustomImages().add(savedCustomImage);
    doAnswer(invocation -> ((Supplier<CustomImage>) invocation.getArgument(0)).get()).when(transactionService).required(any(Supplier.class));
    when(imageCatalogService.getImageCatalogByName(WORKSPACE_ID, IMAGE_CATALOG_NAME)).thenReturn(imageCatalog);
    when(imageCatalogService.pureSave(imageCatalog)).thenReturn(imageCatalog);
    CustomImage actual = victim.updateCustomImage(WORKSPACE_ID, CREATOR, IMAGE_CATALOG_NAME, updatedCustomImage);
    assertEquals(1, imageCatalog.getCustomImages().size());
    assertEquals(CUSTOMIZED_IMAGE_ID, actual.getCustomizedImageId());
    assertEquals(BASE_PARCEL_URL, actual.getBaseParcelUrl());
    assertEquals(ImageType.RUNTIME, actual.getImageType());
    assertEquals(1, actual.getVmImage().size());
    VmImage actualVmImage = actual.getVmImage().stream().findFirst().get();
    assertNull(actualVmImage.getCreator());
    assertEquals(REGION, actualVmImage.getRegion());
    assertEquals(IMAGE_REFERENCE, actualVmImage.getImageReference());
}
Also used : CustomImage(com.sequenceiq.cloudbreak.domain.CustomImage) Supplier(java.util.function.Supplier) VmImage(com.sequenceiq.cloudbreak.domain.VmImage) ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog) Test(org.junit.jupiter.api.Test)

Example 14 with CustomImage

use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.

the class CustomImageProviderTest method getCustomImage.

private CustomImage getCustomImage(ImageType imageType, String customizedImageId, String baseParcelUrl) {
    CustomImage customImage = new CustomImage();
    customImage.setId(0L);
    customImage.setName(CUSTOM_IMAGE_ID);
    customImage.setDescription(CUSTOM_IMAGE_DESCRIPTION);
    customImage.setImageType(imageType);
    customImage.setCustomizedImageId(customizedImageId);
    customImage.setBaseParcelUrl(baseParcelUrl);
    return customImage;
}
Also used : CustomImage(com.sequenceiq.cloudbreak.domain.CustomImage)

Example 15 with CustomImage

use of com.sequenceiq.cloudbreak.domain.CustomImage in project cloudbreak by hortonworks.

the class CustomImageProviderTest method testMergeSourceImageAndCustomImagePropertiesInCaseOfRuntimeImage.

@Test
public void testMergeSourceImageAndCustomImagePropertiesInCaseOfRuntimeImage() throws Exception {
    StatedImage statedImage = getStatedImageFromCatalog(V3_CB_CATALOG_FILE, "949bffa3-17d4-4076-9d5a-bf3d23c1086b");
    CustomImage customImage = getCustomImage(ImageType.RUNTIME, CUSTOM_IMAGE_ID, CUSTOM_BASE_PARCEL_URL);
    StatedImage image = underTest.mergeSourceImageAndCustomImageProperties(statedImage, customImage, CUSTOM_IMAGE_CATALOG_URL, CUSTOM_CATALOG_NAME);
    assertEquals(customImage.getCreated(), image.getImage().getCreated());
    assertEquals(customImage.getDescription(), image.getImage().getDescription());
    assertEquals(CUSTOM_IMAGE_ID, image.getImage().getUuid());
    assertEquals("https://myarchive.test.com/cm-public/7.2.2/redhat7/yum/", image.getImage().getRepo().get("redhat7"));
    assertEquals("https://myarchive.test.com/cdp-public/7.2.2.0/parcels/", image.getImage().getStackDetails().getRepo().getStack().get("redhat7"));
    assertFalse(image.getImage().getPreWarmParcels().contains(CUSTOM_BASE_PARCEL_URL));
    assertFalse(image.getImage().getPreWarmCsd().contains(CUSTOM_BASE_PARCEL_URL));
    assertTrue(image.getImage().getImageSetsByProvider().containsKey("aws"));
    assertEquals(16, image.getImage().getImageSetsByProvider().get("aws").size());
}
Also used : CustomImage(com.sequenceiq.cloudbreak.domain.CustomImage) Test(org.junit.Test)

Aggregations

CustomImage (com.sequenceiq.cloudbreak.domain.CustomImage)47 Test (org.junit.jupiter.api.Test)26 ImageCatalog (com.sequenceiq.cloudbreak.domain.ImageCatalog)18 VmImage (com.sequenceiq.cloudbreak.domain.VmImage)13 Supplier (java.util.function.Supplier)11 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)9 CustomImageCatalogV4GetImageResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4GetImageResponse)4 CheckPermissionByResourceName (com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)3 CustomImageCatalogV4UpdateImageRequest (com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.request.CustomImageCatalogV4UpdateImageRequest)3 CustomImageCatalogV4VmImageResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4VmImageResponse)3 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)3 Test (org.junit.Test)3 CustomImageCatalogV4CreateImageRequest (com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.request.CustomImageCatalogV4CreateImageRequest)2 CustomImageCatalogV4CreateImageResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4CreateImageResponse)2 CustomImageCatalogV4DeleteImageResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4DeleteImageResponse)2 CustomImageCatalogV4ImageListItemResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4ImageListItemResponse)2 CustomImageCatalogV4UpdateImageResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4UpdateImageResponse)2 TransactionService (com.sequenceiq.cloudbreak.common.service.TransactionService)2 ConversionException (com.sequenceiq.cloudbreak.converter.ConversionException)2 StatedImage.statedImage (com.sequenceiq.cloudbreak.service.image.StatedImage.statedImage)2