@Test public void testGetImageGivenIdInputFound() { ImageSettingsRequest is = setupImageSettingsRequest(EXISTING_ID, null, null); Image image = underTest.getImage(is, DEFAULT_REGION, DEFAULT_PLATFORM); assertEquals(DEFAULT_OS, image.getOs()); assertEquals("Assuming the latest image to be selected", LATEST_DATE, image.getDate()); assertEquals("61851893-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);  }