@Test void testWhenDeleteClusterDefinitionsOnCloudbreakThrowsProcessingExceptionThenItShouldBeCatchedAndEnvironmentServiceExceptionShouldBeThrown() { doThrow(ProcessingException.class).when(clusterTemplateV4Endpoint).deleteMultiple(eq(WORKSPACE_ID), any(), any(), eq(ENVIRONMENT_CRN)); when(clusterTemplateViewV4Responses.getResponses()).thenReturn(Collections.emptySet()); when(clusterTemplateV4Endpoint.list(anyLong())).thenReturn(clusterTemplateViewV4Responses); Assertions.assertThrows(EnvironmentServiceException.class, () -> environmentResourceDeletionServiceUnderTest.deleteClusterDefinitionsOnCloudbreak(ENVIRONMENT_CRN)); verify(clusterTemplateV4Endpoint).deleteMultiple(anyLong(), any(), any(), anyString()); verify(clusterTemplateV4Endpoint).deleteMultiple(eq(WORKSPACE_ID), any(), any(), eq(ENVIRONMENT_CRN)); }
public void deleteClusterDefinitionsOnCloudbreak(String environmentCrn) { try { Set<String> names = getClusterDefinitionNamesInEnvironment(TEMP_WORKSPACE_ID, environmentCrn); clusterTemplateV4Endpoint.deleteMultiple(TEMP_WORKSPACE_ID, names, null, environmentCrn); } catch (WebApplicationException e) { propagateException("Failed to delete cluster definition(s) from Cloudbreak due to:", e); } catch (ProcessingException | UnableToDeleteClusterDefinitionException e) { propagateException("Failed to delete cluster definition(s) from Cloudbreak due to:", e); } }
EnvironmentResourceDeletionService { public void deleteClusterDefinitionsOnCloudbreak(String environmentCrn) { try { Set<String> names = getClusterDefinitionNamesInEnvironment(TEMP_WORKSPACE_ID, environmentCrn); clusterTemplateV4Endpoint.deleteMultiple(TEMP_WORKSPACE_ID, names, null, environmentCrn); } catch (WebApplicationException e) { propagateException("Failed to delete cluster definition(s) from Cloudbreak due to:", e); } catch (ProcessingException | UnableToDeleteClusterDefinitionException e) { propagateException("Failed to delete cluster definition(s) from Cloudbreak due to:", e); } } }
EnvironmentResourceDeletionService { public void deleteClusterDefinitionsOnCloudbreak(String environmentCrn) { try { Set<String> names = getClusterDefinitionNamesInEnvironment(TEMP_WORKSPACE_ID, environmentCrn); clusterTemplateV4Endpoint.deleteMultiple(TEMP_WORKSPACE_ID, names, null, environmentCrn); } catch (WebApplicationException e) { propagateException("Failed to delete cluster definition(s) from Cloudbreak due to:", e); } catch (ProcessingException | UnableToDeleteClusterDefinitionException e) { propagateException("Failed to delete cluster definition(s) from Cloudbreak due to:", e); } } EnvironmentResourceDeletionService(SdxEndpoint sdxEndpoint, DatalakeV4Endpoint datalakeV4Endpoint, DistroXV1Endpoint distroXV1Endpoint,
            ClusterTemplateV4Endpoint clusterTemplateV4Endpoint); }
EnvironmentResourceDeletionService { public void deleteClusterDefinitionsOnCloudbreak(String environmentCrn) { try { Set<String> names = getClusterDefinitionNamesInEnvironment(TEMP_WORKSPACE_ID, environmentCrn); clusterTemplateV4Endpoint.deleteMultiple(TEMP_WORKSPACE_ID, names, null, environmentCrn); } catch (WebApplicationException e) { propagateException("Failed to delete cluster definition(s) from Cloudbreak due to:", e); } catch (ProcessingException | UnableToDeleteClusterDefinitionException e) { propagateException("Failed to delete cluster definition(s) from Cloudbreak due to:", e); } } EnvironmentResourceDeletionService(SdxEndpoint sdxEndpoint, DatalakeV4Endpoint datalakeV4Endpoint, DistroXV1Endpoint distroXV1Endpoint,
            ClusterTemplateV4Endpoint clusterTemplateV4Endpoint); void deleteClusterDefinitionsOnCloudbreak(String environmentCrn); Set<String> getAttachedSdxClusterCrns(Environment environment); Set<String> getDatalakeClusterNames(Environment environment); }
EnvironmentResourceDeletionService { public void deleteClusterDefinitionsOnCloudbreak(String environmentCrn) { try { Set<String> names = getClusterDefinitionNamesInEnvironment(TEMP_WORKSPACE_ID, environmentCrn); clusterTemplateV4Endpoint.deleteMultiple(TEMP_WORKSPACE_ID, names, null, environmentCrn); } catch (WebApplicationException e) { propagateException("Failed to delete cluster definition(s) from Cloudbreak due to:", e); } catch (ProcessingException | UnableToDeleteClusterDefinitionException e) { propagateException("Failed to delete cluster definition(s) from Cloudbreak due to:", e); } } EnvironmentResourceDeletionService(SdxEndpoint sdxEndpoint, DatalakeV4Endpoint datalakeV4Endpoint, DistroXV1Endpoint distroXV1Endpoint,
            ClusterTemplateV4Endpoint clusterTemplateV4Endpoint); void deleteClusterDefinitionsOnCloudbreak(String environmentCrn); Set<String> getAttachedSdxClusterCrns(Environment environment); Set<String> getDatalakeClusterNames(Environment environment);  }