FileExportScriptInjector { public void inject() { final String fileSaver = getFileSaverSource(); final String jsPdf = getJsPdfSource(); final String c2sSource = getC2SSource(); scriptInjector.accept("var " + fileSaver + "\n" + jsPdf + "\n" + c2sSource + "\n"); } FileExportScriptInjector();   FileExportScriptInjector(final Consumer<String> scriptInjector); void inject(); static final String NS_SEPARATOR; static final String NS; static final String JS_OBJ_SUFFIX; }
@Test public void testInject() { tested.inject(); final ArgumentCaptor<String> scriptCaptor = ArgumentCaptor.forClass(String.class); verify(scriptInjector, times(1)).accept(scriptCaptor.capture()); final String script = scriptCaptor.getValue(); final String fsNsObject = buildNamespaceObject(NS + JsFileSaver.class.getSimpleName() + ".saveAs"); final String jsPdfNsObject = buildNamespaceObject(NS + JsPdf.class.getSimpleName()); final String c2sNsObject = FileExportResources.INSTANCE.canvas2svg().getText(); assertEquals("var " + fsNsObject + " = function(blob, fileName, disableAutoBOM) {\n" + "fileSaver\n" + "return saveAs(blob, fileName, disableAutoBOM);};\n" + jsPdfNsObject + " = function(settings) {\n" + "jsPdf\n" + "var saveAs = " + NS + "JsFileSaver.saveAs; " + "return new jsPDF(settings);};" + "\n" + c2sNsObject + "\n", script); }