use of de.fraunhofer.iosb.ilt.faaast.service.model.value.DataElementValue in project FAAAST-Service by FraunhoferIOSB.
the class MqttAssetConnectionTest method testSubscriptionProvider.
public void testSubscriptionProvider(ContentFormat contentFormat, String message, String query, PropertyValue expected) throws AssetConnectionException, InterruptedException, ValueFormatException {
MqttAssetConnection assetConnection = newConnection(ElementValueTypeInfo.builder().datatype(expected.getValue().getDataType()).type(expected.getClass()).build(), MqttSubscriptionProviderConfig.builder().contentFormat(contentFormat).query(query).build());
CountDownLatch condition = new CountDownLatch(1);
final AtomicReference<DataElementValue> response = new AtomicReference<>();
assetConnection.getSubscriptionProviders().get(DEFAULT_REFERENCE).addNewDataListener(new NewDataListener() {
@Override
public void newDataReceived(DataElementValue data) {
response.set(data);
condition.countDown();
}
});
publishMqtt(DEFAULT_TOPIC, message);
condition.await(DEFAULT_TIMEOUT, isDebugging() ? TimeUnit.SECONDS : TimeUnit.MILLISECONDS);
Assert.assertEquals(expected, response.get());
}
Aggregations