...
|
...
|
@@ -18,11 +18,14 @@ package org.thingsboard.rule.engine.transform; |
18
|
18
|
import com.datastax.driver.core.utils.UUIDs;
|
19
|
19
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
20
|
20
|
import com.google.common.util.concurrent.Futures;
|
|
21
|
+import com.google.common.util.concurrent.ListenableFuture;
|
|
22
|
+import org.junit.Before;
|
21
|
23
|
import org.junit.Test;
|
22
|
24
|
import org.junit.runner.RunWith;
|
23
|
25
|
import org.mockito.ArgumentCaptor;
|
24
|
26
|
import org.mockito.Mock;
|
25
|
27
|
import org.mockito.runners.MockitoJUnitRunner;
|
|
28
|
+import org.thingsboard.rule.engine.api.ListeningExecutor;
|
26
|
29
|
import org.thingsboard.rule.engine.api.TbContext;
|
27
|
30
|
import org.thingsboard.rule.engine.api.TbNodeConfiguration;
|
28
|
31
|
import org.thingsboard.rule.engine.api.TbNodeException;
|
...
|
...
|
@@ -36,6 +39,8 @@ import org.thingsboard.server.common.msg.TbMsg; |
36
|
39
|
import org.thingsboard.server.common.msg.TbMsgMetaData;
|
37
|
40
|
import org.thingsboard.server.dao.asset.AssetService;
|
38
|
41
|
|
|
42
|
+import java.util.concurrent.Callable;
|
|
43
|
+
|
39
|
44
|
import static org.junit.Assert.assertEquals;
|
40
|
45
|
import static org.mockito.Matchers.same;
|
41
|
46
|
import static org.mockito.Mockito.verify;
|
...
|
...
|
@@ -52,6 +57,26 @@ public class TbChangeOriginatorNodeTest { |
52
|
57
|
@Mock
|
53
|
58
|
private AssetService assetService;
|
54
|
59
|
|
|
60
|
+ private ListeningExecutor dbExecutor;
|
|
61
|
+
|
|
62
|
+ @Before
|
|
63
|
+ public void before() {
|
|
64
|
+ dbExecutor = new ListeningExecutor() {
|
|
65
|
+ @Override
|
|
66
|
+ public <T> ListenableFuture<T> executeAsync(Callable<T> task) {
|
|
67
|
+ try {
|
|
68
|
+ return Futures.immediateFuture(task.call());
|
|
69
|
+ } catch (Exception e) {
|
|
70
|
+ throw new RuntimeException(e);
|
|
71
|
+ }
|
|
72
|
+ }
|
|
73
|
+
|
|
74
|
+ @Override
|
|
75
|
+ public void execute(Runnable command) {
|
|
76
|
+ command.run();
|
|
77
|
+ }
|
|
78
|
+ };
|
|
79
|
+ }
|
55
|
80
|
|
56
|
81
|
@Test
|
57
|
82
|
public void originatorCanBeChangedToCustomerId() throws TbNodeException {
|
...
|
...
|
@@ -134,6 +159,8 @@ public class TbChangeOriginatorNodeTest { |
134
|
159
|
ObjectMapper mapper = new ObjectMapper();
|
135
|
160
|
TbNodeConfiguration nodeConfiguration = new TbNodeConfiguration(mapper.valueToTree(config));
|
136
|
161
|
|
|
162
|
+ when(ctx.getDbCallbackExecutor()).thenReturn(dbExecutor);
|
|
163
|
+
|
137
|
164
|
node = new TbChangeOriginatorNode();
|
138
|
165
|
node.init(null, nodeConfiguration);
|
139
|
166
|
}
|
...
|
...
|
|