@Test void testDeleteSdxWhenSdxHasAttachedDataHubsShouldThrowBadRequestBecauseSdxCanNotDeletedIfAttachedClustersAreAvailable() { SdxCluster sdxCluster = getSdxCluster(); when(sdxClusterRepository.findByAccountIdAndClusterNameAndDeletedIsNull(anyString(), anyString())).thenReturn(Optional.of(sdxCluster)); StackViewV4Response stackViewV4Response = new StackViewV4Response(); stackViewV4Response.setName("existingDistroXCluster"); mockCBCallForDistroXClusters(Sets.newHashSet(stackViewV4Response)); BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> underTest.deleteSdx(USER_CRN, "sdx-cluster-name", false)); assertEquals("The following Data Hub cluster(s) must be terminated before SDX deletion [existingDistroXCluster]", badRequestException.getMessage()); }
public FlowIdentifier deleteSdx(String userCrn, String name, boolean forced) { LOGGER.info("Deleting SDX {}", name); String accountIdFromCrn = getAccountIdFromCrn(userCrn); return sdxClusterRepository.findByAccountIdAndClusterNameAndDeletedIsNull(accountIdFromCrn, name) .map(sdxCluster -> deleteSdxCluster(sdxCluster, forced)) .orElseThrow(() -> notFound("SDX cluster", name).get()); }
SdxService implements ResourceIdProvider, ResourceBasedCrnProvider { public FlowIdentifier deleteSdx(String userCrn, String name, boolean forced) { LOGGER.info("Deleting SDX {}", name); String accountIdFromCrn = getAccountIdFromCrn(userCrn); return sdxClusterRepository.findByAccountIdAndClusterNameAndDeletedIsNull(accountIdFromCrn, name) .map(sdxCluster -> deleteSdxCluster(sdxCluster, forced)) .orElseThrow(() -> notFound("SDX cluster", name).get()); } }
SdxService implements ResourceIdProvider, ResourceBasedCrnProvider { public FlowIdentifier deleteSdx(String userCrn, String name, boolean forced) { LOGGER.info("Deleting SDX {}", name); String accountIdFromCrn = getAccountIdFromCrn(userCrn); return sdxClusterRepository.findByAccountIdAndClusterNameAndDeletedIsNull(accountIdFromCrn, name) .map(sdxCluster -> deleteSdxCluster(sdxCluster, forced)) .orElseThrow(() -> notFound("SDX cluster", name).get()); }  }
SdxService implements ResourceIdProvider, ResourceBasedCrnProvider { public FlowIdentifier deleteSdx(String userCrn, String name, boolean forced) { LOGGER.info("Deleting SDX {}", name); String accountIdFromCrn = getAccountIdFromCrn(userCrn); return sdxClusterRepository.findByAccountIdAndClusterNameAndDeletedIsNull(accountIdFromCrn, name) .map(sdxCluster -> deleteSdxCluster(sdxCluster, forced)) .orElseThrow(() -> notFound("SDX cluster", name).get()); }  String getStackCrnByClusterCrn(String crn); Set<Long> findByResourceIdsAndStatuses(Set<Long> resourceIds, Set<DatalakeStatusEnum> statuses); SdxCluster getById(Long id); StackV4Response getDetail(String name, Set<String> entries, String accountId); SdxCluster getByCrn(String userCrn, String clusterCrn); SdxCluster getByNameInAccount(String userCrn, String name); Pair<SdxCluster, FlowIdentifier> createSdx(final String userCrn, final String name, final SdxClusterRequest sdxClusterRequest,
            final StackV4Request internalStackV4Request); FlowIdentifier sync(String name, String accountId); void syncByCrn(String userCrn, String crn); @Override Long getResourceIdByResourceCrn(String resourceCrn); @Override Long getResourceIdByResourceName(String resourceName); List<SdxCluster> listSdxByEnvCrn(String userCrn, String envCrn); List<SdxCluster> listSdxByEnvCrn(String envCrn); List<SdxCluster> listSdx(String userCrn, String envName); FlowIdentifier deleteSdxByClusterCrn(String userCrn, String clusterCrn, boolean forced); FlowIdentifier deleteSdx(String userCrn, String name, boolean forced); void updateRuntimeVersionFromStackResponse(SdxCluster sdxCluster, StackV4Response stackV4Response); String getAccountIdFromCrn(String crnStr); @Override String getResourceCrnByResourceName(String resourceName); @Override List<String> getResourceCrnListByResourceNameList(List<String> resourceNames); @Override List<String> getResourceCrnsInAccount(); @Override Optional<String> getEnvironmentCrnByResourceCrn(String resourceCrn); @Override AuthorizationResourceType getResourceType(); SdxCluster save(SdxCluster sdxCluster); }
SdxService implements ResourceIdProvider, ResourceBasedCrnProvider { public FlowIdentifier deleteSdx(String userCrn, String name, boolean forced) { LOGGER.info("Deleting SDX {}", name); String accountIdFromCrn = getAccountIdFromCrn(userCrn); return sdxClusterRepository.findByAccountIdAndClusterNameAndDeletedIsNull(accountIdFromCrn, name) .map(sdxCluster -> deleteSdxCluster(sdxCluster, forced)) .orElseThrow(() -> notFound("SDX cluster", name).get()); }  String getStackCrnByClusterCrn(String crn); Set<Long> findByResourceIdsAndStatuses(Set<Long> resourceIds, Set<DatalakeStatusEnum> statuses); SdxCluster getById(Long id); StackV4Response getDetail(String name, Set<String> entries, String accountId); SdxCluster getByCrn(String userCrn, String clusterCrn); SdxCluster getByNameInAccount(String userCrn, String name); Pair<SdxCluster, FlowIdentifier> createSdx(final String userCrn, final String name, final SdxClusterRequest sdxClusterRequest,
            final StackV4Request internalStackV4Request); FlowIdentifier sync(String name, String accountId); void syncByCrn(String userCrn, String crn); @Override Long getResourceIdByResourceCrn(String resourceCrn); @Override Long getResourceIdByResourceName(String resourceName); List<SdxCluster> listSdxByEnvCrn(String userCrn, String envCrn); List<SdxCluster> listSdxByEnvCrn(String envCrn); List<SdxCluster> listSdx(String userCrn, String envName); FlowIdentifier deleteSdxByClusterCrn(String userCrn, String clusterCrn, boolean forced); FlowIdentifier deleteSdx(String userCrn, String name, boolean forced); void updateRuntimeVersionFromStackResponse(SdxCluster sdxCluster, StackV4Response stackV4Response); String getAccountIdFromCrn(String crnStr); @Override String getResourceCrnByResourceName(String resourceName); @Override List<String> getResourceCrnListByResourceNameList(List<String> resourceNames); @Override List<String> getResourceCrnsInAccount(); @Override Optional<String> getEnvironmentCrnByResourceCrn(String resourceCrn); @Override AuthorizationResourceType getResourceType(); SdxCluster save(SdxCluster sdxCluster);  }