use of org.thingsboard.rule.engine.api.TbNodeConfiguration in project thingsboard by thingsboard.
the class TbJsFilterNodeTest method initWithScript.
private void initWithScript() throws TbNodeException {
TbJsFilterNodeConfiguration config = new TbJsFilterNodeConfiguration();
config.setJsScript("scr");
ObjectMapper mapper = new ObjectMapper();
TbNodeConfiguration nodeConfiguration = new TbNodeConfiguration(mapper.valueToTree(config));
when(ctx.createJsScriptEngine("scr")).thenReturn(scriptEngine);
node = new TbJsFilterNode();
node.init(ctx, nodeConfiguration);
}
use of org.thingsboard.rule.engine.api.TbNodeConfiguration in project thingsboard by thingsboard.
the class AbstractAttributeNodeTest method init.
void init(TbEntityGetAttrNode node) throws TbNodeException {
ObjectMapper mapper = JacksonUtil.OBJECT_MAPPER;
TbNodeConfiguration nodeConfiguration = new TbNodeConfiguration(mapper.valueToTree(getTbNodeConfig()));
metaData = new HashMap<>();
metaData.putIfAbsent("word", "temperature");
metaData.putIfAbsent("result", "answer");
this.node = node;
this.node.init(null, nodeConfiguration);
}
use of org.thingsboard.rule.engine.api.TbNodeConfiguration in project thingsboard by thingsboard.
the class AbstractAttributeNodeTest method deviceCustomerTelemetryFetched.
void deviceCustomerTelemetryFetched(Device device) throws TbNodeException {
ObjectMapper mapper = JacksonUtil.OBJECT_MAPPER;
TbNodeConfiguration nodeConfiguration = new TbNodeConfiguration(mapper.valueToTree(getTbNodeConfigForTelemetry()));
TbEntityGetAttrNode node = getEmptyNode();
node.init(null, nodeConfiguration);
msg = TbMsg.newMsg("DEVICE", device.getId(), new TbMsgMetaData(metaData), TbMsgDataType.JSON, "{}", ruleChainId, ruleNodeId);
List<TsKvEntry> timeseries = Lists.newArrayList(new BasicTsKvEntry(1L, new StringDataEntry("temperature", "highest")));
when(ctx.getTimeseriesService()).thenReturn(timeseriesService);
when(timeseriesService.findLatest(any(), eq(getEntityId()), anyCollection())).thenReturn(Futures.immediateFuture(timeseries));
node.onMsg(ctx, msg);
verify(ctx).tellSuccess(msg);
assertEquals(msg.getMetaData().getValue("answer"), "highest");
}
use of org.thingsboard.rule.engine.api.TbNodeConfiguration in project thingsboard by thingsboard.
the class TbChangeOriginatorNodeTest method init.
public void init() throws TbNodeException {
TbChangeOriginatorNodeConfiguration config = new TbChangeOriginatorNodeConfiguration();
config.setOriginatorSource(TbChangeOriginatorNode.CUSTOMER_SOURCE);
ObjectMapper mapper = new ObjectMapper();
TbNodeConfiguration nodeConfiguration = new TbNodeConfiguration(mapper.valueToTree(config));
when(ctx.getDbCallbackExecutor()).thenReturn(dbExecutor);
node = new TbChangeOriginatorNode();
node.init(null, nodeConfiguration);
}
use of org.thingsboard.rule.engine.api.TbNodeConfiguration in project thingsboard by thingsboard.
the class TbJsSwitchNodeTest method initWithScript.
private void initWithScript() throws TbNodeException {
TbJsSwitchNodeConfiguration config = new TbJsSwitchNodeConfiguration();
config.setJsScript("scr");
ObjectMapper mapper = new ObjectMapper();
TbNodeConfiguration nodeConfiguration = new TbNodeConfiguration(mapper.valueToTree(config));
when(ctx.createJsScriptEngine("scr")).thenReturn(scriptEngine);
node = new TbJsSwitchNode();
node.init(ctx, nodeConfiguration);
}
Aggregations