From 1b14f26dae5568c43f2b737022eca7bf15d2f652 Mon Sep 17 00:00:00 2001 From: Andrii Shvaika Date: Fri, 26 Jun 2020 14:53:57 +0300 Subject: [PATCH] Tests Fix --- .../server/controller/BaseWebsocketApiTest.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/application/src/test/java/org/thingsboard/server/controller/BaseWebsocketApiTest.java b/application/src/test/java/org/thingsboard/server/controller/BaseWebsocketApiTest.java index 0a2e798b08..fee52548d3 100644 --- a/application/src/test/java/org/thingsboard/server/controller/BaseWebsocketApiTest.java +++ b/application/src/test/java/org/thingsboard/server/controller/BaseWebsocketApiTest.java @@ -455,22 +455,18 @@ public class BaseWebsocketApiTest extends AbstractWebsocketTest { Assert.assertEquals(0, pageData.getData().get(0).getLatest().get(EntityKeyType.SERVER_ATTRIBUTE).get("serverAttributeKey").getTs()); Assert.assertEquals("", pageData.getData().get(0).getLatest().get(EntityKeyType.SERVER_ATTRIBUTE).get("serverAttributeKey").getValue()); - AttributeKvEntry dataPoint1 = new BaseAttributeKvEntry(now - TimeUnit.MINUTES.toMillis(1), new LongDataEntry("serverAttributeKey", 42L)); - List tsData = Arrays.asList(dataPoint1); - sendAttributes(device, TbAttributeSubscriptionScope.SERVER_SCOPE, tsData); + wsClient.registerWaitForUpdate(); Thread.sleep(100); - cmd = new EntityDataCmd(1, edq, null, latestCmd, null); - wrapper = new TelemetryPluginCmdsWrapper(); - wrapper.setEntityDataCmds(Collections.singletonList(cmd)); + AttributeKvEntry dataPoint1 = new BaseAttributeKvEntry(now - TimeUnit.MINUTES.toMillis(1), new LongDataEntry("serverAttributeKey", 42L)); + List tsData = Arrays.asList(dataPoint1); + sendAttributes(device, TbAttributeSubscriptionScope.SERVER_SCOPE, tsData); - wsClient.send(mapper.writeValueAsString(wrapper)); - msg = wsClient.waitForReply(); + msg = wsClient.waitForUpdate(); update = mapper.readValue(msg, EntityDataUpdate.class); Assert.assertEquals(1, update.getCmdId()); - List listData = update.getUpdate(); Assert.assertNotNull(listData); Assert.assertEquals(1, listData.size()); @@ -483,6 +479,7 @@ public class BaseWebsocketApiTest extends AbstractWebsocketTest { AttributeKvEntry dataPoint2 = new BaseAttributeKvEntry(now, new LongDataEntry("serverAttributeKey", 52L)); wsClient.registerWaitForUpdate(); + Thread.sleep(100); sendAttributes(device, TbAttributeSubscriptionScope.SERVER_SCOPE, Arrays.asList(dataPoint2)); msg = wsClient.waitForUpdate(); @@ -498,12 +495,14 @@ public class BaseWebsocketApiTest extends AbstractWebsocketTest { //Sending update from the past, while latest value has new timestamp; wsClient.registerWaitForUpdate(); + Thread.sleep(100); sendAttributes(device, TbAttributeSubscriptionScope.SERVER_SCOPE, Arrays.asList(dataPoint1)); msg = wsClient.waitForUpdate(TimeUnit.SECONDS.toMillis(1)); Assert.assertNull(msg); //Sending duplicate update again wsClient.registerWaitForUpdate(); + Thread.sleep(100); sendAttributes(device, TbAttributeSubscriptionScope.SERVER_SCOPE, Arrays.asList(dataPoint2)); msg = wsClient.waitForUpdate(TimeUnit.SECONDS.toMillis(1)); Assert.assertNull(msg);