@Test public void testGetImagesFromDefaultWithStackName() throws CloudbreakImageCatalogException { when(stackImageFilterService.getApplicableImages(anyLong(), anyString())).thenReturn(new Images(Lists.newArrayList(), Lists.newArrayList(), Sets.newHashSet())); underTest.getImagesFromDefault(ORG_ID, "stack", null, Collections.emptySet()); verify(stackImageFilterService, never()).getApplicableImages(anyLong(), anyString(), anyString()); verify(stackImageFilterService, times(1)).getApplicableImages(anyLong(), anyString()); }
public Images getImagesFromDefault(Long workspaceId, String stackName, String platform, Set<String> operatingSystems) throws CloudbreakImageCatalogException { if (isNotEmpty(platform) && isNotEmpty(stackName)) { throw new BadRequestException("Platform or stackName cannot be filled in the same request."); } if (isNotEmpty(platform)) { User user = getLoggedInUser(); ImageFilter imageFilter = new ImageFilter(getDefaultImageCatalog(user), Set.of(platform), null, baseImageEnabled(), operatingSystems, null); return getStatedImagesFilteredByOperatingSystems(imageFilter, image -> true).getImages(); } else if (isNotEmpty(stackName)) { return stackImageFilterService.getApplicableImages(workspaceId, stackName); } else { throw new BadRequestException("Either platform or stackName should be filled in request."); } }
ImageCatalogService extends AbstractWorkspaceAwareResourceService<ImageCatalog> implements ResourceBasedCrnProvider { public Images getImagesFromDefault(Long workspaceId, String stackName, String platform, Set<String> operatingSystems) throws CloudbreakImageCatalogException { if (isNotEmpty(platform) && isNotEmpty(stackName)) { throw new BadRequestException("Platform or stackName cannot be filled in the same request."); } if (isNotEmpty(platform)) { User user = getLoggedInUser(); ImageFilter imageFilter = new ImageFilter(getDefaultImageCatalog(user), Set.of(platform), null, baseImageEnabled(), operatingSystems, null); return getStatedImagesFilteredByOperatingSystems(imageFilter, image -> true).getImages(); } else if (isNotEmpty(stackName)) { return stackImageFilterService.getApplicableImages(workspaceId, stackName); } else { throw new BadRequestException("Either platform or stackName should be filled in request."); } } }
ImageCatalogService extends AbstractWorkspaceAwareResourceService<ImageCatalog> implements ResourceBasedCrnProvider { public Images getImagesFromDefault(Long workspaceId, String stackName, String platform, Set<String> operatingSystems) throws CloudbreakImageCatalogException { if (isNotEmpty(platform) && isNotEmpty(stackName)) { throw new BadRequestException("Platform or stackName cannot be filled in the same request."); } if (isNotEmpty(platform)) { User user = getLoggedInUser(); ImageFilter imageFilter = new ImageFilter(getDefaultImageCatalog(user), Set.of(platform), null, baseImageEnabled(), operatingSystems, null); return getStatedImagesFilteredByOperatingSystems(imageFilter, image -> true).getImages(); } else if (isNotEmpty(stackName)) { return stackImageFilterService.getApplicableImages(workspaceId, stackName); } else { throw new BadRequestException("Either platform or stackName should be filled in request."); } }  }
ImageCatalogService extends AbstractWorkspaceAwareResourceService<ImageCatalog> implements ResourceBasedCrnProvider { public Images getImagesFromDefault(Long workspaceId, String stackName, String platform, Set<String> operatingSystems) throws CloudbreakImageCatalogException { if (isNotEmpty(platform) && isNotEmpty(stackName)) { throw new BadRequestException("Platform or stackName cannot be filled in the same request."); } if (isNotEmpty(platform)) { User user = getLoggedInUser(); ImageFilter imageFilter = new ImageFilter(getDefaultImageCatalog(user), Set.of(platform), null, baseImageEnabled(), operatingSystems, null); return getStatedImagesFilteredByOperatingSystems(imageFilter, image -> true).getImages(); } else if (isNotEmpty(stackName)) { return stackImageFilterService.getApplicableImages(workspaceId, stackName); } else { throw new BadRequestException("Either platform or stackName should be filled in request."); } }  @Override Set<ImageCatalog> findAllByWorkspaceId(Long workspaceId); ImageCatalog delete(NameOrCrn imageCatalogNameOrCrn, Long workspaceId); @Override Set<ImageCatalog> findAllByWorkspace(Workspace workspace); ImageCatalog createForLoggedInUser(ImageCatalog imageCatalog, Long workspaceId, String accountId, String creator); ImageCatalog get(NameOrCrn imageCatalogNameOrCrn, Long workspaceId); ImageCatalog findByResourceCrn(String resourceCrn); Images getImagesByCatalogName(Long workspaceId, String catalogName, String stackName, String platform); Images getImagesFromDefault(Long workspaceId, String stackName, String platform, Set<String> operatingSystems); StatedImages getStatedImagesFilteredByOperatingSystems(ImageFilter imageFilter, Predicate<Image> imageFilterPredicate); StatedImage getLatestBaseImageDefaultPreferred(ImageFilter imageFilter, Predicate<Image> imageFilterPredicate); StatedImage getImagePrewarmedDefaultPreferred(ImageFilter imageFilter, Predicate<Image> imageFilterPredicate); StatedImages getImages(Long workspaceId, String name, String provider); StatedImages getImages(Long workspaceId, String name, Set<String> providers); StatedImage getImage(String imageId); StatedImage getImage(String catalogUrl, String catalogName, String imageId); StatedImage getImageByCatalogName(Long workspaceId, String imageId, String catalogName); ImageCatalog delete(Long workspaceId, String name); Set<ImageCatalog> deleteMultiple(Long workspaceId, Set<String> names); ImageCatalog get(Long workspaceId, String name); boolean isEnvDefault(String name); ImageCatalog update(Long workspaceId, ImageCatalog source); StatedImages getImages(ImageFilter imageFilter); Images propagateImagesIfRequested(Long workspaceId, String name, Boolean withImages); boolean baseImageEnabled(); @Nonnull ImageCatalog getDefaultImageCatalog(User user); String getDefaultImageCatalogName(User user); String getImageDefaultCatalogUrl(User user); @Override WorkspaceResourceRepository<ImageCatalog, Long> repository(); @Override String getResourceCrnByResourceName(String resourceName); @Override List<String> getResourceCrnListByResourceNameList(List<String> resourceNames); @Override List<String> getResourceCrnsInAccount(); List<ImageCatalog> getDefaultImageCatalogs(); @Override AuthorizationResourceType getResourceType(); }
ImageCatalogService extends AbstractWorkspaceAwareResourceService<ImageCatalog> implements ResourceBasedCrnProvider { public Images getImagesFromDefault(Long workspaceId, String stackName, String platform, Set<String> operatingSystems) throws CloudbreakImageCatalogException { if (isNotEmpty(platform) && isNotEmpty(stackName)) { throw new BadRequestException("Platform or stackName cannot be filled in the same request."); } if (isNotEmpty(platform)) { User user = getLoggedInUser(); ImageFilter imageFilter = new ImageFilter(getDefaultImageCatalog(user), Set.of(platform), null, baseImageEnabled(), operatingSystems, null); return getStatedImagesFilteredByOperatingSystems(imageFilter, image -> true).getImages(); } else if (isNotEmpty(stackName)) { return stackImageFilterService.getApplicableImages(workspaceId, stackName); } else { throw new BadRequestException("Either platform or stackName should be filled in request."); } }  @Override Set<ImageCatalog> findAllByWorkspaceId(Long workspaceId); ImageCatalog delete(NameOrCrn imageCatalogNameOrCrn, Long workspaceId); @Override Set<ImageCatalog> findAllByWorkspace(Workspace workspace); ImageCatalog createForLoggedInUser(ImageCatalog imageCatalog, Long workspaceId, String accountId, String creator); ImageCatalog get(NameOrCrn imageCatalogNameOrCrn, Long workspaceId); ImageCatalog findByResourceCrn(String resourceCrn); Images getImagesByCatalogName(Long workspaceId, String catalogName, String stackName, String platform); Images getImagesFromDefault(Long workspaceId, String stackName, String platform, Set<String> operatingSystems); StatedImages getStatedImagesFilteredByOperatingSystems(ImageFilter imageFilter, Predicate<Image> imageFilterPredicate); StatedImage getLatestBaseImageDefaultPreferred(ImageFilter imageFilter, Predicate<Image> imageFilterPredicate); StatedImage getImagePrewarmedDefaultPreferred(ImageFilter imageFilter, Predicate<Image> imageFilterPredicate); StatedImages getImages(Long workspaceId, String name, String provider); StatedImages getImages(Long workspaceId, String name, Set<String> providers); StatedImage getImage(String imageId); StatedImage getImage(String catalogUrl, String catalogName, String imageId); StatedImage getImageByCatalogName(Long workspaceId, String imageId, String catalogName); ImageCatalog delete(Long workspaceId, String name); Set<ImageCatalog> deleteMultiple(Long workspaceId, Set<String> names); ImageCatalog get(Long workspaceId, String name); boolean isEnvDefault(String name); ImageCatalog update(Long workspaceId, ImageCatalog source); StatedImages getImages(ImageFilter imageFilter); Images propagateImagesIfRequested(Long workspaceId, String name, Boolean withImages); boolean baseImageEnabled(); @Nonnull ImageCatalog getDefaultImageCatalog(User user); String getDefaultImageCatalogName(User user); String getImageDefaultCatalogUrl(User user); @Override WorkspaceResourceRepository<ImageCatalog, Long> repository(); @Override String getResourceCrnByResourceName(String resourceName); @Override List<String> getResourceCrnListByResourceNameList(List<String> resourceNames); @Override List<String> getResourceCrnsInAccount(); List<ImageCatalog> getDefaultImageCatalogs(); @Override AuthorizationResourceType getResourceType(); static final String UNDEFINED; static final String CDP_DEFAULT_CATALOG_NAME; }