@Test public void testGetImageGivenNoInputWithInvalidAppVersion() { ReflectionTestUtils.setField(underTest, ImageService.class, "freeIpaVersion", "2.21.0-dcv.1", null); ImageSettingsRequest is = setupImageSettingsRequest(null, null, "centos7"); Image image = underTest.getImage(is, DEFAULT_REGION, DEFAULT_PLATFORM); assertEquals("centos7", image.getOs()); assertEquals("Assuming the latest image to be selected", "2019-05-09", image.getDate()); assertEquals("91851893-8340-411d-afb7-e1b55107fb10", image.getUuid()); }
public Image getImage(ImageSettingsRequest imageSettings, String region, String platform) { String imageId = imageSettings.getId(); String catalogUrl = Objects.nonNull(imageSettings.getCatalog()) ? imageSettings.getCatalog() : defaultCatalogUrl; String imageOs = Objects.nonNull(imageSettings.getOs()) ? imageSettings.getOs() : defaultOs; ImageCatalog cachedImageCatalog = imageCatalogProvider.getImageCatalog(catalogUrl); return findImageForAppVersion(region, platform, imageId, imageOs, cachedImageCatalog) .or(() -> retryAfterEvictingCache(region, platform, imageId, catalogUrl, imageOs)) .orElseThrow(() -> throwImageNotFoundException(region, imageId, imageOs)); }
ImageService { public Image getImage(ImageSettingsRequest imageSettings, String region, String platform) { String imageId = imageSettings.getId(); String catalogUrl = Objects.nonNull(imageSettings.getCatalog()) ? imageSettings.getCatalog() : defaultCatalogUrl; String imageOs = Objects.nonNull(imageSettings.getOs()) ? imageSettings.getOs() : defaultOs; ImageCatalog cachedImageCatalog = imageCatalogProvider.getImageCatalog(catalogUrl); return findImageForAppVersion(region, platform, imageId, imageOs, cachedImageCatalog) .or(() -> retryAfterEvictingCache(region, platform, imageId, catalogUrl, imageOs)) .orElseThrow(() -> throwImageNotFoundException(region, imageId, imageOs)); } }
ImageService { public Image getImage(ImageSettingsRequest imageSettings, String region, String platform) { String imageId = imageSettings.getId(); String catalogUrl = Objects.nonNull(imageSettings.getCatalog()) ? imageSettings.getCatalog() : defaultCatalogUrl; String imageOs = Objects.nonNull(imageSettings.getOs()) ? imageSettings.getOs() : defaultOs; ImageCatalog cachedImageCatalog = imageCatalogProvider.getImageCatalog(catalogUrl); return findImageForAppVersion(region, platform, imageId, imageOs, cachedImageCatalog) .or(() -> retryAfterEvictingCache(region, platform, imageId, catalogUrl, imageOs)) .orElseThrow(() -> throwImageNotFoundException(region, imageId, imageOs)); }  }
ImageService { public Image getImage(ImageSettingsRequest imageSettings, String region, String platform) { String imageId = imageSettings.getId(); String catalogUrl = Objects.nonNull(imageSettings.getCatalog()) ? imageSettings.getCatalog() : defaultCatalogUrl; String imageOs = Objects.nonNull(imageSettings.getOs()) ? imageSettings.getOs() : defaultOs; ImageCatalog cachedImageCatalog = imageCatalogProvider.getImageCatalog(catalogUrl); return findImageForAppVersion(region, platform, imageId, imageOs, cachedImageCatalog) .or(() -> retryAfterEvictingCache(region, platform, imageId, catalogUrl, imageOs)) .orElseThrow(() -> throwImageNotFoundException(region, imageId, imageOs)); }  ImageEntity create(Stack stack, ImageSettingsRequest imageRequest); ImageEntity getByStack(Stack stack); ImageEntity getByStackId(Long stackId); ImageEntity decorateImageWithUserDataForStack(Stack stack, String userdata); Image getImage(ImageSettingsRequest imageSettings, String region, String platform); String determineImageName(String platformString, String region, Image imgFromCatalog); }
ImageService { public Image getImage(ImageSettingsRequest imageSettings, String region, String platform) { String imageId = imageSettings.getId(); String catalogUrl = Objects.nonNull(imageSettings.getCatalog()) ? imageSettings.getCatalog() : defaultCatalogUrl; String imageOs = Objects.nonNull(imageSettings.getOs()) ? imageSettings.getOs() : defaultOs; ImageCatalog cachedImageCatalog = imageCatalogProvider.getImageCatalog(catalogUrl); return findImageForAppVersion(region, platform, imageId, imageOs, cachedImageCatalog) .or(() -> retryAfterEvictingCache(region, platform, imageId, catalogUrl, imageOs)) .orElseThrow(() -> throwImageNotFoundException(region, imageId, imageOs)); }  ImageEntity create(Stack stack, ImageSettingsRequest imageRequest); ImageEntity getByStack(Stack stack); ImageEntity getByStackId(Long stackId); ImageEntity decorateImageWithUserDataForStack(Stack stack, String userdata); Image getImage(ImageSettingsRequest imageSettings, String region, String platform); String determineImageName(String platformString, String region, Image imgFromCatalog);  }