### Question:
RecordingJavascriptGenerator implements JavascriptGenerator<ApplicationConfiguration> { @Override public String generate(ApplicationConfiguration applicationConfiguration) { long start = System.currentTimeMillis(); String generated = baseTemplate + System.lineSeparator() + contextBuildersGenerator.generate(applicationConfiguration) + System.lineSeparator() + applicationConfiguration .getApplicationActionConfigurationList() .stream() .map(applicationActionConfiguration -> applicationActionGenerator.generate(applicationActionConfiguration) + System.lineSeparator()) .collect(Collectors.joining()); long total = System.currentTimeMillis() - start; logger.info("Generation took {}ms", total); return generated; } RecordingJavascriptGenerator(String baseTemplate,
                                        JavascriptGenerator<ApplicationActionConfiguration> applicationActionGenerator,
                                        JavascriptGenerator<ApplicationConfiguration> contextBuildersGenerator); @Override String generate(ApplicationConfiguration applicationConfiguration);  }### Answer:
@Test public void concatenatesApplicationActionRecorders() { String baseTemplate = "baseTemplate"; String contextBuilders = "contextBuilders"; String generatedCodeForFirstAction = "generated1"; String generatedCodeForSecondAction = "generated2"; ApplicationActionConfiguration firstAction = mock(ApplicationActionConfiguration.class); ApplicationActionConfiguration secondAction = mock(ApplicationActionConfiguration.class); List<ApplicationActionConfiguration> applicationActionConfigurationList = new ArrayList<>(); applicationActionConfigurationList.add(firstAction); applicationActionConfigurationList.add(secondAction); ApplicationConfiguration applicationConfiguration = mock(ApplicationConfiguration.class); when(applicationConfiguration.getApplicationActionConfigurationList()).thenReturn(applicationActionConfigurationList); JavascriptGenerator<ApplicationActionConfiguration> applicationActionGenerator = mock(JavascriptGenerator.class); when(applicationActionGenerator.generate(firstAction)).thenReturn(generatedCodeForFirstAction); when(applicationActionGenerator.generate(secondAction)).thenReturn(generatedCodeForSecondAction); JavascriptGenerator<ApplicationConfiguration> contextBuildersGenerator = mock(JavascriptGenerator.class); when(contextBuildersGenerator.generate(applicationConfiguration)).thenReturn(contextBuilders); JavascriptGenerator javascriptGenerator = new RecordingJavascriptGenerator(baseTemplate, applicationActionGenerator, contextBuildersGenerator); String generatedJavascript = javascriptGenerator.generate(applicationConfiguration); assertTrue(generatedJavascript.contains(generatedCodeForFirstAction)); assertTrue(generatedJavascript.contains(generatedCodeForSecondAction)); String expected = baseTemplate + System.lineSeparator() + contextBuilders + System.lineSeparator() + generatedCodeForFirstAction + System.lineSeparator() + generatedCodeForSecondAction + System.lineSeparator(); assertEquals(expected, generatedJavascript); }