Websocket Api tests improvements
This commit is contained in:
parent
0894b23b93
commit
31f0689f63
@ -445,6 +445,7 @@ public class BaseWebsocketApiTest extends AbstractWebsocketTest {
|
|||||||
|
|
||||||
wsClient.send(mapper.writeValueAsString(wrapper));
|
wsClient.send(mapper.writeValueAsString(wrapper));
|
||||||
String msg = wsClient.waitForReply();
|
String msg = wsClient.waitForReply();
|
||||||
|
Assert.assertNotNull(msg);
|
||||||
EntityDataUpdate update = mapper.readValue(msg, EntityDataUpdate.class);
|
EntityDataUpdate update = mapper.readValue(msg, EntityDataUpdate.class);
|
||||||
Assert.assertEquals(1, update.getCmdId());
|
Assert.assertEquals(1, update.getCmdId());
|
||||||
PageData<EntityData> pageData = update.getData();
|
PageData<EntityData> pageData = update.getData();
|
||||||
@ -457,13 +458,14 @@ public class BaseWebsocketApiTest extends AbstractWebsocketTest {
|
|||||||
|
|
||||||
|
|
||||||
wsClient.registerWaitForUpdate();
|
wsClient.registerWaitForUpdate();
|
||||||
Thread.sleep(100);
|
Thread.sleep(500);
|
||||||
|
|
||||||
AttributeKvEntry dataPoint1 = new BaseAttributeKvEntry(now - TimeUnit.MINUTES.toMillis(1), new LongDataEntry("serverAttributeKey", 42L));
|
AttributeKvEntry dataPoint1 = new BaseAttributeKvEntry(now - TimeUnit.MINUTES.toMillis(1), new LongDataEntry("serverAttributeKey", 42L));
|
||||||
List<AttributeKvEntry> tsData = Arrays.asList(dataPoint1);
|
List<AttributeKvEntry> tsData = Arrays.asList(dataPoint1);
|
||||||
sendAttributes(device, TbAttributeSubscriptionScope.SERVER_SCOPE, tsData);
|
sendAttributes(device, TbAttributeSubscriptionScope.SERVER_SCOPE, tsData);
|
||||||
|
|
||||||
msg = wsClient.waitForUpdate();
|
msg = wsClient.waitForUpdate();
|
||||||
|
Assert.assertNotNull(msg);
|
||||||
update = mapper.readValue(msg, EntityDataUpdate.class);
|
update = mapper.readValue(msg, EntityDataUpdate.class);
|
||||||
|
|
||||||
Assert.assertEquals(1, update.getCmdId());
|
Assert.assertEquals(1, update.getCmdId());
|
||||||
@ -479,9 +481,10 @@ public class BaseWebsocketApiTest extends AbstractWebsocketTest {
|
|||||||
AttributeKvEntry dataPoint2 = new BaseAttributeKvEntry(now, new LongDataEntry("serverAttributeKey", 52L));
|
AttributeKvEntry dataPoint2 = new BaseAttributeKvEntry(now, new LongDataEntry("serverAttributeKey", 52L));
|
||||||
|
|
||||||
wsClient.registerWaitForUpdate();
|
wsClient.registerWaitForUpdate();
|
||||||
Thread.sleep(100);
|
Thread.sleep(500);
|
||||||
sendAttributes(device, TbAttributeSubscriptionScope.SERVER_SCOPE, Arrays.asList(dataPoint2));
|
sendAttributes(device, TbAttributeSubscriptionScope.SERVER_SCOPE, Arrays.asList(dataPoint2));
|
||||||
msg = wsClient.waitForUpdate();
|
msg = wsClient.waitForUpdate();
|
||||||
|
Assert.assertNotNull(msg);
|
||||||
|
|
||||||
update = mapper.readValue(msg, EntityDataUpdate.class);
|
update = mapper.readValue(msg, EntityDataUpdate.class);
|
||||||
Assert.assertEquals(1, update.getCmdId());
|
Assert.assertEquals(1, update.getCmdId());
|
||||||
@ -495,14 +498,14 @@ public class BaseWebsocketApiTest extends AbstractWebsocketTest {
|
|||||||
|
|
||||||
//Sending update from the past, while latest value has new timestamp;
|
//Sending update from the past, while latest value has new timestamp;
|
||||||
wsClient.registerWaitForUpdate();
|
wsClient.registerWaitForUpdate();
|
||||||
Thread.sleep(100);
|
Thread.sleep(500);
|
||||||
sendAttributes(device, TbAttributeSubscriptionScope.SERVER_SCOPE, Arrays.asList(dataPoint1));
|
sendAttributes(device, TbAttributeSubscriptionScope.SERVER_SCOPE, Arrays.asList(dataPoint1));
|
||||||
msg = wsClient.waitForUpdate(TimeUnit.SECONDS.toMillis(1));
|
msg = wsClient.waitForUpdate(TimeUnit.SECONDS.toMillis(1));
|
||||||
Assert.assertNull(msg);
|
Assert.assertNull(msg);
|
||||||
|
|
||||||
//Sending duplicate update again
|
//Sending duplicate update again
|
||||||
wsClient.registerWaitForUpdate();
|
wsClient.registerWaitForUpdate();
|
||||||
Thread.sleep(100);
|
Thread.sleep(500);
|
||||||
sendAttributes(device, TbAttributeSubscriptionScope.SERVER_SCOPE, Arrays.asList(dataPoint2));
|
sendAttributes(device, TbAttributeSubscriptionScope.SERVER_SCOPE, Arrays.asList(dataPoint2));
|
||||||
msg = wsClient.waitForUpdate(TimeUnit.SECONDS.toMillis(1));
|
msg = wsClient.waitForUpdate(TimeUnit.SECONDS.toMillis(1));
|
||||||
Assert.assertNull(msg);
|
Assert.assertNull(msg);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user