### Question:
EnvironmentDeletionService { public Environment delete(Environment environment, String userCrn, boolean cascading, boolean forced) { MDCBuilder.buildMdcContext(environment); validateDeletion(environment, cascading); LOGGER.debug("Deleting environment with name: {}", environment.getName()); environmentJobService.unschedule(environment); if (cascading) { reactorFlowManager.triggerCascadingDeleteFlow(environment, userCrn, forced); } else { checkIsEnvironmentDeletable(environment); reactorFlowManager.triggerDeleteFlow(environment, userCrn, forced); } return environment; } 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 delete() { assertEquals(environment, environmentDeletionService.delete(environment, TestConstants.USER, false, false)); verify(reactorFlowManager).triggerDeleteFlow(eq(environment), eq(TestConstants.USER), eq(false)); }
@Test public void deleteFailedDistroXesAreAttached() { when(environmentResourceDeletionService.getAttachedDistroXClusterNames(eq(environment))).thenReturn(Set.of("notempty")); assertThrows(BadRequestException.class, () -> environmentDeletionService.delete(environment, TestConstants.USER, false, false)); verify(reactorFlowManager, never()).triggerDeleteFlow(eq(environment), eq(TestConstants.USER), eq(false)); }
@Test public void deleteFailedDataLakesAreAttached() { when(environmentResourceDeletionService.getAttachedSdxClusterCrns(eq(environment))).thenReturn(Set.of("notempty")); assertThrows(BadRequestException.class, () -> environmentDeletionService.delete(environment, TestConstants.USER, false, false)); verify(reactorFlowManager, never()).triggerDeleteFlow(eq(environment), eq(TestConstants.USER), eq(false)); }
@Test public void canNotDeleteParentEnvironment() { when(environmentService.findNameWithAccountIdAndParentEnvIdAndArchivedIsFalse(environment.getAccountId(), environment.getId())) .thenReturn(singletonList("child name")); assertThrows(BadRequestException.class, () -> environmentDeletionService.delete(environment, TestConstants.USER, false, false)); }