### Question:
RecordingWebDriverActionsOnly implements JavascriptGenerator<ApplicationActionConfiguration> { @Override public String generate(ApplicationActionConfiguration applicationActionConfiguration) { NameWebDriverActionConfiguration nameWebDriverActionConfiguration = nameWebDriverActionConfigurationSupplier.get( applicationActionConfiguration.getName(), applicationActionConfiguration.getWebDriverAction(), applicationActionConfiguration.getContextProvider() ); return webDriverActionGenerator.generate(nameWebDriverActionConfiguration); } @Inject  RecordingWebDriverActionsOnly(JavascriptGenerator<NameWebDriverActionConfiguration> webDriverActionGenerator,
                                         NameWebDriverActionConfigurationSupplier nameWebDriverActionConfigurationSupplier); @Override String generate(ApplicationActionConfiguration applicationActionConfiguration);  }### Answer:
@Test public void generatesBasedOnNameAndWebDriverAction() { String expected = "expected"; WebDriverActionConfiguration webDriverActionConfiguration = mock(WebDriverActionConfiguration.class); String eventName = "something"; ApplicationActionConfiguration applicationActionConfiguration = mock(ApplicationActionConfiguration.class); ContextProvider contextProvider = mock(ContextProvider.class); when(applicationActionConfiguration.getName()).thenReturn(eventName); when(applicationActionConfiguration.getWebDriverAction()).thenReturn(webDriverActionConfiguration); when(applicationActionConfiguration.getContextProvider()).thenReturn(contextProvider); NameWebDriverActionConfiguration nameWebDriverActionConfiguration = mock(NameWebDriverActionConfiguration.class); JavascriptGenerator<NameWebDriverActionConfiguration> webDriverActionGenerator = mock(JavascriptGenerator.class); when(webDriverActionGenerator.generate(nameWebDriverActionConfiguration)).thenReturn(expected); NameWebDriverActionConfigurationSupplier nameWebDriverActionConfigurationSupplier = mock(NameWebDriverActionConfigurationSupplier.class); when(nameWebDriverActionConfigurationSupplier.get(eventName, webDriverActionConfiguration, contextProvider)) .thenReturn(nameWebDriverActionConfiguration); RecordingWebDriverActionsOnly recordingWebDriverActionsOnly = new RecordingWebDriverActionsOnly(webDriverActionGenerator, nameWebDriverActionConfigurationSupplier); String actual = recordingWebDriverActionsOnly.generate(applicationActionConfiguration); assertEquals(expected, actual); }