diff --git a/rule-engine/rule-engine-components/pom.xml b/rule-engine/rule-engine-components/pom.xml
index 224aea3137..de48596d70 100644
--- a/rule-engine/rule-engine-components/pom.xml
+++ b/rule-engine/rule-engine-components/pom.xml
@@ -138,11 +138,6 @@
spring-boot-starter-test
test
-
- org.junit.vintage
- junit-vintage-engine
- test
-
org.awaitility
awaitility
diff --git a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/action/TbCreateRelationNodeTest.java b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/action/TbCreateRelationNodeTest.java
index ec2b4a581f..5d7b92615d 100644
--- a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/action/TbCreateRelationNodeTest.java
+++ b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/action/TbCreateRelationNodeTest.java
@@ -17,12 +17,12 @@ package org.thingsboard.rule.engine.action;
import com.datastax.oss.driver.api.core.uuid.Uuids;
import com.google.common.util.concurrent.Futures;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.common.util.ListeningExecutor;
import org.thingsboard.rule.engine.TestDbCallbackExecutor;
@@ -49,13 +49,13 @@ import org.thingsboard.server.dao.relation.RelationService;
import java.util.Collections;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class TbCreateRelationNodeTest {
private TbCreateRelationNode node;
@@ -74,7 +74,7 @@ public class TbCreateRelationNodeTest {
private ListeningExecutor dbExecutor;
- @Before
+ @BeforeEach
public void before() {
dbExecutor = new TestDbCallbackExecutor();
}
diff --git a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/action/TbDeviceStateNodeTest.java b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/action/TbDeviceStateNodeTest.java
index 9352d64809..9b3d2dc29b 100644
--- a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/action/TbDeviceStateNodeTest.java
+++ b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/action/TbDeviceStateNodeTest.java
@@ -47,6 +47,7 @@ import org.thingsboard.server.common.msg.queue.TbCallback;
import org.thingsboard.server.common.msg.tools.TbRateLimits;
import java.util.UUID;
+import java.util.function.BiConsumer;
import java.util.stream.Stream;
import static org.assertj.core.api.Assertions.assertThat;
@@ -65,9 +66,9 @@ public class TbDeviceStateNodeTest {
@Mock
private TbContext ctxMock;
@Mock
- private static RuleEngineDeviceStateManager deviceStateManagerMock;
+ private RuleEngineDeviceStateManager deviceStateManagerMock;
@Captor
- private static ArgumentCaptor callbackCaptor;
+ private ArgumentCaptor callbackCaptor;
private TbDeviceStateNode node;
private TbDeviceStateNodeConfiguration config;
@@ -246,7 +247,7 @@ public class TbDeviceStateNodeTest {
@ParameterizedTest
@MethodSource
- public void givenSupportedEventAndDeviceOriginator_whenOnMsg_thenCorrectEventIsSentWithCorrectCallback(TbMsgType supportedEventType, Runnable actionVerification) {
+ public void givenSupportedEventAndDeviceOriginator_whenOnMsg_thenCorrectEventIsSentWithCorrectCallback(TbMsgType supportedEventType, BiConsumer> actionVerification) {
// GIVEN
given(ctxMock.getTenantId()).willReturn(TENANT_ID);
given(ctxMock.getDeviceStateNodeRateLimitConfig()).willReturn("1:1");
@@ -262,7 +263,7 @@ public class TbDeviceStateNodeTest {
node.onMsg(ctxMock, msg);
// THEN
- actionVerification.run();
+ actionVerification.accept(this.deviceStateManagerMock, this.callbackCaptor);
TbCallback actualCallback = callbackCaptor.getValue();
@@ -280,10 +281,10 @@ public class TbDeviceStateNodeTest {
private static Stream givenSupportedEventAndDeviceOriginator_whenOnMsg_thenCorrectEventIsSentWithCorrectCallback() {
return Stream.of(
- Arguments.of(TbMsgType.CONNECT_EVENT, (Runnable) () -> then(deviceStateManagerMock).should().onDeviceConnect(eq(TENANT_ID), eq(DEVICE_ID), eq(METADATA_TS), callbackCaptor.capture())),
- Arguments.of(TbMsgType.ACTIVITY_EVENT, (Runnable) () -> then(deviceStateManagerMock).should().onDeviceActivity(eq(TENANT_ID), eq(DEVICE_ID), eq(METADATA_TS), callbackCaptor.capture())),
- Arguments.of(TbMsgType.DISCONNECT_EVENT, (Runnable) () -> then(deviceStateManagerMock).should().onDeviceDisconnect(eq(TENANT_ID), eq(DEVICE_ID), eq(METADATA_TS), callbackCaptor.capture())),
- Arguments.of(TbMsgType.INACTIVITY_EVENT, (Runnable) () -> then(deviceStateManagerMock).should().onDeviceInactivity(eq(TENANT_ID), eq(DEVICE_ID), eq(METADATA_TS), callbackCaptor.capture()))
+ Arguments.of(TbMsgType.CONNECT_EVENT, (BiConsumer>) (deviceStateManagerMock, callbackCaptor) -> then(deviceStateManagerMock).should().onDeviceConnect(eq(TENANT_ID), eq(DEVICE_ID), eq(METADATA_TS), callbackCaptor.capture())),
+ Arguments.of(TbMsgType.ACTIVITY_EVENT, (BiConsumer>) (deviceStateManagerMock, callbackCaptor) -> then(deviceStateManagerMock).should().onDeviceActivity(eq(TENANT_ID), eq(DEVICE_ID), eq(METADATA_TS), callbackCaptor.capture())),
+ Arguments.of(TbMsgType.DISCONNECT_EVENT, (BiConsumer>) (deviceStateManagerMock, callbackCaptor) -> then(deviceStateManagerMock).should().onDeviceDisconnect(eq(TENANT_ID), eq(DEVICE_ID), eq(METADATA_TS), callbackCaptor.capture())),
+ Arguments.of(TbMsgType.INACTIVITY_EVENT, (BiConsumer>) (deviceStateManagerMock, callbackCaptor) -> then(deviceStateManagerMock).should().onDeviceInactivity(eq(TENANT_ID), eq(DEVICE_ID), eq(METADATA_TS), callbackCaptor.capture()))
);
}
diff --git a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/credentials/CertPemCredentialsTest.java b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/credentials/CertPemCredentialsTest.java
index 6aa1b02fa9..cd191c3707 100644
--- a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/credentials/CertPemCredentialsTest.java
+++ b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/credentials/CertPemCredentialsTest.java
@@ -16,8 +16,7 @@
package org.thingsboard.rule.engine.credentials;
import org.apache.commons.io.FileUtils;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
@@ -49,14 +48,14 @@ public class CertPemCredentialsTest {
List x509Certificates = SslUtil.readCertFile(fileContent);
- Assert.assertEquals(4, x509Certificates.size());
- Assert.assertEquals("CN=*.thingsboard.cloud, O=\"ThingsBoard, Inc.\", ST=New York, C=US",
+ Assertions.assertEquals(4, x509Certificates.size());
+ Assertions.assertEquals("CN=*.thingsboard.cloud, O=\"ThingsBoard, Inc.\", ST=New York, C=US",
x509Certificates.get(0).getSubjectDN().getName());
- Assert.assertEquals("CN=Sectigo ECC Organization Validation Secure Server CA, O=Sectigo Limited, L=Salford, ST=Greater Manchester, C=GB",
+ Assertions.assertEquals("CN=Sectigo ECC Organization Validation Secure Server CA, O=Sectigo Limited, L=Salford, ST=Greater Manchester, C=GB",
x509Certificates.get(1).getSubjectDN().getName());
- Assert.assertEquals("CN=USERTrust ECC Certification Authority, O=The USERTRUST Network, L=Jersey City, ST=New Jersey, C=US",
+ Assertions.assertEquals("CN=USERTrust ECC Certification Authority, O=The USERTRUST Network, L=Jersey City, ST=New Jersey, C=US",
x509Certificates.get(2).getSubjectDN().getName());
- Assert.assertEquals("CN=AAA Certificate Services, O=Comodo CA Limited, L=Salford, ST=Greater Manchester, C=GB",
+ Assertions.assertEquals("CN=AAA Certificate Services, O=Comodo CA Limited, L=Salford, ST=Greater Manchester, C=GB",
x509Certificates.get(3).getSubjectDN().getName());
}
@@ -66,8 +65,8 @@ public class CertPemCredentialsTest {
List x509Certificates = SslUtil.readCertFile(fileContent);
- Assert.assertEquals(1, x509Certificates.size());
- Assert.assertEquals("CN=*.thingsboard.cloud, O=\"ThingsBoard, Inc.\", ST=New York, C=US",
+ Assertions.assertEquals(1, x509Certificates.size());
+ Assertions.assertEquals("CN=*.thingsboard.cloud, O=\"ThingsBoard, Inc.\", ST=New York, C=US",
x509Certificates.get(0).getSubjectDN().getName());
}
@@ -77,7 +76,7 @@ public class CertPemCredentialsTest {
List x509Certificates = SslUtil.readCertFile(fileContent);
- Assert.assertEquals(0, x509Certificates.size());
+ Assertions.assertEquals(0, x509Certificates.size());
}
private static Stream testLoadKeyStore() {
diff --git a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/edge/TbMsgPushToEdgeNodeTest.java b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/edge/TbMsgPushToEdgeNodeTest.java
index 5f57f7f5e3..b8a70991bc 100644
--- a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/edge/TbMsgPushToEdgeNodeTest.java
+++ b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/edge/TbMsgPushToEdgeNodeTest.java
@@ -16,13 +16,13 @@
package org.thingsboard.rule.engine.edge;
import com.google.common.util.concurrent.SettableFuture;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentMatcher;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.common.util.ListeningExecutor;
import org.thingsboard.rule.engine.api.TbContext;
@@ -50,7 +50,7 @@ import java.util.UUID;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class TbMsgPushToEdgeNodeTest {
private static final List MISC_EVENTS = List.of(TbMsgType.CONNECT_EVENT, TbMsgType.DISCONNECT_EVENT,
@@ -71,7 +71,7 @@ public class TbMsgPushToEdgeNodeTest {
@Mock
private ListeningExecutor dbCallbackExecutor;
- @Before
+ @BeforeEach
public void setUp() throws TbNodeException {
node = new TbMsgPushToEdgeNode();
TbMsgPushToEdgeNodeConfiguration config = new TbMsgPushToEdgeNodeConfiguration().defaultConfiguration();
diff --git a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/filter/TbJsFilterNodeTest.java b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/filter/TbJsFilterNodeTest.java
index 903944025a..b991b7b220 100644
--- a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/filter/TbJsFilterNodeTest.java
+++ b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/filter/TbJsFilterNodeTest.java
@@ -17,11 +17,11 @@ package org.thingsboard.rule.engine.filter;
import com.datastax.oss.driver.api.core.uuid.Uuids;
import com.google.common.util.concurrent.Futures;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.rule.engine.api.ScriptEngine;
import org.thingsboard.rule.engine.api.TbContext;
@@ -38,12 +38,12 @@ import org.thingsboard.server.common.msg.TbMsgMetaData;
import javax.script.ScriptException;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.same;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class TbJsFilterNodeTest {
private TbJsFilterNode node;
diff --git a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/filter/TbJsSwitchNodeTest.java b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/filter/TbJsSwitchNodeTest.java
index d679e42ba0..ff7a40644b 100644
--- a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/filter/TbJsSwitchNodeTest.java
+++ b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/filter/TbJsSwitchNodeTest.java
@@ -18,10 +18,10 @@ package org.thingsboard.rule.engine.filter;
import com.datastax.oss.driver.api.core.uuid.Uuids;
import com.google.common.collect.Sets;
import com.google.common.util.concurrent.Futures;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.rule.engine.api.ScriptEngine;
import org.thingsboard.rule.engine.api.TbContext;
@@ -38,7 +38,7 @@ import org.thingsboard.server.common.msg.TbMsgMetaData;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class TbJsSwitchNodeTest {
private TbJsSwitchNode node;
diff --git a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/geo/GeoUtilTest.java b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/geo/GeoUtilTest.java
index 2172288236..8d39105d30 100644
--- a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/geo/GeoUtilTest.java
+++ b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/geo/GeoUtilTest.java
@@ -15,12 +15,12 @@
*/
package org.thingsboard.rule.engine.geo;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class GeoUtilTest {
public static final String SIMPLE_RECT = "[[51.903762928405555,23.642220786948297],[44.669801219635644,41.83345155830211]]";
@@ -47,117 +47,117 @@ public class GeoUtilTest {
@Test
public void testPointsInSimplePolygons() {
- Assert.assertTrue("Polygon " + SIMPLE_RECT + " must contain the dot " + POINT_INSIDE_SIMPLE_RECT_CENTER,
- GeoUtil.contains(SIMPLE_RECT, POINT_INSIDE_SIMPLE_RECT_CENTER)
- );
- Assert.assertTrue("Polygon " + SIMPLE_RECT + " must contain the dot " + POINT_INSIDE_SIMPLE_RECT_NEAR_BORDER,
- GeoUtil.contains(SIMPLE_RECT, POINT_INSIDE_SIMPLE_RECT_NEAR_BORDER)
- );
- Assert.assertTrue("Polygon " + SIMPLE_RECT_WITH_HOLE_IN_CENTER + " must contain the dot "
- + POINT_INSIDE_SIMPLE_RECT_NEAR_BORDER,
- GeoUtil.contains(SIMPLE_RECT_WITH_HOLE_IN_CENTER, POINT_INSIDE_SIMPLE_RECT_NEAR_BORDER)
- );
+ Assertions.assertTrue(GeoUtil.contains(SIMPLE_RECT, POINT_INSIDE_SIMPLE_RECT_CENTER),
+ "Polygon " + SIMPLE_RECT + " must contain the dot " + POINT_INSIDE_SIMPLE_RECT_CENTER
+ );
+ Assertions.assertTrue(GeoUtil.contains(SIMPLE_RECT, POINT_INSIDE_SIMPLE_RECT_NEAR_BORDER),
+ "Polygon " + SIMPLE_RECT + " must contain the dot " + POINT_INSIDE_SIMPLE_RECT_NEAR_BORDER
+ );
+ Assertions.assertTrue(GeoUtil.contains(SIMPLE_RECT_WITH_HOLE_IN_CENTER, POINT_INSIDE_SIMPLE_RECT_NEAR_BORDER),
+ "Polygon " + SIMPLE_RECT_WITH_HOLE_IN_CENTER + " must contain the dot "
+ + POINT_INSIDE_SIMPLE_RECT_NEAR_BORDER
+ );
- Assert.assertFalse("Polygon " + SIMPLE_RECT + " must not contain the dot "
- + POINT_OUTSIDE_SIMPLE_RECT,
- GeoUtil.contains(SIMPLE_RECT, POINT_OUTSIDE_SIMPLE_RECT)
- );
- Assert.assertFalse("Polygon " + SIMPLE_RECT_WITH_HOLE_IN_CENTER + " must not contain the dot "
- + POINT_OUTSIDE_SIMPLE_RECT,
- GeoUtil.contains(SIMPLE_RECT_WITH_HOLE_IN_CENTER, POINT_OUTSIDE_SIMPLE_RECT)
- );
- Assert.assertFalse("Polygon " + SIMPLE_RECT_WITH_HOLE_IN_CENTER + " must not contain the dot "
- + POINT_INSIDE_SIMPLE_RECT_CENTER,
- GeoUtil.contains(SIMPLE_RECT_WITH_HOLE_IN_CENTER, POINT_INSIDE_SIMPLE_RECT_CENTER)
- );
+ Assertions.assertFalse(GeoUtil.contains(SIMPLE_RECT, POINT_OUTSIDE_SIMPLE_RECT),
+ "Polygon " + SIMPLE_RECT + " must not contain the dot "
+ + POINT_OUTSIDE_SIMPLE_RECT
+ );
+ Assertions.assertFalse(GeoUtil.contains(SIMPLE_RECT_WITH_HOLE_IN_CENTER, POINT_OUTSIDE_SIMPLE_RECT),
+ "Polygon " + SIMPLE_RECT_WITH_HOLE_IN_CENTER + " must not contain the dot "
+ + POINT_OUTSIDE_SIMPLE_RECT
+ );
+ Assertions.assertFalse(GeoUtil.contains(SIMPLE_RECT_WITH_HOLE_IN_CENTER, POINT_INSIDE_SIMPLE_RECT_CENTER),
+ "Polygon " + SIMPLE_RECT_WITH_HOLE_IN_CENTER + " must not contain the dot "
+ + POINT_INSIDE_SIMPLE_RECT_CENTER
+ );
}
@Test
public void testPointsInComplexPolygons() {
- Assert.assertTrue("Polygon " + SAND_CLOCK + " must contain the dot " + POINT_INSIDE_SAND_CLOCK_CENTER,
- GeoUtil.contains(SAND_CLOCK, POINT_INSIDE_SAND_CLOCK_CENTER)
- );
- Assert.assertTrue("Polygon " + SAND_CLOCK + " must contain the dot " + POINT_INSIDE_SAND_CLOCK_NEAR_BORDER,
- GeoUtil.contains(SAND_CLOCK, POINT_INSIDE_SAND_CLOCK_NEAR_BORDER)
- );
- Assert.assertTrue("Polygon " + SAND_CLOCK_WITH_HOLE_IN_CENTER + " must contain the dot "
- + POINT_INSIDE_SAND_CLOCK_NEAR_BORDER,
- GeoUtil.contains(SAND_CLOCK_WITH_HOLE_IN_CENTER, POINT_INSIDE_SAND_CLOCK_NEAR_BORDER)
- );
+ Assertions.assertTrue(GeoUtil.contains(SAND_CLOCK, POINT_INSIDE_SAND_CLOCK_CENTER),
+ "Polygon " + SAND_CLOCK + " must contain the dot " + POINT_INSIDE_SAND_CLOCK_CENTER
+ );
+ Assertions.assertTrue(GeoUtil.contains(SAND_CLOCK, POINT_INSIDE_SAND_CLOCK_NEAR_BORDER),
+ "Polygon " + SAND_CLOCK + " must contain the dot " + POINT_INSIDE_SAND_CLOCK_NEAR_BORDER
+ );
+ Assertions.assertTrue(GeoUtil.contains(SAND_CLOCK_WITH_HOLE_IN_CENTER, POINT_INSIDE_SAND_CLOCK_NEAR_BORDER),
+ "Polygon " + SAND_CLOCK_WITH_HOLE_IN_CENTER + " must contain the dot "
+ + POINT_INSIDE_SAND_CLOCK_NEAR_BORDER
+ );
- Assert.assertFalse("Polygon " + SAND_CLOCK + " must not contain the dot "
- + POINT_OUTSIDE_SAND_CLOCK_1,
- GeoUtil.contains(SAND_CLOCK, POINT_OUTSIDE_SAND_CLOCK_1)
- );
- Assert.assertFalse("Polygon " + SAND_CLOCK + " must not contain the dot "
- + POINT_OUTSIDE_SAND_CLOCK_2,
- GeoUtil.contains(SAND_CLOCK, POINT_OUTSIDE_SAND_CLOCK_2)
- );
- Assert.assertFalse("Polygon " + SAND_CLOCK_WITH_HOLE_IN_CENTER + " must not contain the dot "
- + POINT_INSIDE_SAND_CLOCK_CENTER,
- GeoUtil.contains(SAND_CLOCK_WITH_HOLE_IN_CENTER, POINT_INSIDE_SAND_CLOCK_CENTER)
- );
- Assert.assertFalse("Polygon " + SAND_CLOCK_WITH_HOLE_IN_CENTER + " must not contain the dot "
- + POINT_OUTSIDE_SAND_CLOCK_1,
- GeoUtil.contains(SAND_CLOCK_WITH_HOLE_IN_CENTER, POINT_OUTSIDE_SAND_CLOCK_1)
- );
- Assert.assertFalse("Polygon " + SAND_CLOCK_WITH_HOLE_IN_CENTER + " must not contain the dot "
- + POINT_OUTSIDE_SAND_CLOCK_2,
- GeoUtil.contains(SAND_CLOCK_WITH_HOLE_IN_CENTER, POINT_OUTSIDE_SAND_CLOCK_2)
- );
+ Assertions.assertFalse(GeoUtil.contains(SAND_CLOCK, POINT_OUTSIDE_SAND_CLOCK_1),
+ "Polygon " + SAND_CLOCK + " must not contain the dot "
+ + POINT_OUTSIDE_SAND_CLOCK_1
+ );
+ Assertions.assertFalse(GeoUtil.contains(SAND_CLOCK, POINT_OUTSIDE_SAND_CLOCK_2),
+ "Polygon " + SAND_CLOCK + " must not contain the dot "
+ + POINT_OUTSIDE_SAND_CLOCK_2
+ );
+ Assertions.assertFalse(GeoUtil.contains(SAND_CLOCK_WITH_HOLE_IN_CENTER, POINT_INSIDE_SAND_CLOCK_CENTER),
+ "Polygon " + SAND_CLOCK_WITH_HOLE_IN_CENTER + " must not contain the dot "
+ + POINT_INSIDE_SAND_CLOCK_CENTER
+ );
+ Assertions.assertFalse(GeoUtil.contains(SAND_CLOCK_WITH_HOLE_IN_CENTER, POINT_OUTSIDE_SAND_CLOCK_1),
+ "Polygon " + SAND_CLOCK_WITH_HOLE_IN_CENTER + " must not contain the dot "
+ + POINT_OUTSIDE_SAND_CLOCK_1
+ );
+ Assertions.assertFalse(GeoUtil.contains(SAND_CLOCK_WITH_HOLE_IN_CENTER, POINT_OUTSIDE_SAND_CLOCK_2),
+ "Polygon " + SAND_CLOCK_WITH_HOLE_IN_CENTER + " must not contain the dot "
+ + POINT_OUTSIDE_SAND_CLOCK_2
+ );
}
@Test
public void testPointsInSelfIntersectingPolygons() {
- Assert.assertTrue("Polygon " + SELF_INTERSECTING + " must contain the dot "
- + POINT_INSIDE_SELF_INTERSECTING_UPPER_CENTER,
- GeoUtil.contains(SELF_INTERSECTING, POINT_INSIDE_SELF_INTERSECTING_UPPER_CENTER)
- );
- Assert.assertTrue("Polygon " + SELF_INTERSECTING + " must contain the dot "
- + POINT_INSIDE_SELF_INTERSECTING_LOWER_CENTER,
- GeoUtil.contains(SELF_INTERSECTING, POINT_INSIDE_SELF_INTERSECTING_LOWER_CENTER)
- );
- Assert.assertTrue("Polygon " + SELF_INTERSECTING + " must contain the dot "
- + POINT_INSIDE_SELF_INTERSECTING_NEAR_BORDER,
- GeoUtil.contains(SELF_INTERSECTING, POINT_INSIDE_SELF_INTERSECTING_NEAR_BORDER)
- );
- Assert.assertTrue("Polygon " + SELF_INTERSECTING_WITH_HOLES + " must contain the dot "
- + POINT_INSIDE_SAND_CLOCK_NEAR_BORDER,
- GeoUtil.contains(SELF_INTERSECTING_WITH_HOLES, POINT_INSIDE_SELF_INTERSECTING_NEAR_BORDER)
- );
+ Assertions.assertTrue(GeoUtil.contains(SELF_INTERSECTING, POINT_INSIDE_SELF_INTERSECTING_UPPER_CENTER),
+ "Polygon " + SELF_INTERSECTING + " must contain the dot "
+ + POINT_INSIDE_SELF_INTERSECTING_UPPER_CENTER
+ );
+ Assertions.assertTrue(GeoUtil.contains(SELF_INTERSECTING, POINT_INSIDE_SELF_INTERSECTING_LOWER_CENTER),
+ "Polygon " + SELF_INTERSECTING + " must contain the dot "
+ + POINT_INSIDE_SELF_INTERSECTING_LOWER_CENTER
+ );
+ Assertions.assertTrue(GeoUtil.contains(SELF_INTERSECTING, POINT_INSIDE_SELF_INTERSECTING_NEAR_BORDER),
+ "Polygon " + SELF_INTERSECTING + " must contain the dot "
+ + POINT_INSIDE_SELF_INTERSECTING_NEAR_BORDER
+ );
+ Assertions.assertTrue(GeoUtil.contains(SELF_INTERSECTING_WITH_HOLES, POINT_INSIDE_SELF_INTERSECTING_NEAR_BORDER),
+ "Polygon " + SELF_INTERSECTING_WITH_HOLES + " must contain the dot "
+ + POINT_INSIDE_SAND_CLOCK_NEAR_BORDER
+ );
- Assert.assertFalse("Polygon " + SELF_INTERSECTING + " must not contain the dot "
- + POINT_OUTSIDE_SELF_INTERSECTING_1,
- GeoUtil.contains(SELF_INTERSECTING, POINT_OUTSIDE_SELF_INTERSECTING_1)
- );
- Assert.assertFalse("Polygon " + SELF_INTERSECTING + " must not contain the dot "
- + POINT_OUTSIDE_SELF_INTERSECTING_2,
- GeoUtil.contains(SELF_INTERSECTING, POINT_OUTSIDE_SELF_INTERSECTING_2)
- );
- Assert.assertFalse("Polygon " + SELF_INTERSECTING + " must not contain the dot "
- + POINT_OUTSIDE_SELF_INTERSECTING_3,
- GeoUtil.contains(SELF_INTERSECTING, POINT_OUTSIDE_SELF_INTERSECTING_3)
- );
- Assert.assertFalse("Polygon " + SELF_INTERSECTING_WITH_HOLES + " must not contain the dot "
- + POINT_OUTSIDE_SELF_INTERSECTING_1,
- GeoUtil.contains(SELF_INTERSECTING_WITH_HOLES, POINT_OUTSIDE_SELF_INTERSECTING_1)
- );
- Assert.assertFalse("Polygon " + SELF_INTERSECTING_WITH_HOLES + " must not contain the dot "
- + POINT_OUTSIDE_SELF_INTERSECTING_2,
- GeoUtil.contains(SELF_INTERSECTING_WITH_HOLES, POINT_OUTSIDE_SELF_INTERSECTING_2)
- );
- Assert.assertFalse("Polygon " + SELF_INTERSECTING_WITH_HOLES + " must not contain the dot "
- + POINT_OUTSIDE_SELF_INTERSECTING_3,
- GeoUtil.contains(SELF_INTERSECTING_WITH_HOLES, POINT_OUTSIDE_SELF_INTERSECTING_3)
- );
- Assert.assertFalse("Polygon " + SELF_INTERSECTING_WITH_HOLES + " must not contain the dot "
- + POINT_INSIDE_SELF_INTERSECTING_UPPER_CENTER,
- GeoUtil.contains(SELF_INTERSECTING_WITH_HOLES, POINT_INSIDE_SELF_INTERSECTING_UPPER_CENTER)
- );
- Assert.assertFalse("Polygon " + SELF_INTERSECTING_WITH_HOLES + " must not contain the dot "
- + POINT_INSIDE_SELF_INTERSECTING_LOWER_CENTER,
- GeoUtil.contains(SELF_INTERSECTING_WITH_HOLES, POINT_INSIDE_SELF_INTERSECTING_LOWER_CENTER)
- );
+ Assertions.assertFalse(GeoUtil.contains(SELF_INTERSECTING, POINT_OUTSIDE_SELF_INTERSECTING_1),
+ "Polygon " + SELF_INTERSECTING + " must not contain the dot "
+ + POINT_OUTSIDE_SELF_INTERSECTING_1
+ );
+ Assertions.assertFalse(GeoUtil.contains(SELF_INTERSECTING, POINT_OUTSIDE_SELF_INTERSECTING_2),
+ "Polygon " + SELF_INTERSECTING + " must not contain the dot "
+ + POINT_OUTSIDE_SELF_INTERSECTING_2
+ );
+ Assertions.assertFalse(GeoUtil.contains(SELF_INTERSECTING, POINT_OUTSIDE_SELF_INTERSECTING_3),
+ "Polygon " + SELF_INTERSECTING + " must not contain the dot "
+ + POINT_OUTSIDE_SELF_INTERSECTING_3
+ );
+ Assertions.assertFalse(GeoUtil.contains(SELF_INTERSECTING_WITH_HOLES, POINT_OUTSIDE_SELF_INTERSECTING_1),
+ "Polygon " + SELF_INTERSECTING_WITH_HOLES + " must not contain the dot "
+ + POINT_OUTSIDE_SELF_INTERSECTING_1
+ );
+ Assertions.assertFalse(GeoUtil.contains(SELF_INTERSECTING_WITH_HOLES, POINT_OUTSIDE_SELF_INTERSECTING_2),
+ "Polygon " + SELF_INTERSECTING_WITH_HOLES + " must not contain the dot "
+ + POINT_OUTSIDE_SELF_INTERSECTING_2
+ );
+ Assertions.assertFalse(GeoUtil.contains(SELF_INTERSECTING_WITH_HOLES, POINT_OUTSIDE_SELF_INTERSECTING_3),
+ "Polygon " + SELF_INTERSECTING_WITH_HOLES + " must not contain the dot "
+ + POINT_OUTSIDE_SELF_INTERSECTING_3
+ );
+ Assertions.assertFalse(GeoUtil.contains(SELF_INTERSECTING_WITH_HOLES, POINT_INSIDE_SELF_INTERSECTING_UPPER_CENTER),
+ "Polygon " + SELF_INTERSECTING_WITH_HOLES + " must not contain the dot "
+ + POINT_INSIDE_SELF_INTERSECTING_UPPER_CENTER
+ );
+ Assertions.assertFalse(GeoUtil.contains(SELF_INTERSECTING_WITH_HOLES, POINT_INSIDE_SELF_INTERSECTING_LOWER_CENTER),
+ "Polygon " + SELF_INTERSECTING_WITH_HOLES + " must not contain the dot "
+ + POINT_INSIDE_SELF_INTERSECTING_LOWER_CENTER
+ );
}
}
diff --git a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/math/TbMathArgumentValueTest.java b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/math/TbMathArgumentValueTest.java
index 5a6fffbb18..073a9fb393 100644
--- a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/math/TbMathArgumentValueTest.java
+++ b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/math/TbMathArgumentValueTest.java
@@ -16,8 +16,8 @@
package org.thingsboard.rule.engine.math;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.server.common.msg.TbMsgMetaData;
@@ -32,7 +32,7 @@ public class TbMathArgumentValueTest {
TbMathArgument tbMathArgument = new TbMathArgument(TbMathArgumentType.MESSAGE_BODY, "TestKey");
tbMathArgument.setDefaultValue(5.0);
TbMathArgumentValue result = TbMathArgumentValue.fromMessageBody(tbMathArgument, tbMathArgument.getKey(), Optional.ofNullable(JacksonUtil.newObjectNode()));
- Assert.assertEquals(5.0, result.getValue(), 0d);
+ Assertions.assertEquals(5.0, result.getValue(), 0d);
}
@Test
@@ -41,14 +41,14 @@ public class TbMathArgumentValueTest {
Throwable thrown = assertThrows(RuntimeException.class, () -> {
TbMathArgumentValue result = TbMathArgumentValue.fromMessageBody(tbMathArgument, tbMathArgument.getKey(), Optional.empty());
});
- Assert.assertNotNull(thrown.getMessage());
+ Assertions.assertNotNull(thrown.getMessage());
}
@Test
public void test_fromMessageBody_then_noKey() {
TbMathArgument tbMathArgument = new TbMathArgument(TbMathArgumentType.MESSAGE_BODY, "TestKey");
Throwable thrown = assertThrows(RuntimeException.class, () -> TbMathArgumentValue.fromMessageBody(tbMathArgument, tbMathArgument.getKey(), Optional.ofNullable(JacksonUtil.newObjectNode())));
- Assert.assertNotNull(thrown.getMessage());
+ Assertions.assertNotNull(thrown.getMessage());
}
@Test
@@ -59,12 +59,12 @@ public class TbMathArgumentValueTest {
//null value
Throwable thrown = assertThrows(RuntimeException.class, () -> TbMathArgumentValue.fromMessageBody(tbMathArgument, tbMathArgument.getKey(), Optional.of(msgData)));
- Assert.assertNotNull(thrown.getMessage());
+ Assertions.assertNotNull(thrown.getMessage());
//empty value
msgData.put("TestKey", "");
thrown = assertThrows(RuntimeException.class, () -> TbMathArgumentValue.fromMessageBody(tbMathArgument, tbMathArgument.getKey(), Optional.of(msgData)));
- Assert.assertNotNull(thrown.getMessage());
+ Assertions.assertNotNull(thrown.getMessage());
}
@Test
@@ -75,40 +75,40 @@ public class TbMathArgumentValueTest {
//string value
Throwable thrown = assertThrows(RuntimeException.class, () -> TbMathArgumentValue.fromMessageBody(tbMathArgument, tbMathArgument.getKey(), Optional.of(msgData)));
- Assert.assertNotNull(thrown.getMessage());
+ Assertions.assertNotNull(thrown.getMessage());
//object value
msgData.set("TestKey", JacksonUtil.newObjectNode());
thrown = assertThrows(RuntimeException.class, () -> TbMathArgumentValue.fromMessageBody(tbMathArgument, tbMathArgument.getKey(), Optional.of(msgData)));
- Assert.assertNotNull(thrown.getMessage());
+ Assertions.assertNotNull(thrown.getMessage());
}
@Test
public void test_fromMessageMetadata_then_noKey() {
TbMathArgument tbMathArgument = new TbMathArgument(TbMathArgumentType.MESSAGE_BODY, "TestKey");
Throwable thrown = assertThrows(RuntimeException.class, () -> TbMathArgumentValue.fromMessageMetadata(tbMathArgument, tbMathArgument.getKey(), new TbMsgMetaData()));
- Assert.assertNotNull(thrown.getMessage());
+ Assertions.assertNotNull(thrown.getMessage());
}
@Test
public void test_fromMessageMetadata_then_valueEmpty() {
TbMathArgument tbMathArgument = new TbMathArgument(TbMathArgumentType.MESSAGE_BODY, "TestKey");
Throwable thrown = assertThrows(RuntimeException.class, () -> TbMathArgumentValue.fromMessageMetadata(tbMathArgument, tbMathArgument.getKey(), null));
- Assert.assertNotNull(thrown.getMessage());
+ Assertions.assertNotNull(thrown.getMessage());
}
@Test
public void test_fromString_thenOK() {
var value = "5.0";
TbMathArgumentValue result = TbMathArgumentValue.fromString(value);
- Assert.assertNotNull(result);
- Assert.assertEquals(5.0, result.getValue(), 0d);
+ Assertions.assertNotNull(result);
+ Assertions.assertEquals(5.0, result.getValue(), 0d);
}
@Test
public void test_fromString_then_failure() {
var value = "Test";
Throwable thrown = assertThrows(RuntimeException.class, () -> TbMathArgumentValue.fromString(value));
- Assert.assertNotNull(thrown.getMessage());
+ Assertions.assertNotNull(thrown.getMessage());
}
}
diff --git a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/metadata/TbGetAttributesNodeTest.java b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/metadata/TbGetAttributesNodeTest.java
index 26b9c9a30d..9eb74b5627 100644
--- a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/metadata/TbGetAttributesNodeTest.java
+++ b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/metadata/TbGetAttributesNodeTest.java
@@ -18,14 +18,14 @@ package org.thingsboard.rule.engine.metadata;
import com.datastax.oss.driver.api.core.uuid.Uuids;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.util.concurrent.Futures;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.thingsboard.common.util.AbstractListeningExecutor;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.rule.engine.api.TbContext;
@@ -33,7 +33,6 @@ import org.thingsboard.rule.engine.api.TbNodeConfiguration;
import org.thingsboard.rule.engine.api.TbNodeException;
import org.thingsboard.rule.engine.util.TbMsgSource;
import org.thingsboard.server.common.data.AttributeScope;
-import org.thingsboard.server.common.data.DataConstants;
import org.thingsboard.server.common.data.id.DeviceId;
import org.thingsboard.server.common.data.id.EntityId;
import org.thingsboard.server.common.data.id.TenantId;
@@ -55,17 +54,18 @@ import java.util.List;
import java.util.stream.Collectors;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class TbGetAttributesNodeTest {
private static final EntityId ORIGINATOR = new DeviceId(Uuids.timeBased());
@@ -86,7 +86,7 @@ public class TbGetAttributesNodeTest {
private long ts;
private TbGetAttributesNode node;
- @Before
+ @BeforeEach
public void before() throws TbNodeException {
dbExecutor = new AbstractListeningExecutor() {
@Override
@@ -96,10 +96,10 @@ public class TbGetAttributesNodeTest {
};
dbExecutor.init();
- when(ctxMock.getAttributesService()).thenReturn(attributesServiceMock);
- when(ctxMock.getTimeseriesService()).thenReturn(timeseriesServiceMock);
- when(ctxMock.getTenantId()).thenReturn(TENANT_ID);
- when(ctxMock.getDbCallbackExecutor()).thenReturn(dbExecutor);
+ lenient().when(ctxMock.getAttributesService()).thenReturn(attributesServiceMock);
+ lenient().when(ctxMock.getTimeseriesService()).thenReturn(timeseriesServiceMock);
+ lenient().when(ctxMock.getTenantId()).thenReturn(TENANT_ID);
+ lenient().when(ctxMock.getDbCallbackExecutor()).thenReturn(dbExecutor);
clientAttributes = getAttributeNames("client");
serverAttributes = getAttributeNames("server");
@@ -107,20 +107,20 @@ public class TbGetAttributesNodeTest {
tsKeys = List.of("temperature", "humidity", "unknown");
ts = System.currentTimeMillis();
- when(attributesServiceMock.find(TENANT_ID, ORIGINATOR, AttributeScope.CLIENT_SCOPE, clientAttributes))
+ lenient().when(attributesServiceMock.find(TENANT_ID, ORIGINATOR, AttributeScope.CLIENT_SCOPE, clientAttributes))
.thenReturn(Futures.immediateFuture(getListAttributeKvEntry(clientAttributes, ts)));
- when(attributesServiceMock.find(TENANT_ID, ORIGINATOR, AttributeScope.SERVER_SCOPE, serverAttributes))
+ lenient().when(attributesServiceMock.find(TENANT_ID, ORIGINATOR, AttributeScope.SERVER_SCOPE, serverAttributes))
.thenReturn(Futures.immediateFuture(getListAttributeKvEntry(serverAttributes, ts)));
- when(attributesServiceMock.find(TENANT_ID, ORIGINATOR, AttributeScope.SHARED_SCOPE, sharedAttributes))
+ lenient().when(attributesServiceMock.find(TENANT_ID, ORIGINATOR, AttributeScope.SHARED_SCOPE, sharedAttributes))
.thenReturn(Futures.immediateFuture(getListAttributeKvEntry(sharedAttributes, ts)));
- when(timeseriesServiceMock.findLatest(TENANT_ID, ORIGINATOR, tsKeys))
+ lenient().when(timeseriesServiceMock.findLatest(TENANT_ID, ORIGINATOR, tsKeys))
.thenReturn(Futures.immediateFuture(getListTsKvEntry(tsKeys, ts)));
}
- @After
+ @AfterEach
public void after() {
dbExecutor.destroy();
}
diff --git a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/metadata/TbGetDeviceAttrNodeTest.java b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/metadata/TbGetDeviceAttrNodeTest.java
index f40ab2bed8..ac6bb38be5 100644
--- a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/metadata/TbGetDeviceAttrNodeTest.java
+++ b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/metadata/TbGetDeviceAttrNodeTest.java
@@ -16,7 +16,7 @@
package org.thingsboard.rule.engine.metadata;
import com.fasterxml.jackson.databind.JsonNode;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.server.common.data.util.TbPair;
diff --git a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/metadata/TbGetTelemetryNodeTest.java b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/metadata/TbGetTelemetryNodeTest.java
index 990688611e..6ecd1b6eb9 100644
--- a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/metadata/TbGetTelemetryNodeTest.java
+++ b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/metadata/TbGetTelemetryNodeTest.java
@@ -15,8 +15,8 @@
*/
package org.thingsboard.rule.engine.metadata;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.rule.engine.api.TbContext;
@@ -37,7 +37,7 @@ public class TbGetTelemetryNodeTest {
TbNodeConfiguration nodeConfiguration;
TbContext ctx;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
ctx = mock(TbContext.class);
node = spy(new TbGetTelemetryNode());
diff --git a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/profile/AlarmStateTest.java b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/profile/AlarmStateTest.java
index 7cc6781abb..08d445b89d 100644
--- a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/profile/AlarmStateTest.java
+++ b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/profile/AlarmStateTest.java
@@ -15,7 +15,7 @@
*/
package org.thingsboard.rule.engine.profile;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.thingsboard.server.common.data.DataConstants;
import org.thingsboard.server.common.data.device.profile.AlarmCondition;
import org.thingsboard.server.common.data.device.profile.AlarmConditionSpec;
@@ -28,9 +28,9 @@ import org.thingsboard.server.common.msg.TbMsgMetaData;
import java.util.concurrent.TimeUnit;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.mock;
public class AlarmStateTest {
diff --git a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/profile/DeviceStateTest.java b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/profile/DeviceStateTest.java
index 0d2002661f..5cee1aa5b3 100644
--- a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/profile/DeviceStateTest.java
+++ b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/profile/DeviceStateTest.java
@@ -16,8 +16,8 @@
package org.thingsboard.rule.engine.profile;
import com.google.common.util.concurrent.Futures;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.rule.engine.api.RuleEngineAlarmService;
@@ -69,7 +69,7 @@ public class DeviceStateTest {
private TbContext ctx;
- @Before
+ @BeforeEach
public void beforeEach() {
ctx = mock(TbContext.class);
diff --git a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/profile/TbDeviceProfileNodeTest.java b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/profile/TbDeviceProfileNodeTest.java
index 645613f553..19eabf0bdc 100644
--- a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/profile/TbDeviceProfileNodeTest.java
+++ b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/profile/TbDeviceProfileNodeTest.java
@@ -18,11 +18,11 @@ package org.thingsboard.rule.engine.profile;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.rule.engine.api.RuleEngineAlarmService;
import org.thingsboard.rule.engine.api.RuleEngineDeviceProfileCache;
@@ -86,7 +86,7 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class TbDeviceProfileNodeTest {
private TbDeviceProfileNode node;
@@ -1700,10 +1700,10 @@ public class TbDeviceProfileNodeTest {
private void init() throws TbNodeException {
Mockito.when(ctx.getTenantId()).thenReturn(tenantId);
Mockito.when(ctx.getDeviceProfileCache()).thenReturn(cache);
- Mockito.when(ctx.getTimeseriesService()).thenReturn(timeseriesService);
- Mockito.when(ctx.getAlarmService()).thenReturn(alarmService);
+ Mockito.lenient().when(ctx.getTimeseriesService()).thenReturn(timeseriesService);
+ Mockito.lenient().when(ctx.getAlarmService()).thenReturn(alarmService);
Mockito.when(ctx.getDeviceService()).thenReturn(deviceService);
- Mockito.when(ctx.getAttributesService()).thenReturn(attributesService);
+ Mockito.lenient().when(ctx.getAttributesService()).thenReturn(attributesService);
TbNodeConfiguration nodeConfiguration = new TbNodeConfiguration(JacksonUtil.newObjectNode());
node = new TbDeviceProfileNode();
node.init(ctx, nodeConfiguration);
diff --git a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/rest/TbRestApiCallNodeTest.java b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/rest/TbRestApiCallNodeTest.java
index 78c68a24be..98695c1570 100644
--- a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/rest/TbRestApiCallNodeTest.java
+++ b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/rest/TbRestApiCallNodeTest.java
@@ -25,13 +25,13 @@ import org.apache.http.impl.bootstrap.HttpServer;
import org.apache.http.impl.bootstrap.ServerBootstrap;
import org.apache.http.protocol.HttpContext;
import org.apache.http.protocol.HttpRequestHandler;
-import org.junit.After;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.rule.engine.api.TbContext;
import org.thingsboard.rule.engine.api.TbNodeConfiguration;
@@ -51,12 +51,12 @@ import java.util.Collections;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.verify;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class TbRestApiCallNodeTest {
private TbRestApiCallNode restNode;
@@ -91,7 +91,7 @@ public class TbRestApiCallNodeTest {
}
}
- @After
+ @AfterEach
public void teardown() {
if (server != null) {
server.stop();
@@ -108,9 +108,9 @@ public class TbRestApiCallNodeTest {
public void handle(HttpRequest request, HttpResponse response, HttpContext context)
throws HttpException, IOException {
try {
- assertEquals("Request path matches", request.getRequestLine().getUri(), path);
- assertTrue("Custom header included", request.containsHeader("Foo"));
- assertEquals("Custom header value", "Bar", request.getFirstHeader("Foo").getValue());
+ assertEquals(request.getRequestLine().getUri(), path, "Request path matches");
+ assertTrue(request.containsHeader("Foo"), "Custom header included");
+ assertEquals("Bar", request.getFirstHeader("Foo").getValue(), "Custom header value");
response.setStatusCode(200);
new Thread(new Runnable() {
@Override
@@ -142,7 +142,7 @@ public class TbRestApiCallNodeTest {
TbMsg msg = TbMsg.newMsg(TbMsgType.POST_TELEMETRY_REQUEST, originator, metaData, TbMsgDataType.JSON, TbMsg.EMPTY_JSON_OBJECT, ruleChainId, ruleNodeId);
restNode.onMsg(ctx, msg);
- assertTrue("Server handled request", latch.await(10, TimeUnit.SECONDS));
+ assertTrue(latch.await(10, TimeUnit.SECONDS), "Server handled request");
ArgumentCaptor msgCaptor = ArgumentCaptor.forClass(TbMsg.class);
ArgumentCaptor metadataCaptor = ArgumentCaptor.forClass(TbMsgMetaData.class);
@@ -163,15 +163,15 @@ public class TbRestApiCallNodeTest {
public void handle(HttpRequest request, HttpResponse response, HttpContext context)
throws HttpException, IOException {
try {
- assertEquals("Request path matches", path, request.getRequestLine().getUri());
- assertTrue("Content-Type included", request.containsHeader("Content-Type"));
- assertEquals("Content-Type value", "text/plain;charset=UTF-8",
- request.getFirstHeader("Content-Type").getValue());
- assertTrue("Content-Length included", request.containsHeader("Content-Length"));
- assertEquals("Content-Length value", "2",
- request.getFirstHeader("Content-Length").getValue());
- assertTrue("Custom header included", request.containsHeader("Foo"));
- assertEquals("Custom header value", "Bar", request.getFirstHeader("Foo").getValue());
+ assertEquals(path, request.getRequestLine().getUri(), "Request path matches");
+ assertTrue(request.containsHeader("Content-Type"), "Content-Type included");
+ assertEquals("text/plain;charset=UTF-8",
+ request.getFirstHeader("Content-Type").getValue(), "Content-Type value");
+ assertTrue(request.containsHeader("Content-Length"), "Content-Length included");
+ assertEquals("2",
+ request.getFirstHeader("Content-Length").getValue(), "Content-Length value");
+ assertTrue(request.containsHeader("Foo"), "Custom header included");
+ assertEquals("Bar", request.getFirstHeader("Foo").getValue(), "Custom header value");
response.setStatusCode(200);
new Thread(new Runnable() {
@Override
@@ -203,7 +203,7 @@ public class TbRestApiCallNodeTest {
TbMsg msg = TbMsg.newMsg(TbMsgType.POST_TELEMETRY_REQUEST, originator, metaData, TbMsgDataType.JSON, TbMsg.EMPTY_JSON_OBJECT, ruleChainId, ruleNodeId);
restNode.onMsg(ctx, msg);
- assertTrue("Server handled request", latch.await(10, TimeUnit.SECONDS));
+ assertTrue(latch.await(10, TimeUnit.SECONDS), "Server handled request");
ArgumentCaptor msgCaptor = ArgumentCaptor.forClass(TbMsg.class);
ArgumentCaptor metadataCaptor = ArgumentCaptor.forClass(TbMsgMetaData.class);
diff --git a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/rpc/TbSendRPCReplyNodeTest.java b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/rpc/TbSendRPCReplyNodeTest.java
index 454c1a9fe6..db632fe3c7 100644
--- a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/rpc/TbSendRPCReplyNodeTest.java
+++ b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/rpc/TbSendRPCReplyNodeTest.java
@@ -16,12 +16,12 @@
package org.thingsboard.rule.engine.rpc;
import com.google.common.util.concurrent.SettableFuture;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.common.util.ListeningExecutor;
import org.thingsboard.rule.engine.api.RuleEngineRpcService;
@@ -43,7 +43,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class TbSendRPCReplyNodeTest {
private static final String DUMMY_SERVICE_ID = "testServiceId";
@@ -68,7 +68,7 @@ public class TbSendRPCReplyNodeTest {
@Mock
private ListeningExecutor listeningExecutor;
- @Before
+ @BeforeEach
public void setUp() throws TbNodeException {
node = new TbSendRPCReplyNode();
TbSendRpcReplyNodeConfiguration config = new TbSendRpcReplyNodeConfiguration().defaultConfiguration();
diff --git a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/transform/TbChangeOriginatorNodeTest.java b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/transform/TbChangeOriginatorNodeTest.java
index e9803289bb..952a566695 100644
--- a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/transform/TbChangeOriginatorNodeTest.java
+++ b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/transform/TbChangeOriginatorNodeTest.java
@@ -17,12 +17,12 @@ package org.thingsboard.rule.engine.transform;
import com.datastax.oss.driver.api.core.uuid.Uuids;
import com.google.common.util.concurrent.Futures;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.common.util.ListeningExecutor;
import org.thingsboard.rule.engine.TestDbCallbackExecutor;
@@ -43,14 +43,14 @@ import org.thingsboard.server.dao.asset.AssetService;
import java.util.NoSuchElementException;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.same;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class TbChangeOriginatorNodeTest {
private static final String CUSTOMER_SOURCE = "CUSTOMER";
@@ -64,14 +64,14 @@ public class TbChangeOriginatorNodeTest {
private ListeningExecutor dbExecutor;
- @Before
- public void before() {
+ @BeforeEach
+ public void before() throws TbNodeException {
dbExecutor = new TestDbCallbackExecutor();
+ init();
}
@Test
- public void originatorCanBeChangedToCustomerId() throws TbNodeException {
- init();
+ public void originatorCanBeChangedToCustomerId() {
AssetId assetId = new AssetId(Uuids.timeBased());
CustomerId customerId = new CustomerId(Uuids.timeBased());
Asset asset = new Asset();
@@ -95,8 +95,7 @@ public class TbChangeOriginatorNodeTest {
}
@Test
- public void newChainCanBeStarted() throws TbNodeException {
- init();
+ public void newChainCanBeStarted() {
AssetId assetId = new AssetId(Uuids.timeBased());
CustomerId customerId = new CustomerId(Uuids.timeBased());
Asset asset = new Asset();
@@ -119,8 +118,7 @@ public class TbChangeOriginatorNodeTest {
}
@Test
- public void exceptionThrownIfCannotFindNewOriginator() throws TbNodeException {
- init();
+ public void exceptionThrownIfCannotFindNewOriginator() {
AssetId assetId = new AssetId(Uuids.timeBased());
CustomerId customerId = new CustomerId(Uuids.timeBased());
Asset asset = new Asset();
diff --git a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/transform/TbTransformMsgNodeTest.java b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/transform/TbTransformMsgNodeTest.java
index a410b84532..98ecc237b6 100644
--- a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/transform/TbTransformMsgNodeTest.java
+++ b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/transform/TbTransformMsgNodeTest.java
@@ -17,11 +17,11 @@ package org.thingsboard.rule.engine.transform;
import com.datastax.oss.driver.api.core.uuid.Uuids;
import com.google.common.util.concurrent.Futures;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.rule.engine.api.ScriptEngine;
import org.thingsboard.rule.engine.api.TbContext;
@@ -37,12 +37,12 @@ import org.thingsboard.server.common.msg.TbMsgMetaData;
import java.util.Collections;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.same;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class TbTransformMsgNodeTest {
private TbTransformMsgNode node;
diff --git a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/util/TenantIdLoaderTest.java b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/util/TenantIdLoaderTest.java
index e06be15fe6..47fa03e08e 100644
--- a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/util/TenantIdLoaderTest.java
+++ b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/util/TenantIdLoaderTest.java
@@ -15,13 +15,13 @@
*/
package org.thingsboard.rule.engine.util;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.thingsboard.common.util.AbstractListeningExecutor;
import org.thingsboard.rule.engine.api.RuleEngineAlarmService;
import org.thingsboard.rule.engine.api.RuleEngineApiUsageStateService;
@@ -88,7 +88,7 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class TenantIdLoaderTest {
@Mock
@@ -145,7 +145,7 @@ public class TenantIdLoaderTest {
private NotificationId notificationId;
private AbstractListeningExecutor dbExecutor;
- @Before
+ @BeforeEach
public void before() {
dbExecutor = new AbstractListeningExecutor() {
@Override
@@ -165,7 +165,7 @@ public class TenantIdLoaderTest {
}
}
- @After
+ @AfterEach
public void after() {
dbExecutor.destroy();
}
@@ -384,9 +384,9 @@ public class TenantIdLoaderTest {
TenantId targetTenantId = TenantIdLoader.findTenantId(ctx, entityId);
String msg = "Check entity type <" + entityType.name() + ">:";
if (equals) {
- Assert.assertEquals(msg, targetTenantId, checkTenantId);
+ Assertions.assertEquals(targetTenantId, checkTenantId, msg);
} else {
- Assert.assertNotEquals(msg, targetTenantId, checkTenantId);
+ Assertions.assertNotEquals(targetTenantId, checkTenantId, msg);
}
}
}
diff --git a/rule-engine/rule-engine-components/src/test/resources/junit-platform.properties b/rule-engine/rule-engine-components/src/test/resources/junit-platform.properties
new file mode 100644
index 0000000000..f2ed301920
--- /dev/null
+++ b/rule-engine/rule-engine-components/src/test/resources/junit-platform.properties
@@ -0,0 +1,3 @@
+junit.jupiter.execution.parallel.enabled = true
+junit.jupiter.execution.parallel.mode.default = concurrent
+junit.jupiter.execution.parallel.mode.classes.default = concurrent