Browse Source

minor refactoring of test class and rule node description

pull/7893/head
ShvaykaD 4 years ago
parent
commit
080aeef525
  1. 6
      rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/delay/TbMsgDeDuplicateNode.java
  2. 12
      rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/action/TbMsgDeDuplicateNodeTest.java

6
rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/delay/TbMsgDeDuplicateNode.java

@ -51,12 +51,12 @@ import java.util.stream.Collectors;
"<b>FIRST</b> - return first message that arrived during de-duplication period.<br></br>" +
"<b>LAST</b> - return last message that arrived during de-duplication period.<br></br>" +
"<b>ALL</b> - return all messages as a single JSON array message. Where each element represents object with <b>msg</b> and <b>metadata</b> inner properties.<br></br>" +
"By default rule node <b>de-duplicates messages by message originator</b>, however, there is an option to de-duplicate messages independently from the incoming message's originator. " +
"In case of the <b>de-duplication strategy</b> set to <b>ALL</b> and <b>de-duplicates messages by message originator</b> checkbox set to <b>false</b>, you must configure the <b>Queue Name</b> and <b>Message Type</b> for the output array message. " +
"By default rule node <b>De-duplicate messages by message originator</b>, however, there is an option to de-duplicate messages independently from the incoming message's originator. " +
"In case of the <b>De-duplicate strategy</b> set to <b>ALL</b> and <b>De-duplicate messages by message originator</b> checkbox set to <b>false</b>, you must configure the <b>Queue Name</b> and <b>Out Message Type</b> for the output array message. " +
"Also in this case the output message originator will be set to the current tenant id.<br></br>",
icon = "pause",
uiResources = {"static/rulenode/rulenode-core-config.js"},
configDirective = ""
configDirective = "tbActionNodeMsgDeDuplicateConfig"
)
@Slf4j
public class TbMsgDeDuplicateNode implements TbNode {

12
rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/action/TbMsgDeDuplicateNodeTest.java

@ -70,10 +70,9 @@ public class TbMsgDeDuplicateNodeTest {
private TbContext ctx;
private ExecutorService executorService = Executors.newSingleThreadExecutor(ThingsBoardThreadFactory.forName("de-duplication-node-test"));
private final ExecutorService executorService = Executors.newSingleThreadExecutor(ThingsBoardThreadFactory.forName("de-duplication-node-test"));
private TenantId tenantId;
private RuleNodeId ruleNodeId;
private TbMsgDeDuplicateNode node;
private TbMsgDeDuplicateNodeConfiguration config;
@ -84,14 +83,13 @@ public class TbMsgDeDuplicateNodeTest {
private int scheduleCount;
@BeforeEach
@SuppressWarnings("unchecked")
public void init() throws TbNodeException {
ctx = mock(TbContext.class);
awaitTellSelfLatch = new CountDownLatch(1);
awaitAllMsgsProcessedLatch = new CountDownLatch(1);
tenantId = TenantId.fromUUID(UUID.randomUUID());
ruleNodeId = new RuleNodeId(UUID.randomUUID());
RuleNodeId ruleNodeId = new RuleNodeId(UUID.randomUUID());
when(ctx.getSelfId()).thenReturn(ruleNodeId);
when(ctx.getTenantId()).thenReturn(tenantId);
@ -129,9 +127,7 @@ public class TbMsgDeDuplicateNodeTest {
@AfterEach
public void destroy() {
if (executorService != null) {
executorService.shutdown();
}
executorService.shutdown();
node.destroy();
}
@ -275,6 +271,8 @@ public class TbMsgDeDuplicateNodeTest {
TbMsg outMessage = newMsgCaptor.getAllValues().get(0);
Assertions.assertEquals(getMergedData(inputMsgs), outMessage.getData());
Assertions.assertEquals(tenantId, outMessage.getOriginator());
Assertions.assertEquals(config.getQueueName(), outMessage.getQueueName());
Assertions.assertEquals(config.getOutMsgType(), outMessage.getType());
}
private List<TbMsg> createTbMsgs(DeviceId deviceId) {

Loading…
Cancel
Save