use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image in project cloudbreak by hortonworks.
the class UpgradeImageServiceTest method testFindTargetImagesCurrentImageMissingDate.
@Test
public void testFindTargetImagesCurrentImageMissingDate() {
Stack stack = new Stack();
stack.setCloudPlatform("AWS");
stack.setRegion("reg");
ImageSettingsRequest imageSettingsRequest = new ImageSettingsRequest();
Image image = createImage("2021-09-01");
ImageWrapper imageWrapper = new ImageWrapper(image, "catalogURL", "catalogName");
when(imageService.fetchImagesWrapperAndName(stack, imageSettingsRequest)).thenReturn(List.of(Pair.of(imageWrapper, "imageName")));
ArgumentCaptor<ImageSettingsRequest> captor = ArgumentCaptor.forClass(ImageSettingsRequest.class);
Image currentImageFromCatalog = createImage("2021-08-01");
ImageWrapper currentImageWrapperFromCatalog = new ImageWrapper(currentImageFromCatalog, "asdf", "Asdf");
when(imageService.getImage(captor.capture(), eq(stack.getRegion()), eq(stack.getCloudPlatform().toLowerCase()))).thenReturn(currentImageWrapperFromCatalog);
ImageInfoResponse currentImage = new ImageInfoResponse();
currentImage.setId("222-333");
currentImage.setCatalog("cat");
currentImage.setCatalogName("catName");
currentImage.setOs("zOs");
List<ImageInfoResponse> targetImages = underTest.findTargetImages(stack, imageSettingsRequest, currentImage);
assertEquals(1, targetImages.size());
ImageInfoResponse imageInfoResponse = targetImages.get(0);
assertEquals(imageWrapper.getCatalogName(), imageInfoResponse.getCatalogName());
assertEquals(imageWrapper.getCatalogUrl(), imageInfoResponse.getCatalog());
assertEquals(image.getDate(), imageInfoResponse.getDate());
assertEquals(image.getUuid(), imageInfoResponse.getId());
assertEquals(image.getOs(), imageInfoResponse.getOs());
ImageSettingsRequest settingsRequest = captor.getValue();
assertEquals(currentImage.getCatalog(), settingsRequest.getCatalog());
assertEquals(currentImage.getId(), settingsRequest.getId());
assertEquals(currentImage.getOs(), settingsRequest.getOs());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image in project cloudbreak by hortonworks.
the class FreeIpaImageProviderTest method testGetImagesGivenIdInputFound.
@Test
public void testGetImagesGivenIdInputFound() {
ImageSettingsRequest is = setupImageSettingsRequest(EXISTING_ID, null, null);
List<ImageWrapper> images = underTest.getImages(is, DEFAULT_REGION, DEFAULT_PLATFORM);
assertEquals(1, images.size());
ImageWrapper imageWrapper = images.get(0);
assertEquals(DEFAULT_CATALOG_URL, imageWrapper.getCatalogUrl());
assertNull(imageWrapper.getCatalogName());
Image image = imageWrapper.getImage();
assertEquals(DEFAULT_OS, image.getOs());
assertEquals(LATEST_DATE, image.getDate());
assertEquals(IMAGE_UUID, image.getUuid());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image in project cloudbreak by hortonworks.
the class FreeIpaImageProviderTest method testGetImageGivenUuidInputFoundWithNotDefaultOs.
@Test
public void testGetImageGivenUuidInputFoundWithNotDefaultOs() {
ImageSettingsRequest is = setupImageSettingsRequest(NON_DEFAULT_OS_IMAGE_UUID, null, null);
Image image = underTest.getImage(is, DEFAULT_REGION, DEFAULT_PLATFORM).get().getImage();
assertEquals(NON_DEFAULT_OS_IMAGE_UUID, image.getUuid());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image in project cloudbreak by hortonworks.
the class FreeIpaImageProviderTest method testGetImageGivenAllInputNonExistentOS.
@Test
public void testGetImageGivenAllInputNonExistentOS() {
ImageSettingsRequest is = setupImageSettingsRequest(EXISTING_ID, CUSTOM_IMAGE_CATALOG_URL, NON_EXISTING_OS);
Image image = underTest.getImage(is, DEFAULT_REGION, DEFAULT_PLATFORM).get().getImage();
assertEquals(DEFAULT_OS, image.getOs());
assertEquals(LATEST_DATE, image.getDate());
assertEquals(IMAGE_UUID, image.getUuid());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image in project cloudbreak by hortonworks.
the class FreeIpaImageProviderTest method testGetImageGivenIdInputFound.
@Test
public void testGetImageGivenIdInputFound() {
ImageSettingsRequest is = setupImageSettingsRequest(EXISTING_ID, null, null);
Image image = underTest.getImage(is, DEFAULT_REGION, DEFAULT_PLATFORM).get().getImage();
assertEquals(DEFAULT_OS, image.getOs());
assertEquals(LATEST_DATE, image.getDate());
assertEquals(IMAGE_UUID, image.getUuid());
}
Aggregations