@Test void testAggregateHooksIfTheHookForExecutionIsAlreadyExecuted() { List<Hook> hooksForModule = List.of(createHook("hook1", List.of("blue-green.application.before-stop.live")), createHook("hook2", List.of("blue-green.application.after-stop.live"))); Module moduleToDeploy = createModule("test-module", hooksForModule); List<HookPhase> currentHookPhasesForExecutions = List.of(HookPhase.BEFORE_STOP); prepareExecutedHooks("test-module", Map.of("hook1", List.of("blue-green.application.before-stop.live"))); Mockito.when(processTypeParser.getProcessType(context.getExecution())) .thenReturn(ProcessType.BLUE_GREEN_DEPLOY); ModuleHooksAggregator moduleHooksAggregator = createModuleHooksAggregator(moduleToDeploy); List<Hook> aggregatedHooks = moduleHooksAggregator.aggregateHooks(currentHookPhasesForExecutions); Assertions.assertTrue(aggregatedHooks.isEmpty()); }
public List<Hook> aggregateHooks(List<HookPhase> currentHookPhasesForExecution) { Map<String, List<String>> alreadyExecutedHooksForModule = getAlreadyExecutedHooks(); List<Hook> hooksCalculatedForExecution = determineHooksForExecution(alreadyExecutedHooksForModule, currentHookPhasesForExecution); updateExecutedHooksForModule(alreadyExecutedHooksForModule, currentHookPhasesForExecution, hooksCalculatedForExecution); return hooksCalculatedForExecution; }
ModuleHooksAggregator { public List<Hook> aggregateHooks(List<HookPhase> currentHookPhasesForExecution) { Map<String, List<String>> alreadyExecutedHooksForModule = getAlreadyExecutedHooks(); List<Hook> hooksCalculatedForExecution = determineHooksForExecution(alreadyExecutedHooksForModule, currentHookPhasesForExecution); updateExecutedHooksForModule(alreadyExecutedHooksForModule, currentHookPhasesForExecution, hooksCalculatedForExecution); return hooksCalculatedForExecution; } }
ModuleHooksAggregator { public List<Hook> aggregateHooks(List<HookPhase> currentHookPhasesForExecution) { Map<String, List<String>> alreadyExecutedHooksForModule = getAlreadyExecutedHooks(); List<Hook> hooksCalculatedForExecution = determineHooksForExecution(alreadyExecutedHooksForModule, currentHookPhasesForExecution); updateExecutedHooksForModule(alreadyExecutedHooksForModule, currentHookPhasesForExecution, hooksCalculatedForExecution); return hooksCalculatedForExecution; } ModuleHooksAggregator(DelegateExecution execution, Module moduleToDeploy); }
ModuleHooksAggregator { public List<Hook> aggregateHooks(List<HookPhase> currentHookPhasesForExecution) { Map<String, List<String>> alreadyExecutedHooksForModule = getAlreadyExecutedHooks(); List<Hook> hooksCalculatedForExecution = determineHooksForExecution(alreadyExecutedHooksForModule, currentHookPhasesForExecution); updateExecutedHooksForModule(alreadyExecutedHooksForModule, currentHookPhasesForExecution, hooksCalculatedForExecution); return hooksCalculatedForExecution; } ModuleHooksAggregator(DelegateExecution execution, Module moduleToDeploy); List<Hook> aggregateHooks(List<HookPhase> currentHookPhasesForExecution); }
ModuleHooksAggregator { public List<Hook> aggregateHooks(List<HookPhase> currentHookPhasesForExecution) { Map<String, List<String>> alreadyExecutedHooksForModule = getAlreadyExecutedHooks(); List<Hook> hooksCalculatedForExecution = determineHooksForExecution(alreadyExecutedHooksForModule, currentHookPhasesForExecution); updateExecutedHooksForModule(alreadyExecutedHooksForModule, currentHookPhasesForExecution, hooksCalculatedForExecution); return hooksCalculatedForExecution; } ModuleHooksAggregator(DelegateExecution execution, Module moduleToDeploy); List<Hook> aggregateHooks(List<HookPhase> currentHookPhasesForExecution);  }