@Test void deleteInvalid() { when(stackService.findAllByEnvironmentCrnAndAccountId(eq(ENVIRONMENT_CRN), eq(ACCOUNT_ID))).thenReturn(Collections.singletonList(stack)); when(childEnvironmentService.findChildEnvironments(stack, ACCOUNT_ID)).thenReturn(Collections.singletonList(new ChildEnvironment())); assertThrows(BadRequestException.class, () -> underTest.delete(ENVIRONMENT_CRN, ACCOUNT_ID, false)); verify(stackService, times(1)).findAllByEnvironmentCrnAndAccountId(eq(ENVIRONMENT_CRN), eq(ACCOUNT_ID)); verify(childEnvironmentService, times(1)).findChildEnvironments(stack, ACCOUNT_ID); }
public void delete(String environmentCrn, String accountId, boolean forced) { List<Stack> stacks = stackService.findAllByEnvironmentCrnAndAccountId(environmentCrn, accountId); if (stacks.isEmpty()) { throw new NotFoundException("No FreeIpa found in environment"); } stacks.forEach(stack -> validateDeletion(stack, accountId)); stacks.forEach(stack -> unscheduleAndTriggerTerminate(stack, forced)); }
FreeIpaDeletionService { public void delete(String environmentCrn, String accountId, boolean forced) { List<Stack> stacks = stackService.findAllByEnvironmentCrnAndAccountId(environmentCrn, accountId); if (stacks.isEmpty()) { throw new NotFoundException("No FreeIpa found in environment"); } stacks.forEach(stack -> validateDeletion(stack, accountId)); stacks.forEach(stack -> unscheduleAndTriggerTerminate(stack, forced)); } }
FreeIpaDeletionService { public void delete(String environmentCrn, String accountId, boolean forced) { List<Stack> stacks = stackService.findAllByEnvironmentCrnAndAccountId(environmentCrn, accountId); if (stacks.isEmpty()) { throw new NotFoundException("No FreeIpa found in environment"); } stacks.forEach(stack -> validateDeletion(stack, accountId)); stacks.forEach(stack -> unscheduleAndTriggerTerminate(stack, forced)); }  }
FreeIpaDeletionService { public void delete(String environmentCrn, String accountId, boolean forced) { List<Stack> stacks = stackService.findAllByEnvironmentCrnAndAccountId(environmentCrn, accountId); if (stacks.isEmpty()) { throw new NotFoundException("No FreeIpa found in environment"); } stacks.forEach(stack -> validateDeletion(stack, accountId)); stacks.forEach(stack -> unscheduleAndTriggerTerminate(stack, forced)); }  void delete(String environmentCrn, String accountId, boolean forced); }
FreeIpaDeletionService { public void delete(String environmentCrn, String accountId, boolean forced) { List<Stack> stacks = stackService.findAllByEnvironmentCrnAndAccountId(environmentCrn, accountId); if (stacks.isEmpty()) { throw new NotFoundException("No FreeIpa found in environment"); } stacks.forEach(stack -> validateDeletion(stack, accountId)); stacks.forEach(stack -> unscheduleAndTriggerTerminate(stack, forced)); }  void delete(String environmentCrn, String accountId, boolean forced);  }