Search in sources :

Example 1 with ImageSettingsBase

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsBase in project cloudbreak by hortonworks.

the class ImageServiceTest method testGenerateForStack.

@Test
void testGenerateForStack() throws NoSuchFieldException {
    ReflectionUtils.setField(ImageService.class.getDeclaredField("freeIpaVersion"), underTest, FREEIPA_VERSION);
    Stack stack = new Stack();
    stack.setRegion(DEFAULT_REGION);
    stack.setCloudPlatform(DEFAULT_PLATFORM);
    ImageEntity imageEntity = new ImageEntity();
    imageEntity.setImageId(IMAGE_UUID);
    imageEntity.setOs(DEFAULT_OS);
    imageEntity.setImageCatalogName(IMAGE_CATALOG);
    imageEntity.setImageCatalogUrl(IMAGE_CATALOG_URL);
    when(imageRepository.getByStack(stack)).thenReturn(imageEntity);
    when(imageProviderFactory.getImageProvider(IMAGE_CATALOG)).thenReturn(imageProvider);
    Image image = new Image(123L, "now", "desc", DEFAULT_OS, IMAGE_UUID, Map.of(), "os", Map.of(), true);
    ImageWrapper imageWrapper = new ImageWrapper(image, IMAGE_CATALOG_URL, IMAGE_CATALOG);
    when(imageProvider.getImage(any(), any(), any())).thenReturn(Optional.of(imageWrapper));
    ImageCatalog result = underTest.generateImageCatalogForStack(stack);
    verify(imageProvider).getImage(imageSettingsRequestCaptor.capture(), eq(DEFAULT_REGION), eq(DEFAULT_PLATFORM));
    assertThat(imageSettingsRequestCaptor.getValue()).returns(IMAGE_CATALOG, ImageSettingsBase::getCatalog).returns(IMAGE_UUID, ImageSettingsBase::getId);
    assertThat(result.getImages().getFreeipaImages()).containsExactly(image);
    assertThat(result.getVersions()).isNull();
}
Also used : ImageEntity(com.sequenceiq.freeipa.entity.ImageEntity) ImageWrapper(com.sequenceiq.freeipa.dto.ImageWrapper) ImageSettingsBase(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsBase) Image(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image) ImageCatalog(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Aggregations

ImageSettingsBase (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsBase)1 Image (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image)1 ImageCatalog (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog)1 ImageWrapper (com.sequenceiq.freeipa.dto.ImageWrapper)1 ImageEntity (com.sequenceiq.freeipa.entity.ImageEntity)1 Stack (com.sequenceiq.freeipa.entity.Stack)1 Test (org.junit.jupiter.api.Test)1