BaseWebsocketApiTest - improved assertion output and logging
This commit is contained in:
parent
cd881d8a68
commit
433a5dcbcf
@ -548,7 +548,7 @@ public abstract class BaseWebsocketApiTest extends AbstractControllerTest {
|
|||||||
SingleEntityFilter entityFilter = new SingleEntityFilter();
|
SingleEntityFilter entityFilter = new SingleEntityFilter();
|
||||||
entityFilter.setSingleEntity(tenantId);
|
entityFilter.setSingleEntity(tenantId);
|
||||||
|
|
||||||
assertThatNoException().isThrownBy(() -> {
|
assertThatNoException().as("subscribeForAttributes").isThrownBy(() -> {
|
||||||
JsonNode update = getWsClient().subscribeForAttributes(tenantId, TbAttributeSubscriptionScope.SERVER_SCOPE.name(), List.of("attr"));
|
JsonNode update = getWsClient().subscribeForAttributes(tenantId, TbAttributeSubscriptionScope.SERVER_SCOPE.name(), List.of("attr"));
|
||||||
assertThat(update.get("errorMsg").isNull()).isTrue();
|
assertThat(update.get("errorMsg").isNull()).isTrue();
|
||||||
assertThat(update.get("errorCode").asInt()).isEqualTo(SubscriptionErrorCode.NO_ERROR.getCode());
|
assertThat(update.get("errorCode").asInt()).isEqualTo(SubscriptionErrorCode.NO_ERROR.getCode());
|
||||||
@ -560,7 +560,7 @@ public abstract class BaseWebsocketApiTest extends AbstractControllerTest {
|
|||||||
new BaseAttributeKvEntry(System.currentTimeMillis(), new StringDataEntry("attr", expectedAttrValue))
|
new BaseAttributeKvEntry(System.currentTimeMillis(), new StringDataEntry("attr", expectedAttrValue))
|
||||||
));
|
));
|
||||||
JsonNode update = JacksonUtil.toJsonNode(getWsClient().waitForUpdate());
|
JsonNode update = JacksonUtil.toJsonNode(getWsClient().waitForUpdate());
|
||||||
assertThat(update).isNotNull();
|
assertThat(update).as("waitForUpdate").isNotNull();
|
||||||
assertThat(update.get("data").get("attr").get(0).get(1).asText()).isEqualTo(expectedAttrValue);
|
assertThat(update.get("data").get("attr").get(0).get(1).asText()).isEqualTo(expectedAttrValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -569,15 +569,17 @@ public abstract class BaseWebsocketApiTest extends AbstractControllerTest {
|
|||||||
tsService.saveAndNotify(device.getTenantId(), null, device.getId(), tsData, 0, new FutureCallback<Void>() {
|
tsService.saveAndNotify(device.getTenantId(), null, device.getId(), tsData, 0, new FutureCallback<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(@Nullable Void result) {
|
public void onSuccess(@Nullable Void result) {
|
||||||
|
log.debug("sendTelemetry callback onSuccess");
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable t) {
|
public void onFailure(Throwable t) {
|
||||||
|
log.error("Failed to send telemetry", t);
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
latch.await(3, TimeUnit.SECONDS);
|
assertThat(latch.await(TIMEOUT, TimeUnit.SECONDS)).as("await sendTelemetry callback");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendAttributes(Device device, TbAttributeSubscriptionScope scope, List<AttributeKvEntry> attrData) throws InterruptedException {
|
private void sendAttributes(Device device, TbAttributeSubscriptionScope scope, List<AttributeKvEntry> attrData) throws InterruptedException {
|
||||||
@ -589,14 +591,16 @@ public abstract class BaseWebsocketApiTest extends AbstractControllerTest {
|
|||||||
tsService.saveAndNotify(tenantId, entityId, scope.name(), attrData, new FutureCallback<Void>() {
|
tsService.saveAndNotify(tenantId, entityId, scope.name(), attrData, new FutureCallback<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(@Nullable Void result) {
|
public void onSuccess(@Nullable Void result) {
|
||||||
|
log.debug("sendAttributes callback onSuccess");
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable t) {
|
public void onFailure(Throwable t) {
|
||||||
|
log.error("Failed to sendAttributes", t);
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
latch.await(3, TimeUnit.SECONDS);
|
assertThat(latch.await(TIMEOUT, TimeUnit.SECONDS)).as("await sendAttributes callback").isTrue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user