### Question:
HooksExecutor { public List<Hook> executeBeforeStepHooks(StepPhase currentStepPhase) { if (!hooksCalculator.isInPreExecuteStepPhase(currentStepPhase)) { return Collections.emptyList(); } return executeHooks(currentStepPhase); } HooksExecutor(HooksCalculator hooksCalculator, Module moduleToDeploy); List<Hook> executeBeforeStepHooks(StepPhase currentStepPhase); List<Hook> executeAfterStepHooks(StepPhase currentStepPhase);  }### Answer:
@Test void executeBeforeStepHooksWhenPhaseIsNotBefore() { Module moduleToDeploy = createModule("test-module"); HooksExecutor hooksExecutor = new HooksExecutor(hooksCalculator, moduleToDeploy); List<Hook> hooksForExecution = hooksExecutor.executeBeforeStepHooks(StepPhase.DONE); Assertions.assertTrue(hooksForExecution.isEmpty()); }
@Test void executeBeforeStepHooks() { Module moduleToDeploy = createModule("test-module"); Mockito.when(hooksCalculator.isInPreExecuteStepPhase(StepPhase.EXECUTE)) .thenReturn(true); Mockito.when(processTypeParser.getProcessType(any())) .thenReturn(ProcessType.BLUE_GREEN_DEPLOY); List<Hook> expectedHooksForExecution = List.of(createHook("test-hook", Collections.emptyList())); Mockito.when(hooksCalculator.calculateHooksForExecution(moduleToDeploy, StepPhase.EXECUTE)) .thenReturn(expectedHooksForExecution); HooksExecutor hooksExecutor = new HooksExecutor(hooksCalculator, moduleToDeploy); List<Hook> hooksForExecution = hooksExecutor.executeBeforeStepHooks(StepPhase.EXECUTE); Assertions.assertEquals(expectedHooksForExecution, hooksForExecution); }
@Test void executeBeforeStepHooksWhenModuleToDeployIsNull() { Mockito.when(processTypeParser.getProcessType(any())) .thenReturn(ProcessType.DEPLOY); HooksExecutor hooksExecutor = new HooksExecutor(hooksCalculator, null); Mockito.when(hooksCalculator.isInPreExecuteStepPhase(StepPhase.EXECUTE)) .thenReturn(true); List<Hook> hooksForExecution = hooksExecutor.executeBeforeStepHooks(StepPhase.EXECUTE); Assertions.assertTrue(hooksForExecution.isEmpty()); }