@Test public void tesDetermineImageNameFound() { String imageName = underTest.determineImageName(DEFAULT_PLATFORM, DEFAULT_REGION, image); assertEquals("ami-09fea90f257c85513", imageName); }
public String determineImageName(String platformString, String region, Image imgFromCatalog) { Optional<Map<String, String>> imagesForPlatform = findStringKeyWithEqualsIgnoreCase(platformString, imgFromCatalog.getImageSetsByProvider()); if (imagesForPlatform.isPresent()) { Map<String, String> imagesByRegion = imagesForPlatform.get(); Optional<String> imageNameOpt = findStringKeyWithEqualsIgnoreCase(region, imagesByRegion); if (!imageNameOpt.isPresent()) { imageNameOpt = findStringKeyWithEqualsIgnoreCase(DEFAULT_REGION, imagesByRegion); } if (imageNameOpt.isPresent()) { return imageNameOpt.get(); } String msg = String.format("Virtual machine image couldn't be found in image: '%s' for the selected platform: '%s' and region: '%s'.", imgFromCatalog, platformString, region); throw new ImageNotFoundException(msg); } String msg = String.format("The selected image: '%s' doesn't contain virtual machine image for the selected platform: '%s'.", imgFromCatalog, platformString); throw new ImageNotFoundException(msg); }
ImageService { public String determineImageName(String platformString, String region, Image imgFromCatalog) { Optional<Map<String, String>> imagesForPlatform = findStringKeyWithEqualsIgnoreCase(platformString, imgFromCatalog.getImageSetsByProvider()); if (imagesForPlatform.isPresent()) { Map<String, String> imagesByRegion = imagesForPlatform.get(); Optional<String> imageNameOpt = findStringKeyWithEqualsIgnoreCase(region, imagesByRegion); if (!imageNameOpt.isPresent()) { imageNameOpt = findStringKeyWithEqualsIgnoreCase(DEFAULT_REGION, imagesByRegion); } if (imageNameOpt.isPresent()) { return imageNameOpt.get(); } String msg = String.format("Virtual machine image couldn't be found in image: '%s' for the selected platform: '%s' and region: '%s'.", imgFromCatalog, platformString, region); throw new ImageNotFoundException(msg); } String msg = String.format("The selected image: '%s' doesn't contain virtual machine image for the selected platform: '%s'.", imgFromCatalog, platformString); throw new ImageNotFoundException(msg); } }
ImageService { public String determineImageName(String platformString, String region, Image imgFromCatalog) { Optional<Map<String, String>> imagesForPlatform = findStringKeyWithEqualsIgnoreCase(platformString, imgFromCatalog.getImageSetsByProvider()); if (imagesForPlatform.isPresent()) { Map<String, String> imagesByRegion = imagesForPlatform.get(); Optional<String> imageNameOpt = findStringKeyWithEqualsIgnoreCase(region, imagesByRegion); if (!imageNameOpt.isPresent()) { imageNameOpt = findStringKeyWithEqualsIgnoreCase(DEFAULT_REGION, imagesByRegion); } if (imageNameOpt.isPresent()) { return imageNameOpt.get(); } String msg = String.format("Virtual machine image couldn't be found in image: '%s' for the selected platform: '%s' and region: '%s'.", imgFromCatalog, platformString, region); throw new ImageNotFoundException(msg); } String msg = String.format("The selected image: '%s' doesn't contain virtual machine image for the selected platform: '%s'.", imgFromCatalog, platformString); throw new ImageNotFoundException(msg); }  }
ImageService { public String determineImageName(String platformString, String region, Image imgFromCatalog) { Optional<Map<String, String>> imagesForPlatform = findStringKeyWithEqualsIgnoreCase(platformString, imgFromCatalog.getImageSetsByProvider()); if (imagesForPlatform.isPresent()) { Map<String, String> imagesByRegion = imagesForPlatform.get(); Optional<String> imageNameOpt = findStringKeyWithEqualsIgnoreCase(region, imagesByRegion); if (!imageNameOpt.isPresent()) { imageNameOpt = findStringKeyWithEqualsIgnoreCase(DEFAULT_REGION, imagesByRegion); } if (imageNameOpt.isPresent()) { return imageNameOpt.get(); } String msg = String.format("Virtual machine image couldn't be found in image: '%s' for the selected platform: '%s' and region: '%s'.", imgFromCatalog, platformString, region); throw new ImageNotFoundException(msg); } String msg = String.format("The selected image: '%s' doesn't contain virtual machine image for the selected platform: '%s'.", imgFromCatalog, platformString); throw new ImageNotFoundException(msg); }  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 String determineImageName(String platformString, String region, Image imgFromCatalog) { Optional<Map<String, String>> imagesForPlatform = findStringKeyWithEqualsIgnoreCase(platformString, imgFromCatalog.getImageSetsByProvider()); if (imagesForPlatform.isPresent()) { Map<String, String> imagesByRegion = imagesForPlatform.get(); Optional<String> imageNameOpt = findStringKeyWithEqualsIgnoreCase(region, imagesByRegion); if (!imageNameOpt.isPresent()) { imageNameOpt = findStringKeyWithEqualsIgnoreCase(DEFAULT_REGION, imagesByRegion); } if (imageNameOpt.isPresent()) { return imageNameOpt.get(); } String msg = String.format("Virtual machine image couldn't be found in image: '%s' for the selected platform: '%s' and region: '%s'.", imgFromCatalog, platformString, region); throw new ImageNotFoundException(msg); } String msg = String.format("The selected image: '%s' doesn't contain virtual machine image for the selected platform: '%s'.", imgFromCatalog, platformString); throw new ImageNotFoundException(msg); }  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);  }