### Question:
EnvironmentDeletionService { @VisibleForTesting void checkIsEnvironmentDeletable(Environment env) { LOGGER.info("Checking if environment [name: {}] is deletable", env.getName()); Set<String> datalakes = environmentResourceDeletionService.getAttachedSdxClusterCrns(env); if (datalakes.isEmpty()) { datalakes = environmentResourceDeletionService.getDatalakeClusterNames(env); } if (!datalakes.isEmpty()) { throw new BadRequestException(String.format("The following Data Lake cluster(s) must be terminated before Environment deletion [%s]", String.join(", ", datalakes))); } Set<String> distroXClusterNames = environmentResourceDeletionService.getAttachedDistroXClusterNames(env); if (!distroXClusterNames.isEmpty()) { throw new BadRequestException(String.format("The following Data Hub cluster(s) must be terminated before Environment deletion [%s]", String.join(", ", distroXClusterNames))); } } EnvironmentDeletionService(EnvironmentService environmentService, EnvironmentDtoConverter environmentDtoConverter,
            EnvironmentReactorFlowManager reactorFlowManager, EnvironmentResourceDeletionService environmentResourceDeletionService,
            EnvironmentJobService environmentJobService); EnvironmentDto deleteByNameAndAccountId(String environmentName, String accountId, String actualUserCrn,
        boolean cascading, boolean forced); EnvironmentDto deleteByCrnAndAccountId(String crn, String accountId, String actualUserCrn,
        boolean cascading, boolean forced); Environment delete(Environment environment, String userCrn,
        boolean cascading, boolean forced); List<EnvironmentDto> deleteMultipleByNames(Set<String> environmentNames, String accountId, String actualUserCrn,
        boolean cascading, boolean forced); List<EnvironmentDto> deleteMultipleByCrns(Set<String> crns, String accountId, String actualUserCrn,
        boolean cascading, boolean forced);  }### Answer:
@Test public void testCheckIsEnvironmentDeletableWhenSdxAndDatalakeAreEmpty() { when(environmentResourceDeletionService.getAttachedSdxClusterCrns(environment)).thenReturn(emptySet()); when(environmentResourceDeletionService.getDatalakeClusterNames(environment)).thenReturn(emptySet()); environmentDeletionService.checkIsEnvironmentDeletable(environment); verify(environmentResourceDeletionService).getAttachedDistroXClusterNames(environment); }
@Test public void testCheckIsEnvironmentDeletableWhenSdxIsEmptyButDatalakeIsNot() { when(environmentResourceDeletionService.getAttachedSdxClusterCrns(environment)).thenReturn(emptySet()); when(environmentResourceDeletionService.getDatalakeClusterNames(environment)).thenReturn(Set.of("name")); BadRequestException actual = assertThrows(BadRequestException.class, () -> environmentDeletionService.checkIsEnvironmentDeletable(environment)); assertEquals("The following Data Lake cluster(s) must be terminated before Environment deletion [name]", actual.getMessage()); }