TwitterMacro implements IMacroRunnable { @Override public String getHtml(IMacroContext macroContext) { String searchTerms = macroContext.getParameters().trim(); @SuppressWarnings("nls") String html = "<script charset=\"UTF-8\" src=\"http: "<script>\n" + "new TWTR.Widget({" + "version: 2," + "type: 'search'," + "search: '" + StringEscapeUtils.escapeEcmaScript(searchTerms) + "'," + "interval: 15000," + "title: ''," + "subject: ''," + "width: 300," + "height: 300," + "features: {" + "scrollbar: true," + "loop: false," + "live: true," + "behavior: 'default'" + "}" + "}).render().start(); require(['documentr/fixTwitterCss']);\n" + "</script>\n"; return html; }  @Override String getHtml(IMacroContext macroContext); @Override String cleanupHtml(String html);  }
@Test public void getHtml() { when(context.getParameters()).thenReturn("\"searchParams\""); String html = runnable.getHtml(context); @SuppressWarnings("nls") String expectedHtml = "<script charset=\"UTF-8\" src=\"http: "<script>\n" + "new TWTR.Widget({" + "version: 2," + "type: 'search'," + "search: '" + StringEscapeUtils.escapeEcmaScript("\"searchParams\"") + "'," + "interval: 15000," + "title: ''," + "subject: ''," + "width: 300," + "height: 300," + "features: {" + "scrollbar: true," + "loop: false," + "live: true," + "behavior: 'default'" + "}" + "}).render().start(); require(['documentr/fixTwitterCss']);\n" + "</script>\n"; assertEquals(expectedHtml, html); }