use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest in project cloudbreak by hortonworks.
the class ImageCatalogChangeService method getImageSettingsRequestForNewCatalogWithCurrentImageSettings.
private ImageSettingsRequest getImageSettingsRequestForNewCatalogWithCurrentImageSettings(String imageCatalog, ImageEntity image) {
final ImageSettingsRequest imageRequest = new ImageSettingsRequest();
imageRequest.setCatalog(imageCatalog);
imageRequest.setId(image.getImageId());
imageRequest.setOs(image.getOs());
return imageRequest;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest in project cloudbreak by hortonworks.
the class FreeIpaTestDto method withCatalog.
public FreeIpaTestDto withCatalog(String catalog) {
ImageSettingsRequest imageSettingsRequest = new ImageSettingsRequest();
imageSettingsRequest.setCatalog(catalog);
getRequest().setImage(imageSettingsRequest);
return this;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest in project cloudbreak by hortonworks.
the class UpgradeImageServiceTest method testFindTargetImagesCurrentImageMissingDateAndNoImageFoundInCatalog.
@Test
public void testFindTargetImagesCurrentImageMissingDateAndNoImageFoundInCatalog() {
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);
when(imageService.getImage(captor.capture(), eq(stack.getRegion()), eq(stack.getCloudPlatform().toLowerCase()))).thenThrow(new ImageNotFoundException("Image not found"));
ImageInfoResponse currentImage = new ImageInfoResponse();
currentImage.setId("222-333");
currentImage.setCatalogName("cat");
currentImage.setOs("zOs");
List<ImageInfoResponse> targetImages = underTest.findTargetImages(stack, imageSettingsRequest, currentImage);
assertTrue(targetImages.isEmpty());
ImageSettingsRequest settingsRequest = captor.getValue();
assertEquals(currentImage.getCatalogName(), settingsRequest.getCatalog());
assertEquals(currentImage.getId(), settingsRequest.getId());
assertEquals(currentImage.getOs(), settingsRequest.getOs());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest in project cloudbreak by hortonworks.
the class UpgradeImageServiceTest method testFindTargetImages.
@Test
public void testFindTargetImages() {
Stack stack = new Stack();
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")));
ImageInfoResponse currentImage = new ImageInfoResponse();
currentImage.setDate("2021-08-21");
currentImage.setId("111-222");
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());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest in project cloudbreak by hortonworks.
the class UpgradeImageServiceTest method testFindTargetImagesImageWithWrongDateFormatIgnored.
@Test
public void testFindTargetImagesImageWithWrongDateFormatIgnored() {
Stack stack = new Stack();
ImageSettingsRequest imageSettingsRequest = new ImageSettingsRequest();
Image image = createImage("2021-09-01");
ImageWrapper imageWrapper = new ImageWrapper(image, "catalogURL", "catalogName");
Image image2 = createImage("20210901");
ImageWrapper imageWrapper2 = new ImageWrapper(image2, "catalogURL", "catalogName");
when(imageService.fetchImagesWrapperAndName(stack, imageSettingsRequest)).thenReturn(List.of(Pair.of(imageWrapper, "imageName"), Pair.of(imageWrapper2, "imageName2")));
ImageInfoResponse currentImage = new ImageInfoResponse();
currentImage.setDate("2021-08-21");
currentImage.setId("111-222");
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());
}
Aggregations