Browse Source

Merge pull request #15491 from zzzeebra/cleanup/unchecked-generics-lts-4.2

Removed compiler warnings about raw types and unchecked casts
pull/15910/head
Viacheslav Klimov 2 weeks ago
committed by GitHub
parent
commit
c309fdfdbb
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 10
      application/src/test/java/org/thingsboard/server/transport/lwm2m/rpc/AbstractRpcLwM2MIntegrationTest.java
  2. 3
      common/data/src/main/java/org/thingsboard/server/common/data/util/CollectionsUtil.java
  3. 2
      common/script/script-api/src/main/java/org/thingsboard/script/api/tbel/TbUtils.java
  4. 12
      common/script/script-api/src/test/java/org/thingsboard/script/api/tbel/TbUtilsTest.java
  5. 2
      common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/downlink/DefaultLwM2mDownlinkMsgHandler.java
  6. 12
      common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/rpc/DefaultLwM2MRpcRequestHandler.java
  7. 4
      common/transport/transport-api/src/test/java/org/thingsboard/server/common/transport/service/TransportActivityManagerTest.java
  8. 1
      common/util/src/main/java/org/thingsboard/common/util/ExceptionUtil.java
  9. 12
      dao/src/test/java/org/thingsboard/server/dao/AbstractRedisClusterContainer.java
  10. 2
      rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/flow/TbCheckpointNodeTest.java
  11. 2
      rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/kafka/TbKafkaNodeTest.java
  12. 12
      rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/metadata/TbGetTelemetryNodeTest.java
  13. 2
      rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/telemetry/TbMsgDeleteAttributesNodeTest.java
  14. 10
      rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/transform/TbMsgDeduplicationNodeTest.java
  15. 2
      rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/transform/TbSplitArrayMsgNodeTest.java

10
application/src/test/java/org/thingsboard/server/transport/lwm2m/rpc/AbstractRpcLwM2MIntegrationTest.java

@ -78,16 +78,16 @@ public abstract class AbstractRpcLwM2MIntegrationTest extends AbstractLwM2MInteg
protected final LinkParser linkParser = new DefaultLwM2mLinkParser();
protected String CONFIG_PROFILE_WITH_PARAMS_RPC;
public Set expectedObjects;
public Set expectedObjectIdVers;
public Set expectedInstances;
public Set expectedObjectIdVerInstances;
public Set<String> expectedObjects;
public Set<String> expectedObjectIdVers;
public Set<String> expectedInstances;
public Set<String> expectedObjectIdVerInstances;
protected String objectInstanceIdVer_1;
protected String objectIdVer_0;
protected String objectIdVer_1;
protected String objectIdVer_2;
private static final Predicate PREDICATE_3 = path -> (!((String) path).startsWith("/" + TEMPERATURE_SENSOR) && ((String) path).startsWith("/" + DEVICE));
private static final Predicate<String> PREDICATE_3 = path -> (!((String) path).startsWith("/" + TEMPERATURE_SENSOR) && ((String) path).startsWith("/" + DEVICE));
protected String objectIdVer_3;
protected String objectInstanceIdVer_3;
protected String objectInstanceIdVer_5;

3
common/data/src/main/java/org/thingsboard/server/common/data/util/CollectionsUtil.java

@ -83,6 +83,7 @@ public class CollectionsUtil {
return result;
}
@SafeVarargs
public static <V> boolean isOneOf(V value, V... others) {
if (value == null) {
return false;
@ -105,7 +106,7 @@ public class CollectionsUtil {
Set<T> newSet = new HashSet<>(existing.size() + 1);
newSet.addAll(existing);
newSet.add(value);
return (Set<T>) Set.of(newSet.toArray());
return Set.copyOf(newSet);
}
}

2
common/script/script-api/src/main/java/org/thingsboard/script/api/tbel/TbUtils.java

@ -1353,7 +1353,7 @@ public class TbUtils {
for (byte b : byteArray) {
byteList.add(b);
}
ExecutionArrayList<Byte> list = new ExecutionArrayList(byteList, ctx);
ExecutionArrayList<Byte> list = new ExecutionArrayList<>(byteList, ctx);
return list;
}

12
common/script/script-api/src/test/java/org/thingsboard/script/api/tbel/TbUtilsTest.java

@ -1316,13 +1316,13 @@ public class TbUtilsTest {
}
@Test
public void setTest() throws ExecutionException, InterruptedException {
Set actual = TbUtils.newSet(ctx);
Set expected = toSet(new byte[]{(byte) 0xDD, (byte) 0xCC, (byte) 0xCC});
Set<Byte> actual = TbUtils.newSet(ctx);
Set<Byte> expected = toSet(new byte[]{(byte) 0xDD, (byte) 0xCC, (byte) 0xCC});
actual.add((byte) 0xDD);
actual.add((byte) 0xCC);
actual.add((byte) 0xCC);
assertTrue(expected.containsAll(actual));
List list = toList(new byte[]{(byte) 0xDD, (byte) 0xCC, (byte) 0xBB, (byte) 0xAA});
List<Byte> list = toList(new byte[]{(byte) 0xDD, (byte) 0xCC, (byte) 0xBB, (byte) 0xAA});
actual.addAll(list);
assertEquals(4, actual.size());
assertTrue(actual.containsAll(expected));
@ -1336,9 +1336,9 @@ public class TbUtilsTest {
actual.clear();
assertTrue(actual.isEmpty());
actual = TbUtils.toSet(ctx, list);
Set actualClone = TbUtils.toSet(ctx, list);
Set actualClone_asc = TbUtils.toSet(ctx, list);
Set actualClone_desc = TbUtils.toSet(ctx, list);
Set<Byte> actualClone = TbUtils.toSet(ctx, list);
Set<Byte> actualClone_asc = TbUtils.toSet(ctx, list);
Set<Byte> actualClone_desc = TbUtils.toSet(ctx, list);
((ExecutionLinkedHashSet<?>)actualClone).sort();
((ExecutionLinkedHashSet<?>)actualClone_asc).sort(true);
((ExecutionLinkedHashSet<?>)actualClone_desc).sort(false);

2
common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/downlink/DefaultLwM2mDownlinkMsgHandler.java

@ -815,7 +815,7 @@ public class DefaultLwM2mDownlinkMsgHandler extends LwM2MExecutorAwareService im
LwM2mPath pathSingleOb = singleObs.getPath();
LwM2mPath pathObjectId = new LwM2mPath(objectId);
if (!pathSingleOb.toString().equals(objectId)) {
List paths = Arrays.asList(pathSingleOb, pathObjectId);
List<LwM2mPath> paths = Arrays.asList(pathSingleOb, pathObjectId);
try {
LwM2mPath.validateNotOverlapping(paths);
} catch (IllegalArgumentException e){

12
common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/rpc/DefaultLwM2MRpcRequestHandler.java

@ -212,7 +212,7 @@ public class DefaultLwM2MRpcRequestHandler implements LwM2MRpcRequestHandler {
String[] versionedIds = getIdsFromParameters(client, requestMsg);
TbLwM2MReadCompositeRequest request = TbLwM2MReadCompositeRequest.builder().versionedIds(versionedIds).timeout(clientContext.getRequestTimeout(client)).build();
var mainCallback = new TbLwM2MReadCompositeCallback(uplinkHandler, logService, client, versionedIds);
var rpcCallback = new RpcReadResponseCompositeCallback(transportService, client, requestMsg, mainCallback);
var rpcCallback = new RpcReadResponseCompositeCallback<>(transportService, client, requestMsg, mainCallback);
downlinkHandler.sendReadCompositeRequest(client, request, rpcCallback);
}
@ -323,7 +323,7 @@ public class DefaultLwM2MRpcRequestHandler implements LwM2MRpcRequestHandler {
} else if (path.isResource()) {
validateResource(client, newNodes, nodes, key , value);
} else if (path.isObjectInstance() && value instanceof Map<?, ?>) {
((Map) value).forEach((k, v) -> {
((Map<?, ?>) value).forEach((k, v) -> {
validateResource(client, newNodes, nodes, validateResourceId (key, k.toString(), nodes), v);
});
} else {
@ -337,7 +337,7 @@ public class DefaultLwM2MRpcRequestHandler implements LwM2MRpcRequestHandler {
return newNodes;
}
private void validateResource(LwM2mClient client, Map newNodes, Map nodes, String resourceId , Object value) {
private void validateResource(LwM2mClient client, Map<String, Object> newNodes, Map<String, Object> nodes, String resourceId , Object value) {
if (value instanceof Map<?, ?>) {
((Map<?, ?>) value).forEach((k, v) -> {
setValueToCompositeNodes(client, newNodes, nodes, validateResourceId (resourceId, k.toString(), nodes), v);
@ -347,7 +347,7 @@ public class DefaultLwM2MRpcRequestHandler implements LwM2MRpcRequestHandler {
}
}
private String validateResourceId (String key, String id, Map nodes) {
private String validateResourceId (String key, String id, Map<String, Object> nodes) {
try {
Integer.parseInt(id);
return key + "/" + id;
@ -357,7 +357,7 @@ public class DefaultLwM2MRpcRequestHandler implements LwM2MRpcRequestHandler {
}
}
private void setValueToCompositeNodes (LwM2mClient client, Map newNodes, Map nodes, String versionedId , Object value) {
private void setValueToCompositeNodes (LwM2mClient client, Map<String, Object> newNodes, Map<String, Object> nodes, String versionedId , Object value) {
// validate value. Must be only primitive, not JsonObject or JsonArray
try {
JsonElement element = JsonUtils.parse(value);
@ -388,7 +388,7 @@ public class DefaultLwM2MRpcRequestHandler implements LwM2MRpcRequestHandler {
String[] versionedIds = getIdsFromParameters(client, requestMsg);
TbLwM2MObserveCompositeRequest request = TbLwM2MObserveCompositeRequest.builder().versionedIds(versionedIds).timeout(clientContext.getRequestTimeout(client)).build();
var mainCallback = new TbLwM2MObserveCompositeCallback(uplinkHandler, logService, client, versionedIds);
var rpcCallback = new RpcObserveResponseCompositeCallback(transportService, client, requestMsg, mainCallback);
var rpcCallback = new RpcObserveResponseCompositeCallback<>(transportService, client, requestMsg, mainCallback);
downlinkHandler.sendObserveCompositeRequest(client, request, rpcCallback);
}

4
common/transport/transport-api/src/test/java/org/thingsboard/server/common/transport/service/TransportActivityManagerTest.java

@ -122,7 +122,7 @@ public class TransportActivityManagerTest {
// THEN
ArgumentCaptor<TransportProtos.SessionInfoProto> sessionInfoCaptor = ArgumentCaptor.forClass(TransportProtos.SessionInfoProto.class);
ArgumentCaptor<TransportProtos.SubscriptionInfoProto> subscriptionInfoCaptor = ArgumentCaptor.forClass(TransportProtos.SubscriptionInfoProto.class);
ArgumentCaptor<TransportServiceCallback<Void>> callbackCaptor = ArgumentCaptor.forClass(TransportServiceCallback.class);
ArgumentCaptor<TransportServiceCallback<Void>> callbackCaptor = ArgumentCaptor.captor();
verify(transportServiceMock).process(sessionInfoCaptor.capture(), subscriptionInfoCaptor.capture(), callbackCaptor.capture());
@ -166,7 +166,7 @@ public class TransportActivityManagerTest {
// THEN
ArgumentCaptor<TransportProtos.SessionInfoProto> sessionInfoCaptor = ArgumentCaptor.forClass(TransportProtos.SessionInfoProto.class);
ArgumentCaptor<TransportProtos.SubscriptionInfoProto> subscriptionInfoCaptor = ArgumentCaptor.forClass(TransportProtos.SubscriptionInfoProto.class);
ArgumentCaptor<TransportServiceCallback<Void>> callbackCaptor = ArgumentCaptor.forClass(TransportServiceCallback.class);
ArgumentCaptor<TransportServiceCallback<Void>> callbackCaptor = ArgumentCaptor.captor();
verify(transportServiceMock).process(sessionInfoCaptor.capture(), subscriptionInfoCaptor.capture(), callbackCaptor.capture());

1
common/util/src/main/java/org/thingsboard/common/util/ExceptionUtil.java

@ -37,6 +37,7 @@ public class ExceptionUtil {
}
}
@SafeVarargs
public static Exception lookupExceptionInCause(Throwable source, Class<? extends Exception>... clazzes) {
while (source != null) {
for (Class<? extends Exception> clazz : clazzes) {

12
dao/src/test/java/org/thingsboard/server/dao/AbstractRedisClusterContainer.java

@ -40,17 +40,17 @@ public class AbstractRedisClusterContainer {
);
@ClassRule(order = 1)
public static GenericContainer redis1 = new GenericContainer(IMAGE).withEnv(ENVS).withEnv("VALKEY_PORT_NUMBER", "6371").withNetworkMode("host").withLogConsumer(AbstractRedisClusterContainer::consumeLog);
public static GenericContainer<?> redis1 = new GenericContainer<>(IMAGE).withEnv(ENVS).withEnv("VALKEY_PORT_NUMBER", "6371").withNetworkMode("host").withLogConsumer(AbstractRedisClusterContainer::consumeLog);
@ClassRule(order = 2)
public static GenericContainer redis2 = new GenericContainer(IMAGE).withEnv(ENVS).withEnv("VALKEY_PORT_NUMBER", "6372").withNetworkMode("host").withLogConsumer(AbstractRedisClusterContainer::consumeLog);
public static GenericContainer<?> redis2 = new GenericContainer<>(IMAGE).withEnv(ENVS).withEnv("VALKEY_PORT_NUMBER", "6372").withNetworkMode("host").withLogConsumer(AbstractRedisClusterContainer::consumeLog);
@ClassRule(order = 3)
public static GenericContainer redis3 = new GenericContainer(IMAGE).withEnv(ENVS).withEnv("VALKEY_PORT_NUMBER", "6373").withNetworkMode("host").withLogConsumer(AbstractRedisClusterContainer::consumeLog);
public static GenericContainer<?> redis3 = new GenericContainer<>(IMAGE).withEnv(ENVS).withEnv("VALKEY_PORT_NUMBER", "6373").withNetworkMode("host").withLogConsumer(AbstractRedisClusterContainer::consumeLog);
@ClassRule(order = 4)
public static GenericContainer redis4 = new GenericContainer(IMAGE).withEnv(ENVS).withEnv("VALKEY_PORT_NUMBER", "6374").withNetworkMode("host").withLogConsumer(AbstractRedisClusterContainer::consumeLog);
public static GenericContainer<?> redis4 = new GenericContainer<>(IMAGE).withEnv(ENVS).withEnv("VALKEY_PORT_NUMBER", "6374").withNetworkMode("host").withLogConsumer(AbstractRedisClusterContainer::consumeLog);
@ClassRule(order = 5)
public static GenericContainer redis5 = new GenericContainer(IMAGE).withEnv(ENVS).withEnv("VALKEY_PORT_NUMBER", "6375").withNetworkMode("host").withLogConsumer(AbstractRedisClusterContainer::consumeLog);
public static GenericContainer<?> redis5 = new GenericContainer<>(IMAGE).withEnv(ENVS).withEnv("VALKEY_PORT_NUMBER", "6375").withNetworkMode("host").withLogConsumer(AbstractRedisClusterContainer::consumeLog);
@ClassRule(order = 6)
public static GenericContainer redis6 = new GenericContainer(IMAGE).withEnv(ENVS).withEnv("VALKEY_PORT_NUMBER", "6376").withNetworkMode("host").withLogConsumer(AbstractRedisClusterContainer::consumeLog);
public static GenericContainer<?> redis6 = new GenericContainer<>(IMAGE).withEnv(ENVS).withEnv("VALKEY_PORT_NUMBER", "6376").withNetworkMode("host").withLogConsumer(AbstractRedisClusterContainer::consumeLog);
@ClassRule(order = 100)

2
rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/flow/TbCheckpointNodeTest.java

@ -114,7 +114,7 @@ public class TbCheckpointNodeTest extends AbstractRuleNodeUpgradeTest {
.build();
node.onMsg(ctxMock, msg);
ArgumentCaptor<Consumer<Throwable>> onFailure = ArgumentCaptor.forClass(Consumer.class);
ArgumentCaptor<Consumer<Throwable>> onFailure = ArgumentCaptor.captor();
then(ctxMock).should().enqueueForTellNext(eq(msg), eq(DataConstants.HP_QUEUE_NAME), eq(TbNodeConnectionType.SUCCESS), any(), onFailure.capture());
String errorMsg = "Something went wrong.";
onFailure.getValue().accept(new RuntimeException(errorMsg));

2
rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/kafka/TbKafkaNodeTest.java

@ -420,7 +420,7 @@ public class TbKafkaNodeTest extends AbstractRuleNodeUpgradeTest {
}
private void verifyProducerRecord(String expectedTopic, String expectedKey, String expectedValue, Headers expectedHeaders) {
ArgumentCaptor<ProducerRecord<String, String>> actualRecordCaptor = ArgumentCaptor.forClass(ProducerRecord.class);
ArgumentCaptor<ProducerRecord<String, String>> actualRecordCaptor = ArgumentCaptor.captor();
then(producerMock).should().send(actualRecordCaptor.capture(), any());
ProducerRecord<String, String> actualRecord = actualRecordCaptor.getValue();
assertThat(actualRecord.topic()).isEqualTo(expectedTopic);

12
rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/metadata/TbGetTelemetryNodeTest.java

@ -219,7 +219,7 @@ public class TbGetTelemetryNodeTest extends AbstractRuleNodeUpgradeTest {
node.onMsg(ctxMock, msg);
// THEN
ArgumentCaptor<List<ReadTsKvQuery>> actualReadTsKvQueryList = ArgumentCaptor.forClass(List.class);
ArgumentCaptor<List<ReadTsKvQuery>> actualReadTsKvQueryList = ArgumentCaptor.captor();
then(timeseriesServiceMock).should().findAll(eq(TENANT_ID), eq(DEVICE_ID), actualReadTsKvQueryList.capture());
ReadTsKvQuery actualReadTsKvQuery = actualReadTsKvQueryList.getValue().get(0);
assertThat(actualReadTsKvQuery.getStartTs()).isEqualTo(startTs);
@ -246,7 +246,7 @@ public class TbGetTelemetryNodeTest extends AbstractRuleNodeUpgradeTest {
node.onMsg(ctxMock, msg);
// THEN
ArgumentCaptor<List<ReadTsKvQuery>> actualReadTsKvQueryList = ArgumentCaptor.forClass(List.class);
ArgumentCaptor<List<ReadTsKvQuery>> actualReadTsKvQueryList = ArgumentCaptor.captor();
then(timeseriesServiceMock).should().findAll(eq(TENANT_ID), eq(DEVICE_ID), actualReadTsKvQueryList.capture());
ReadTsKvQuery actualReadTsKvQuery = actualReadTsKvQueryList.getValue().get(0);
assertThat(actualReadTsKvQuery.getStartTs()).isEqualTo(ts - TimeUnit.MINUTES.toMillis(config.getStartInterval()));
@ -275,7 +275,7 @@ public class TbGetTelemetryNodeTest extends AbstractRuleNodeUpgradeTest {
node.onMsg(ctxMock, msg);
// THEN
ArgumentCaptor<List<ReadTsKvQuery>> actualReadTsKvQueryList = ArgumentCaptor.forClass(List.class);
ArgumentCaptor<List<ReadTsKvQuery>> actualReadTsKvQueryList = ArgumentCaptor.captor();
then(timeseriesServiceMock).should().findAll(eq(TENANT_ID), eq(DEVICE_ID), actualReadTsKvQueryList.capture());
List<String> actualKeys = actualReadTsKvQueryList.getValue().stream().map(TsKvQuery::getKey).toList();
assertThat(actualKeys).containsExactlyInAnyOrder("temperature", "humidity", "pressure");
@ -305,7 +305,7 @@ public class TbGetTelemetryNodeTest extends AbstractRuleNodeUpgradeTest {
node.onMsg(ctxMock, msg);
// THEN
ArgumentCaptor<List<ReadTsKvQuery>> actualReadTsKvQueryList = ArgumentCaptor.forClass(List.class);
ArgumentCaptor<List<ReadTsKvQuery>> actualReadTsKvQueryList = ArgumentCaptor.captor();
then(timeseriesServiceMock).should().findAll(eq(TENANT_ID), eq(DEVICE_ID), actualReadTsKvQueryList.capture());
ReadTsKvQuery actualReadTsKvQuery = actualReadTsKvQueryList.getValue().get(0);
aggregationStepVerifier.accept(actualReadTsKvQuery);
@ -340,7 +340,7 @@ public class TbGetTelemetryNodeTest extends AbstractRuleNodeUpgradeTest {
node.onMsg(ctxMock, msg);
// THEN
ArgumentCaptor<List<ReadTsKvQuery>> actualReadTsKvQueryList = ArgumentCaptor.forClass(List.class);
ArgumentCaptor<List<ReadTsKvQuery>> actualReadTsKvQueryList = ArgumentCaptor.captor();
then(timeseriesServiceMock).should().findAll(eq(TENANT_ID), eq(DEVICE_ID), actualReadTsKvQueryList.capture());
ReadTsKvQuery actualReadTsKvQuery = actualReadTsKvQueryList.getValue().get(0);
limitInQueryVerifier.accept(actualReadTsKvQuery);
@ -385,7 +385,7 @@ public class TbGetTelemetryNodeTest extends AbstractRuleNodeUpgradeTest {
node.onMsg(ctxMock, msg);
// THEN
ArgumentCaptor<List<ReadTsKvQuery>> actualReadTsKvQueryList = ArgumentCaptor.forClass(List.class);
ArgumentCaptor<List<ReadTsKvQuery>> actualReadTsKvQueryList = ArgumentCaptor.captor();
then(timeseriesServiceMock).should().findAll(eq(TENANT_ID), eq(DEVICE_ID), actualReadTsKvQueryList.capture());
ReadTsKvQuery actualReadTsKvQuery = actualReadTsKvQueryList.getValue().get(0);
orderInQueryVerifier.accept(actualReadTsKvQuery);

2
rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/telemetry/TbMsgDeleteAttributesNodeTest.java

@ -147,7 +147,7 @@ public class TbMsgDeleteAttributesNodeTest {
node.onMsg(ctx, msg);
ArgumentCaptor<Runnable> successCaptor = ArgumentCaptor.forClass(Runnable.class);
ArgumentCaptor<Consumer<Throwable>> failureCaptor = ArgumentCaptor.forClass(Consumer.class);
ArgumentCaptor<Consumer<Throwable>> failureCaptor = ArgumentCaptor.captor();
ArgumentCaptor<TbMsg> newMsgCaptor = ArgumentCaptor.forClass(TbMsg.class);
if (sendAttributesDeletedNotification) {

10
rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/transform/TbMsgDeduplicationNodeTest.java

@ -192,7 +192,7 @@ public class TbMsgDeduplicationNodeTest extends AbstractRuleNodeUpgradeTest {
ArgumentCaptor<TbMsg> newMsgCaptor = ArgumentCaptor.forClass(TbMsg.class);
ArgumentCaptor<Runnable> successCaptor = ArgumentCaptor.forClass(Runnable.class);
ArgumentCaptor<Consumer<Throwable>> failureCaptor = ArgumentCaptor.forClass(Consumer.class);
ArgumentCaptor<Consumer<Throwable>> failureCaptor = ArgumentCaptor.captor();
verify(ctx, times(msgCount)).ack(any());
verify(ctx, times(1)).tellFailure(eq(msgToReject), any());
@ -248,7 +248,7 @@ public class TbMsgDeduplicationNodeTest extends AbstractRuleNodeUpgradeTest {
ArgumentCaptor<TbMsg> newMsgCaptor = ArgumentCaptor.forClass(TbMsg.class);
ArgumentCaptor<Runnable> successCaptor = ArgumentCaptor.forClass(Runnable.class);
ArgumentCaptor<Consumer<Throwable>> failureCaptor = ArgumentCaptor.forClass(Consumer.class);
ArgumentCaptor<Consumer<Throwable>> failureCaptor = ArgumentCaptor.captor();
verify(ctx, times(msgCount)).ack(any());
verify(ctx, times(1)).tellFailure(eq(msgToReject), any());
@ -293,7 +293,7 @@ public class TbMsgDeduplicationNodeTest extends AbstractRuleNodeUpgradeTest {
ArgumentCaptor<TbMsg> newMsgCaptor = ArgumentCaptor.forClass(TbMsg.class);
ArgumentCaptor<Runnable> successCaptor = ArgumentCaptor.forClass(Runnable.class);
ArgumentCaptor<Consumer<Throwable>> failureCaptor = ArgumentCaptor.forClass(Consumer.class);
ArgumentCaptor<Consumer<Throwable>> failureCaptor = ArgumentCaptor.captor();
verify(ctx, times(msgCount)).ack(any());
verify(node, times(msgCount + wantedNumberOfTellSelfInvocation)).onMsg(eq(ctx), any());
@ -339,7 +339,7 @@ public class TbMsgDeduplicationNodeTest extends AbstractRuleNodeUpgradeTest {
ArgumentCaptor<TbMsg> newMsgCaptor = ArgumentCaptor.forClass(TbMsg.class);
ArgumentCaptor<Runnable> successCaptor = ArgumentCaptor.forClass(Runnable.class);
ArgumentCaptor<Consumer<Throwable>> failureCaptor = ArgumentCaptor.forClass(Consumer.class);
ArgumentCaptor<Consumer<Throwable>> failureCaptor = ArgumentCaptor.captor();
verify(ctx, times(msgCount)).ack(any());
verify(node, times(msgCount + wantedNumberOfTellSelfInvocation)).onMsg(eq(ctx), any());
@ -393,7 +393,7 @@ public class TbMsgDeduplicationNodeTest extends AbstractRuleNodeUpgradeTest {
ArgumentCaptor<TbMsg> newMsgCaptor = ArgumentCaptor.forClass(TbMsg.class);
ArgumentCaptor<Runnable> successCaptor = ArgumentCaptor.forClass(Runnable.class);
ArgumentCaptor<Consumer<Throwable>> failureCaptor = ArgumentCaptor.forClass(Consumer.class);
ArgumentCaptor<Consumer<Throwable>> failureCaptor = ArgumentCaptor.captor();
verify(ctx, times(msgCount)).ack(any());
verify(node, times(msgCount + wantedNumberOfTellSelfInvocation)).onMsg(eq(ctx), any());

2
rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/transform/TbSplitArrayMsgNodeTest.java

@ -114,7 +114,7 @@ public class TbSplitArrayMsgNodeTest {
if (dataNode.size() > 1) {
ArgumentCaptor<Runnable> successCaptor = ArgumentCaptor.forClass(Runnable.class);
ArgumentCaptor<Consumer<Throwable>> failureCaptor = ArgumentCaptor.forClass(Consumer.class);
ArgumentCaptor<Consumer<Throwable>> failureCaptor = ArgumentCaptor.captor();
verify(ctx, times(dataNode.size())).enqueueForTellNext(any(), anyString(), successCaptor.capture(), failureCaptor.capture());
for (Runnable valueCaptor : successCaptor.getAllValues()) {
valueCaptor.run();

Loading…
Cancel
Save