### Question:
CssSupportImpl implements CssSupport { @Override public void inject(String cssText) { cssText = cssText.replace("\r\n", "").replace("\n", ""); cssText = StringEscapeUtils.escapeEcmaScript(cssText); executeScriptRetry("cssText = \"" + cssText + "\";\n" + getContentOf(INJECTOR_JS_PATH)); } CssSupportImpl(JavascriptControl javascriptControl, AwaitControl awaitControl); @Override void inject(String cssText); @Override void injectResource(String cssResourceName);  }### Answer:
@Test public void shouldInjectCss() { when(javascriptControl.executeScript(anyString())).thenReturn(fluentJavascript); cssSupport.inject(CSS_TEXT); verify(javascriptControl, times(1)).executeScript(startsWith("cssText = \"some: css\";")); verifyNoMoreInteractions(javascriptControl); }
@Test public void shouldInjectUnescapedCss() { when(javascriptControl.executeScript(anyString())).thenReturn(fluentJavascript); cssSupport.inject("#location {\ndisplay: none\n}"); verify(javascriptControl, times(1)).executeScript(startsWith("cssText = \"#location {display: none}\";")); verifyNoMoreInteractions(javascriptControl); }
@Test public void shouldThrowWebDriverExceptionBeforeReachingMaxRetryCount() { when(javascriptControl.executeScript(startsWith("cssText = \"some: css\";"))).thenThrow(WebDriverException.class) .thenReturn(fluentJavascript); cssSupport.inject(CSS_TEXT); verify(javascriptControl, times(2)).executeScript(startsWith("cssText = \"some: css\";")); verify(awaitControl, times(1)).await(); verifyNoMoreInteractions(javascriptControl); verifyNoMoreInteractions(awaitControl); }
@Test public void shouldThrowWebDriverExceptionAfterReachingMaxRetryCount() { when(javascriptControl.executeScript(startsWith("cssText = \"some: css\";"))).thenThrow(WebDriverException.class); assertThatThrownBy(() -> cssSupport.inject(CSS_TEXT)).isInstanceOf(WebDriverException.class); verify(javascriptControl, times(10)).executeScript(startsWith("cssText = \"some: css\";")); verify(awaitControl, times(9)).await(); verifyNoMoreInteractions(javascriptControl); verifyNoMoreInteractions(awaitControl); }