@Test public void testTerminationFlowExists() { when(stackService.findAllByEnvironmentCrnAndAccountId(eq(ENVIRONMENT_CRN), eq(ACCOUNT_ID))).thenReturn(Collections.singletonList(stack)); when(applicationFlowInformation.getTerminationFlow()).thenReturn(List.of(StackTerminationFlowConfig.class)); FlowLog flowLog = new FlowLog(); flowLog.setFlowType(StackTerminationFlowConfig.class); flowLog.setCurrentState(StackTerminationState.INIT_STATE.name()); when(flowLogService.findAllByResourceIdAndFinalizedIsFalseOrderByCreatedDesc(stack.getId())).thenReturn(List.of(flowLog)); underTest.delete(ENVIRONMENT_CRN, ACCOUNT_ID, false); verify(flowManager, never()).notify(anyString(), any(Acceptable.class)); verify(flowCancelService, never()).cancelRunningFlows(stack.getId()); }
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);  }