@Test public void testGetImageGivenIdInputNotFound() { ImageSettingsRequest is = setupImageSettingsRequest(NON_EXISTING_ID, null, null); Exception exception = assertThrows(RuntimeException.class, () -> underTest.getImage(is, DEFAULT_REGION, DEFAULT_PLATFORM)); String exceptionMessage = "Could not find any image with id: 'fake-ami-0a6931aea1415eb0e' in region 'eu-west-1' with OS 'redhat7'."; assertEquals(exceptionMessage, exception.getMessage()); }
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);  }