UidlWriter implements Serializable { static JsonArray encodeExecuteJavaScriptList( List<PendingJavaScriptInvocation> executeJavaScriptList) { return executeJavaScriptList.stream() .map(UidlWriter::encodeExecuteJavaScript) .collect(JsonUtils.asArray()); }  JsonObject createUidl(UI ui, boolean async, boolean resync); JsonObject createUidl(UI ui, boolean async);  }
@Test public void testEncodeExecuteJavaScript_npmMode() { Element element = ElementFactory.createDiv(); JavaScriptInvocation invocation1 = new JavaScriptInvocation( "$0.focus()", element); JavaScriptInvocation invocation2 = new JavaScriptInvocation( "console.log($0, $1)", "Lives remaining:", Integer.valueOf(3)); List<PendingJavaScriptInvocation> executeJavaScriptList = Stream .of(invocation1, invocation2) .map(invocation -> new PendingJavaScriptInvocation( element.getNode(), invocation)) .collect(Collectors.toList()); JsonArray json = UidlWriter .encodeExecuteJavaScriptList(executeJavaScriptList); JsonArray expectedJson = JsonUtils.createArray(JsonUtils.createArray( Json.createNull(), Json.create("$0.focus()")), JsonUtils.createArray(Json.create("Lives remaining:"), Json.create(3), Json.create("console.log($0, $1)"))); assertTrue(JsonUtils.jsonEquals(expectedJson, json)); }