use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog in project cloudbreak by hortonworks.
the class ImageService method generateImageCatalogForStack.
public ImageCatalog generateImageCatalogForStack(Stack stack) {
final Image image = getImageForStack(stack);
final Images images = new Images(List.of(copyImageWithAdvertisedFlag(image)));
return new ImageCatalog(images, null);
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog 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();
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog in project cloudbreak by hortonworks.
the class FreeIpaImageProviderTest method setup.
@BeforeEach
public void setup() throws Exception {
ImageCatalog imageCatalog = setupImageCatalogProvider(CUSTOM_IMAGE_CATALOG_URL, CATALOG_FILE);
imageCatalog.getImages().getFreeipaImages().get(0);
ReflectionTestUtils.setField(underTest, FreeIpaImageProvider.class, "defaultOs", DEFAULT_OS, null);
ReflectionTestUtils.setField(underTest, FreeIpaImageProvider.class, "defaultCatalogUrl", DEFAULT_CATALOG_URL, null);
ReflectionTestUtils.setField(underTest, FreeIpaImageProvider.class, "freeIpaVersion", DEFAULT_VERSION, null);
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog in project cloudbreak by hortonworks.
the class ImageCatalogGeneratorServiceTest method generate.
@Test
void generate() {
Stack stack = new Stack();
when(stackService.getByEnvironmentCrnAndAccountId(ENVIRONMENT_CRN, ACCOUNT_ID)).thenReturn(stack);
ImageCatalog imageCatalog = new ImageCatalog(null, null);
when(imageService.generateImageCatalogForStack(stack)).thenReturn(imageCatalog);
GenerateImageCatalogResponse result = underTest.generate(ENVIRONMENT_CRN, ACCOUNT_ID);
Assertions.assertThat(result.getImageCatalog()).isEqualTo(imageCatalog);
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.ImageCatalog in project cloudbreak by hortonworks.
the class ImageCatalogProviderTest method testImageCatalogFilterNothing.
@Test
public void testImageCatalogFilterNothing() {
String path = getPath(IMAGE_CATALOG_JSON);
ReflectionTestUtils.setField(underTest, "etcConfigDir", path);
ReflectionTestUtils.setField(underTest, "enabledLinuxTypes", Collections.emptyList());
ImageCatalog actualCatalog = underTest.getImageCatalog(IMAGE_CATALOG_JSON);
List<String> actualOsTypes = getImageCatalogOses(actualCatalog);
assertEquals(IMAGE_CATALOG_OS_TYPES, actualOsTypes);
List<String> expectedIds = List.of("61851893-8340-411d-afb7-e1b55107fb10", "71851893-8340-411d-afb7-e1b55107fb10", "81851893-8340-411d-afb7-e1b55107fb10", "91851893-8340-411d-afb7-e1b55107fb10");
assertEquals(expectedIds, mapToUuid(actualCatalog.getImages().getFreeipaImages()));
assertEquals(List.of("61851893-8340-411d-afb7-e1b55107fb10", "71851893-8340-411d-afb7-e1b55107fb10"), actualCatalog.getVersions().getFreeIpaVersions().get(0).getImageIds());
}
Aggregations