@ -15,7 +15,6 @@
* /
package org.thingsboard.server.service.edge.rpc.constructor ;
import com.fasterxml.jackson.core.JsonProcessingException ;
import com.fasterxml.jackson.databind.JsonNode ;
import lombok.extern.slf4j.Slf4j ;
import org.junit.Assert ;
@ -61,7 +60,7 @@ public class RuleChainMsgConstructorTest {
}
@Test
public void testConstructRuleChainMetadataUpdatedMsg_V_3_4_0 ( ) throws JsonProcessingException {
public void testConstructRuleChainMetadataUpdatedMsg_V_3_4_0 ( ) {
RuleChainId ruleChainId = new RuleChainId ( UUID . randomUUID ( ) ) ;
RuleChainMetaData ruleChainMetaData = createRuleChainMetaData (
ruleChainId , 3 , createRuleNodes ( ruleChainId ) , createConnections ( ) ) ;
@ -80,7 +79,7 @@ public class RuleChainMsgConstructorTest {
}
@Test
public void testConstructRuleChainMetadataUpdatedMsg_V_3_3_3 ( ) throws JsonProcessingException {
public void testConstructRuleChainMetadataUpdatedMsg_V_3_3_3 ( ) {
RuleChainId ruleChainId = new RuleChainId ( UUID . randomUUID ( ) ) ;
RuleChainMetaData ruleChainMetaData = createRuleChainMetaData (
ruleChainId , 3 , createRuleNodes ( ruleChainId ) , createConnections ( ) ) ;
@ -120,7 +119,7 @@ public class RuleChainMsgConstructorTest {
}
@Test
public void testConstructRuleChainMetadataUpdatedMsg_V_3_3_0 ( ) throws JsonProcessingException {
public void testConstructRuleChainMetadataUpdatedMsg_V_3_3_0 ( ) {
RuleChainId ruleChainId = new RuleChainId ( UUID . randomUUID ( ) ) ;
RuleChainMetaData ruleChainMetaData = createRuleChainMetaData ( ruleChainId , 3 , createRuleNodes ( ruleChainId ) , createConnections ( ) ) ;
RuleChainMetadataUpdateMsg ruleChainMetadataUpdateMsg =
@ -161,7 +160,7 @@ public class RuleChainMsgConstructorTest {
}
@Test
public void testConstructRuleChainMetadataUpdatedMsg_V_3_3_0_inDifferentOrder ( ) throws JsonProcessingException {
public void testConstructRuleChainMetadataUpdatedMsg_V_3_3_0_inDifferentOrder ( ) {
// same rule chain metadata, but different order of rule nodes
RuleChainId ruleChainId = new RuleChainId ( UUID . randomUUID ( ) ) ;
RuleChainMetaData ruleChainMetaData1 = createRuleChainMetaData ( ruleChainId , 8 , createRuleNodesInDifferentOrder ( ruleChainId ) , createConnectionsInDifferentOrder ( ) ) ;
@ -254,7 +253,7 @@ public class RuleChainMsgConstructorTest {
return result ;
}
private List < RuleNode > createRuleNodes ( RuleChainId ruleChainId ) throws JsonProcessingException {
private List < RuleNode > createRuleNodes ( RuleChainId ruleChainId ) {
List < RuleNode > result = new ArrayList < > ( ) ;
result . add ( getOutputNode ( ruleChainId ) ) ;
result . add ( getAcknowledgeNode ( ruleChainId ) ) ;
@ -301,7 +300,7 @@ public class RuleChainMsgConstructorTest {
return result ;
}
private List < RuleNode > createRuleNodesInDifferentOrder ( RuleChainId ruleChainId ) throws JsonProcessingException {
private List < RuleNode > createRuleNodesInDifferentOrder ( RuleChainId ruleChainId ) {
List < RuleNode > result = new ArrayList < > ( ) ;
result . add ( getPushToAnalyticsNode ( ruleChainId ) ) ;
result . add ( getPushToCloudNode ( ruleChainId ) ) ;
@ -319,99 +318,99 @@ public class RuleChainMsgConstructorTest {
}
private RuleNode getOutputNode ( RuleChainId ruleChainId ) throws JsonProcessingException {
private RuleNode getOutputNode ( RuleChainId ruleChainId ) {
return createRuleNode ( ruleChainId ,
"org.thingsboard.rule.engine.flow.TbRuleChainOutputNode" ,
"Output node" ,
JacksonUtil . OBJECT_MAPPER . readTre e( "{\"version\":0}" ) ,
JacksonUtil . OBJECT_MAPPER . readTre e( "{\"description\":\"\",\"layoutX\":178,\"layoutY\":592}" ) ) ;
JacksonUtil . toJsonNod e( "{\"version\":0}" ) ,
JacksonUtil . toJsonNod e( "{\"description\":\"\",\"layoutX\":178,\"layoutY\":592}" ) ) ;
}
private RuleNode getCheckpointNode ( RuleChainId ruleChainId ) throws JsonProcessingException {
private RuleNode getCheckpointNode ( RuleChainId ruleChainId ) {
return createRuleNode ( ruleChainId ,
"org.thingsboard.rule.engine.flow.TbCheckpointNode" ,
"Checkpoint node" ,
JacksonUtil . OBJECT_MAPPER . readTre e( "{\"queueName\":\"HighPriority\"}" ) ,
JacksonUtil . OBJECT_MAPPER . readTre e( "{\"description\":\"\",\"layoutX\":178,\"layoutY\":647}" ) ) ;
JacksonUtil . toJsonNod e( "{\"queueName\":\"HighPriority\"}" ) ,
JacksonUtil . toJsonNod e( "{\"description\":\"\",\"layoutX\":178,\"layoutY\":647}" ) ) ;
}
private RuleNode getSaveTimeSeriesNode ( RuleChainId ruleChainId ) throws JsonProcessingException {
private RuleNode getSaveTimeSeriesNode ( RuleChainId ruleChainId ) {
return createRuleNode ( ruleChainId ,
"org.thingsboard.rule.engine.telemetry.TbMsgTimeseriesNode" ,
"Save Timeseries" ,
JacksonUtil . OBJECT_MAPPER . readTre e( "{\"defaultTTL\":0}" ) ,
JacksonUtil . OBJECT_MAPPER . readTre e( "{\"layoutX\":823,\"layoutY\":157}" ) ) ;
JacksonUtil . toJsonNod e( "{\"defaultTTL\":0}" ) ,
JacksonUtil . toJsonNod e( "{\"layoutX\":823,\"layoutY\":157}" ) ) ;
}
private RuleNode getMessageTypeSwitchNode ( RuleChainId ruleChainId ) throws JsonProcessingException {
private RuleNode getMessageTypeSwitchNode ( RuleChainId ruleChainId ) {
return createRuleNode ( ruleChainId ,
"org.thingsboard.rule.engine.filter.TbMsgTypeSwitchNode" ,
"Message Type Switch" ,
JacksonUtil . OBJECT_MAPPER . readTre e( "{\"version\":0}" ) ,
JacksonUtil . OBJECT_MAPPER . readTre e( "{\"layoutX\":347,\"layoutY\":149}" ) ) ;
JacksonUtil . toJsonNod e( "{\"version\":0}" ) ,
JacksonUtil . toJsonNod e( "{\"layoutX\":347,\"layoutY\":149}" ) ) ;
}
private RuleNode getLogOtherNode ( RuleChainId ruleChainId ) throws JsonProcessingException {
private RuleNode getLogOtherNode ( RuleChainId ruleChainId ) {
return createRuleNode ( ruleChainId ,
"org.thingsboard.rule.engine.action.TbLogNode" ,
"Log Other" ,
JacksonUtil . OBJECT_MAPPER . readTre e( "{\"jsScript\":\"return '\\\\nIncoming message:\\\\n' + JSON.stringify(msg) + '\\\\nIncoming metadata:\\\\n' + JSON.stringify(metadata);\"}" ) ,
JacksonUtil . OBJECT_MAPPER . readTre e( "{\"layoutX\":824,\"layoutY\":378}" ) ) ;
JacksonUtil . toJsonNod e( "{\"jsScript\":\"return '\\\\nIncoming message:\\\\n' + JSON.stringify(msg) + '\\\\nIncoming metadata:\\\\n' + JSON.stringify(metadata);\"}" ) ,
JacksonUtil . toJsonNod e( "{\"layoutX\":824,\"layoutY\":378}" ) ) ;
}
private RuleNode getPushToCloudNode ( RuleChainId ruleChainId ) throws JsonProcessingException {
private RuleNode getPushToCloudNode ( RuleChainId ruleChainId ) {
return createRuleNode ( ruleChainId ,
"org.thingsboard.rule.engine.edge.TbMsgPushToCloudNode" ,
"Push to cloud" ,
JacksonUtil . OBJECT_MAPPER . readTre e( "{\"scope\":\"SERVER_SCOPE\"}" ) ,
JacksonUtil . OBJECT_MAPPER . readTre e( "{\"layoutX\":1129,\"layoutY\":52}" ) ) ;
JacksonUtil . toJsonNod e( "{\"scope\":\"SERVER_SCOPE\"}" ) ,
JacksonUtil . toJsonNod e( "{\"layoutX\":1129,\"layoutY\":52}" ) ) ;
}
private RuleNode getAcknowledgeNode ( RuleChainId ruleChainId ) throws JsonProcessingException {
private RuleNode getAcknowledgeNode ( RuleChainId ruleChainId ) {
return createRuleNode ( ruleChainId ,
"org.thingsboard.rule.engine.flow.TbAckNode" ,
"Acknowledge node" ,
JacksonUtil . OBJECT_MAPPER . readTre e( "{\"version\":0}" ) ,
JacksonUtil . OBJECT_MAPPER . readTre e( "{\"description\":\"\",\"layoutX\":177,\"layoutY\":703}" ) ) ;
JacksonUtil . toJsonNod e( "{\"version\":0}" ) ,
JacksonUtil . toJsonNod e( "{\"description\":\"\",\"layoutX\":177,\"layoutY\":703}" ) ) ;
}
private RuleNode getDeviceProfileNode ( RuleChainId ruleChainId ) throws JsonProcessingException {
private RuleNode getDeviceProfileNode ( RuleChainId ruleChainId ) {
return createRuleNode ( ruleChainId ,
"org.thingsboard.rule.engine.profile.TbDeviceProfileNode" ,
"Device Profile Node" ,
JacksonUtil . OBJECT_MAPPER . readTre e( "{\"persistAlarmRulesState\":false,\"fetchAlarmRulesStateOnStart\":false}" ) ,
JacksonUtil . OBJECT_MAPPER . readTre e( "{\"description\":\"Process incoming messages from devices with the alarm rules defined in the device profile. Dispatch all incoming messages with \\\"Success\\\" relation type.\",\"layoutX\":187,\"layoutY\":468}" ) ) ;
JacksonUtil . toJsonNod e( "{\"persistAlarmRulesState\":false,\"fetchAlarmRulesStateOnStart\":false}" ) ,
JacksonUtil . toJsonNod e( "{\"description\":\"Process incoming messages from devices with the alarm rules defined in the device profile. Dispatch all incoming messages with \\\"Success\\\" relation type.\",\"layoutX\":187,\"layoutY\":468}" ) ) ;
}
private RuleNode getSaveClientAttributesNode ( RuleChainId ruleChainId ) throws JsonProcessingException {
private RuleNode getSaveClientAttributesNode ( RuleChainId ruleChainId ) {
return createRuleNode ( ruleChainId ,
"org.thingsboard.rule.engine.telemetry.TbMsgAttributesNode" ,
"Save Client Attributes" ,
JacksonUtil . OBJECT_MAPPER . readTre e( "{\"scope\":\"CLIENT_SCOPE\"}" ) ,
JacksonUtil . OBJECT_MAPPER . readTre e( "{\"layoutX\":824,\"layoutY\":52}" ) ) ;
JacksonUtil . toJsonNod e( "{\"scope\":\"CLIENT_SCOPE\"}" ) ,
JacksonUtil . toJsonNod e( "{\"layoutX\":824,\"layoutY\":52}" ) ) ;
}
private RuleNode getLogRpcFromDeviceNode ( RuleChainId ruleChainId ) throws JsonProcessingException {
private RuleNode getLogRpcFromDeviceNode ( RuleChainId ruleChainId ) {
return createRuleNode ( ruleChainId ,
"org.thingsboard.rule.engine.action.TbLogNode" ,
"Log RPC from Device" ,
JacksonUtil . OBJECT_MAPPER . readTre e( "{\"jsScript\":\"return '\\\\nIncoming message:\\\\n' + JSON.stringify(msg) + '\\\\nIncoming metadata:\\\\n' + JSON.stringify(metadata);\"}" ) ,
JacksonUtil . OBJECT_MAPPER . readTre e( "{\"layoutX\":825,\"layoutY\":266}" ) ) ;
JacksonUtil . toJsonNod e( "{\"jsScript\":\"return '\\\\nIncoming message:\\\\n' + JSON.stringify(msg) + '\\\\nIncoming metadata:\\\\n' + JSON.stringify(metadata);\"}" ) ,
JacksonUtil . toJsonNod e( "{\"layoutX\":825,\"layoutY\":266}" ) ) ;
}
private RuleNode getRpcCallRequestNode ( RuleChainId ruleChainId ) throws JsonProcessingException {
private RuleNode getRpcCallRequestNode ( RuleChainId ruleChainId ) {
return createRuleNode ( ruleChainId ,
"org.thingsboard.rule.engine.rpc.TbSendRPCRequestNode" ,
"RPC Call Request" ,
JacksonUtil . OBJECT_MAPPER . readTre e( "{\"timeoutInSeconds\":60}" ) ,
JacksonUtil . OBJECT_MAPPER . readTre e( "{\"layoutX\":824,\"layoutY\":466}" ) ) ;
JacksonUtil . toJsonNod e( "{\"timeoutInSeconds\":60}" ) ,
JacksonUtil . toJsonNod e( "{\"layoutX\":824,\"layoutY\":466}" ) ) ;
}
private RuleNode getPushToAnalyticsNode ( RuleChainId ruleChainId ) throws JsonProcessingException {
private RuleNode getPushToAnalyticsNode ( RuleChainId ruleChainId ) {
return createRuleNode ( ruleChainId ,
"org.thingsboard.rule.engine.flow.TbRuleChainInputNode" ,
"Push to Analytics" ,
JacksonUtil . OBJECT_MAPPER . readTre e( "{\"ruleChainId\":\"af588000-6c7c-11ec-bafd-c9a47a5c8d99\"}" ) ,
JacksonUtil . OBJECT_MAPPER . readTre e( "{\"description\":\"\",\"layoutX\":477,\"layoutY\":560}" ) ) ;
JacksonUtil . toJsonNod e( "{\"ruleChainId\":\"af588000-6c7c-11ec-bafd-c9a47a5c8d99\"}" ) ,
JacksonUtil . toJsonNod e( "{\"description\":\"\",\"layoutX\":477,\"layoutY\":560}" ) ) ;
}
}
}