### Question:
ReplayGeneratorByStepAndActionConfiguration implements JavascriptGenerator<StepAndActionConfiguration> { @Override public String generate(StepAndActionConfiguration generationInformation) { StringBuilder stringBuilder = new StringBuilder(); Map<String, String> testCaseStep = generationInformation.getTestCaseStep(); ApplicationActionConfiguration applicationActionConfiguration = generationInformation.getApplicationActionConfiguration(); int index = generationInformation.getIndex(); StepAndWebDriverActionConfiguration precondition = supplier.get(testCaseStep, index, applicationActionConfiguration.getConditionBeforeExecution()); stringBuilder.append(generator.generate(precondition)); stringBuilder.append(System.lineSeparator()); StepAndWebDriverActionConfiguration action = supplier.get(testCaseStep, index, applicationActionConfiguration.getWebDriverAction()); stringBuilder.append(generator.generate(action)); stringBuilder.append(System.lineSeparator()); StepAndWebDriverActionConfiguration postcondition = supplier.get(testCaseStep, index, applicationActionConfiguration.getConditionAfterExecution()); stringBuilder.append(generator.generate(postcondition)); stringBuilder.append(System.lineSeparator()); return stringBuilder.toString(); } @Inject  ReplayGeneratorByStepAndActionConfiguration(JavascriptGenerator<StepAndWebDriverActionConfiguration> generator,
                                                       StepAndWebDriverActionConfigurationSupplier supplier); @Override String generate(StepAndActionConfiguration generationInformation);  }### Answer:
@Test public void generatesCorrectly() { JavascriptGenerator<StepAndWebDriverActionConfiguration> generator = mock(JavascriptGenerator.class); StepAndWebDriverActionConfigurationSupplier supplier = mock(StepAndWebDriverActionConfigurationSupplier.class); Map<String, String> testCaseStep = new HashMap<>(); WebDriverActionConfiguration precondition = mock(WebDriverActionConfiguration.class); WebDriverActionConfiguration action = mock(WebDriverActionConfiguration.class); WebDriverActionConfiguration postcondition = mock(WebDriverActionConfiguration.class); ApplicationActionConfiguration applicationActionConfiguration = mock(ApplicationActionConfiguration.class); when(applicationActionConfiguration.getConditionBeforeExecution()).thenReturn(precondition); when(applicationActionConfiguration.getWebDriverAction()).thenReturn(action); when(applicationActionConfiguration.getConditionAfterExecution()).thenReturn(postcondition); StepAndActionConfiguration stepAndActionConfiguration = mock(StepAndActionConfiguration.class); when(stepAndActionConfiguration.getTestCaseStep()).thenReturn(testCaseStep); when(stepAndActionConfiguration.getApplicationActionConfiguration()).thenReturn(applicationActionConfiguration); StepAndWebDriverActionConfiguration stepAndPrecondition = mock(StepAndWebDriverActionConfiguration.class); StepAndWebDriverActionConfiguration stepAndAction = mock(StepAndWebDriverActionConfiguration.class); StepAndWebDriverActionConfiguration stepAndPostcondition = mock(StepAndWebDriverActionConfiguration.class); when(supplier.get(eq(testCaseStep), anyInt(), eq(precondition))).thenReturn(stepAndPrecondition); when(supplier.get(eq(testCaseStep), anyInt(), eq(action))).thenReturn(stepAndAction); when(supplier.get(eq(testCaseStep), anyInt(), eq(postcondition))).thenReturn(stepAndPostcondition); String s1 = "s1", s2 = "s2", s3 = "s3", expected = s1 + System.lineSeparator() + s2 + System.lineSeparator() + s3 + System.lineSeparator(); when(generator.generate(stepAndPrecondition)).thenReturn(s1); when(generator.generate(stepAndAction)).thenReturn(s2); when(generator.generate(stepAndPostcondition)).thenReturn(s3); ReplayGeneratorByStepAndActionConfiguration replayGeneratorByStepAndActionConfiguration = new ReplayGeneratorByStepAndActionConfiguration(generator, supplier); String actual = replayGeneratorByStepAndActionConfiguration.generate(stepAndActionConfiguration); assertEquals(expected, actual); }