@Test public void falseEvaluationDoNotSendMsg() throws TbNodeException, ScriptException { initWithScript(); TbMsg msg = TbMsg.newMsg("USER", null, new TbMsgMetaData(), TbMsgDataType.JSON, "{}", ruleChainId, ruleNodeId); mockJsExecutor(); when(scriptEngine.executeFilterAsync(msg)).thenReturn(Futures.immediateFuture(false)); node.onMsg(ctx, msg); verify(ctx).getDbCallbackExecutor(); verify(ctx).tellNext(msg, "False"); }
@Override public void onMsg(TbContext ctx, TbMsg msg) { ctx.logJsEvalRequest(); withCallback(jsEngine.executeFilterAsync(msg), filterResult -> { ctx.logJsEvalResponse(); ctx.tellNext(msg, filterResult ? "True" : "False"); }, t -> { ctx.tellFailure(msg, t); ctx.logJsEvalFailure(); }, ctx.getDbCallbackExecutor()); }
TbJsFilterNode implements TbNode { @Override public void onMsg(TbContext ctx, TbMsg msg) { ctx.logJsEvalRequest(); withCallback(jsEngine.executeFilterAsync(msg), filterResult -> { ctx.logJsEvalResponse(); ctx.tellNext(msg, filterResult ? "True" : "False"); }, t -> { ctx.tellFailure(msg, t); ctx.logJsEvalFailure(); }, ctx.getDbCallbackExecutor()); } }
TbJsFilterNode implements TbNode { @Override public void onMsg(TbContext ctx, TbMsg msg) { ctx.logJsEvalRequest(); withCallback(jsEngine.executeFilterAsync(msg), filterResult -> { ctx.logJsEvalResponse(); ctx.tellNext(msg, filterResult ? "True" : "False"); }, t -> { ctx.tellFailure(msg, t); ctx.logJsEvalFailure(); }, ctx.getDbCallbackExecutor()); }  }
TbJsFilterNode implements TbNode { @Override public void onMsg(TbContext ctx, TbMsg msg) { ctx.logJsEvalRequest(); withCallback(jsEngine.executeFilterAsync(msg), filterResult -> { ctx.logJsEvalResponse(); ctx.tellNext(msg, filterResult ? "True" : "False"); }, t -> { ctx.tellFailure(msg, t); ctx.logJsEvalFailure(); }, ctx.getDbCallbackExecutor()); }  @Override void init(TbContext ctx, TbNodeConfiguration configuration); @Override void onMsg(TbContext ctx, TbMsg msg); @Override void destroy(); }
TbJsFilterNode implements TbNode { @Override public void onMsg(TbContext ctx, TbMsg msg) { ctx.logJsEvalRequest(); withCallback(jsEngine.executeFilterAsync(msg), filterResult -> { ctx.logJsEvalResponse(); ctx.tellNext(msg, filterResult ? "True" : "False"); }, t -> { ctx.tellFailure(msg, t); ctx.logJsEvalFailure(); }, ctx.getDbCallbackExecutor()); }  @Override void init(TbContext ctx, TbNodeConfiguration configuration); @Override void onMsg(TbContext ctx, TbMsg msg); @Override void destroy();  }