@Test public void testDeletionWithTerminatedClustersNonTerminatedStacks() { Set<Cluster> clusters = new HashSet<>(); clusters.add(getCluster("c1", 1L, blueprint, PRE_DELETE_IN_PROGRESS, AVAILABLE)); clusters.add(getCluster("c2", 1L, blueprint, DELETE_COMPLETED, DELETE_IN_PROGRESS)); clusters.add(getCluster("c3", 1L, blueprint, DELETE_COMPLETED, DELETE_COMPLETED)); when(clusterService.findByBlueprint(any())).thenReturn(clusters); exceptionRule.expect(BadRequestException.class); exceptionRule.expectMessage("c1"); underTest.delete(blueprint); }
@Override public Blueprint delete(Blueprint blueprint) { LOGGER.debug("Deleting blueprint with name: {}", blueprint.getName()); prepareDeletion(blueprint); if (USER_MANAGED.equals(blueprint.getStatus())) { blueprintRepository.delete(blueprint); } else { LOGGER.error("Tried to delete DEFAULT blueprint"); throw new BadRequestException("deletion of DEFAULT blueprint is not allowed"); } return blueprint; }
BlueprintService extends AbstractWorkspaceAwareResourceService<Blueprint> implements ResourceBasedCrnProvider { @Override public Blueprint delete(Blueprint blueprint) { LOGGER.debug("Deleting blueprint with name: {}", blueprint.getName()); prepareDeletion(blueprint); if (USER_MANAGED.equals(blueprint.getStatus())) { blueprintRepository.delete(blueprint); } else { LOGGER.error("Tried to delete DEFAULT blueprint"); throw new BadRequestException("deletion of DEFAULT blueprint is not allowed"); } return blueprint; } }
BlueprintService extends AbstractWorkspaceAwareResourceService<Blueprint> implements ResourceBasedCrnProvider { @Override public Blueprint delete(Blueprint blueprint) { LOGGER.debug("Deleting blueprint with name: {}", blueprint.getName()); prepareDeletion(blueprint); if (USER_MANAGED.equals(blueprint.getStatus())) { blueprintRepository.delete(blueprint); } else { LOGGER.error("Tried to delete DEFAULT blueprint"); throw new BadRequestException("deletion of DEFAULT blueprint is not allowed"); } return blueprint; }  }
BlueprintService extends AbstractWorkspaceAwareResourceService<Blueprint> implements ResourceBasedCrnProvider { @Override public Blueprint delete(Blueprint blueprint) { LOGGER.debug("Deleting blueprint with name: {}", blueprint.getName()); prepareDeletion(blueprint); if (USER_MANAGED.equals(blueprint.getStatus())) { blueprintRepository.delete(blueprint); } else { LOGGER.error("Tried to delete DEFAULT blueprint"); throw new BadRequestException("deletion of DEFAULT blueprint is not allowed"); } return blueprint; }  Blueprint get(Long id); Blueprint createForLoggedInUser(Blueprint blueprint, Long workspaceId, String accountId, String creator); Blueprint deleteByWorkspace(NameOrCrn nameOrCrn, Long workspaceId); Blueprint getByWorkspace(@NotNull NameOrCrn nameOrCrn, Long workspaceId); void decorateWithCrn(Blueprint bp, String accountId, String creator); PlatformRecommendation getRecommendation(Long workspaceId, String blueprintName, String credentialName,
            String region, String platformVariant, String availabilityZone, CdpResourceType cdpResourceType); PlatformRecommendation getRecommendationByCredentialCrn(Long workspaceId, String blueprintName, String credentialCrn,
            String region, String platformVariant, String availabilityZone, CdpResourceType cdpResourceType); AutoscaleRecommendation getAutoscaleRecommendation(Long workspaceId, String blueprintName); ScaleRecommendation getScaleRecommendation(Long workspaceId, String blueprintName); @Override Set<Blueprint> findAllByWorkspace(Workspace workspace); @Override Set<Blueprint> findAllByWorkspaceId(Long workspaceId); Set<BlueprintView> getAllAvailableViewInWorkspaceAndFilterBySdxReady(Long workspaceId, Boolean withSdx); Set<Blueprint> getAllAvailableInWorkspace(Workspace workspace); Blueprint getByNameForWorkspaceAndLoadDefaultsIfNecessary(String name, Workspace workspace); void updateDefaultBlueprintCollection(Long workspaceId); boolean isDatalakeBlueprint(Blueprint blueprint); boolean isClouderaManagerTemplate(Blueprint blueprint); String getBlueprintVariant(Blueprint blueprint); @Override Blueprint getByNameForWorkspace(String name, Workspace workspace); @Override Blueprint delete(Blueprint blueprint); @Override WorkspaceResourceRepository<Blueprint, Long> repository(); Map<String, String> queryCustomParametersMap(String name, Long workspaceId); Set<ConfigQueryEntry> queryFileSystemParameters(String blueprintName, String clusterName,
            String baseLocation, String fileSystemType, String accountName, boolean attachedCluster,
            boolean secure, Long workspaceId); @Override String getResourceCrnByResourceName(String resourceName); @Override List<String> getResourceCrnsInAccount(); @Override List<String> getResourceCrnListByResourceNameList(List<String> resourceNames); Blueprint getByResourceCrn(String resourceCrn); @Override AuthorizationResourceType getResourceType(); BlueprintStatusView getStatusViewByResourceCrn(String resourceCrn); }
BlueprintService extends AbstractWorkspaceAwareResourceService<Blueprint> implements ResourceBasedCrnProvider { @Override public Blueprint delete(Blueprint blueprint) { LOGGER.debug("Deleting blueprint with name: {}", blueprint.getName()); prepareDeletion(blueprint); if (USER_MANAGED.equals(blueprint.getStatus())) { blueprintRepository.delete(blueprint); } else { LOGGER.error("Tried to delete DEFAULT blueprint"); throw new BadRequestException("deletion of DEFAULT blueprint is not allowed"); } return blueprint; }  Blueprint get(Long id); Blueprint createForLoggedInUser(Blueprint blueprint, Long workspaceId, String accountId, String creator); Blueprint deleteByWorkspace(NameOrCrn nameOrCrn, Long workspaceId); Blueprint getByWorkspace(@NotNull NameOrCrn nameOrCrn, Long workspaceId); void decorateWithCrn(Blueprint bp, String accountId, String creator); PlatformRecommendation getRecommendation(Long workspaceId, String blueprintName, String credentialName,
            String region, String platformVariant, String availabilityZone, CdpResourceType cdpResourceType); PlatformRecommendation getRecommendationByCredentialCrn(Long workspaceId, String blueprintName, String credentialCrn,
            String region, String platformVariant, String availabilityZone, CdpResourceType cdpResourceType); AutoscaleRecommendation getAutoscaleRecommendation(Long workspaceId, String blueprintName); ScaleRecommendation getScaleRecommendation(Long workspaceId, String blueprintName); @Override Set<Blueprint> findAllByWorkspace(Workspace workspace); @Override Set<Blueprint> findAllByWorkspaceId(Long workspaceId); Set<BlueprintView> getAllAvailableViewInWorkspaceAndFilterBySdxReady(Long workspaceId, Boolean withSdx); Set<Blueprint> getAllAvailableInWorkspace(Workspace workspace); Blueprint getByNameForWorkspaceAndLoadDefaultsIfNecessary(String name, Workspace workspace); void updateDefaultBlueprintCollection(Long workspaceId); boolean isDatalakeBlueprint(Blueprint blueprint); boolean isClouderaManagerTemplate(Blueprint blueprint); String getBlueprintVariant(Blueprint blueprint); @Override Blueprint getByNameForWorkspace(String name, Workspace workspace); @Override Blueprint delete(Blueprint blueprint); @Override WorkspaceResourceRepository<Blueprint, Long> repository(); Map<String, String> queryCustomParametersMap(String name, Long workspaceId); Set<ConfigQueryEntry> queryFileSystemParameters(String blueprintName, String clusterName,
            String baseLocation, String fileSystemType, String accountName, boolean attachedCluster,
            boolean secure, Long workspaceId); @Override String getResourceCrnByResourceName(String resourceName); @Override List<String> getResourceCrnsInAccount(); @Override List<String> getResourceCrnListByResourceNameList(List<String> resourceNames); Blueprint getByResourceCrn(String resourceCrn); @Override AuthorizationResourceType getResourceType(); BlueprintStatusView getStatusViewByResourceCrn(String resourceCrn);  }