@Test void testAggregateHooksIfThereAreSomeExecutedPhases() { Hook hookForExecution = createHook("hook1", List.of("blue-green.application.before-start.live")); List<Hook> hooksForModule = List.of(hookForExecution, createHook("hook2", List.of("blue-green.application.before-start.idle"))); Module moduleToDeploy = createModule("test-module", hooksForModule); List<HookPhase> currentHookPhasesForExecutions = List.of(HookPhase.BLUE_GREEN_APPLICATION_BEFORE_START_LIVE); prepareExecutedHooks("test-module", Map.of("hook1", List.of("blue-green.application.before-start.idle"))); Mockito.when(processTypeParser.getProcessType(context.getExecution())) .thenReturn(ProcessType.BLUE_GREEN_DEPLOY); context.setVariable(Variables.SUBPROCESS_PHASE, SubprocessPhase.BEFORE_APPLICATION_START); context.setVariable(Variables.PHASE, Phase.AFTER_RESUME); ModuleHooksAggregator moduleHooksAggregator = createModuleHooksAggregator(moduleToDeploy); List<Hook> aggregatedHooks = moduleHooksAggregator.aggregateHooks(currentHookPhasesForExecutions); Assertions.assertEquals(List.of(hookForExecution), aggregatedHooks); }
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);  }