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