Search in sources :

Example 6 with DataElementValue

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());
}
Also used : NewDataListener(de.fraunhofer.iosb.ilt.faaast.service.assetconnection.NewDataListener) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch) DataElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.DataElementValue)

Aggregations

DataElementValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.DataElementValue)6 Reference (io.adminshell.aas.v3.model.Reference)3 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 ServiceContext (de.fraunhofer.iosb.ilt.faaast.service.ServiceContext)2 NewDataListener (de.fraunhofer.iosb.ilt.faaast.service.assetconnection.NewDataListener)2 PropertyValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.PropertyValue)2 ElementValueTypeInfo (de.fraunhofer.iosb.ilt.faaast.service.typing.ElementValueTypeInfo)2 TypeInfo (de.fraunhofer.iosb.ilt.faaast.service.typing.TypeInfo)2 DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 UaNode (com.prosysopc.ua.nodes.UaNode)1 MethodManagerUaNode (com.prosysopc.ua.server.MethodManagerUaNode)1 NodeManagerUaNode (com.prosysopc.ua.server.NodeManagerUaNode)1 ByteString (com.prosysopc.ua.stack.builtintypes.ByteString)1 AssetConnectionException (de.fraunhofer.iosb.ilt.faaast.service.assetconnection.AssetConnectionException)1 AssetValueProvider (de.fraunhofer.iosb.ilt.faaast.service.assetconnection.AssetValueProvider)1 AnnotatedRelationshipElementValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.AnnotatedRelationshipElementValue)1 Datatype (de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.Datatype)1 StringValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.StringValue)1 DeleteSubmodelByIdRequestHandler (de.fraunhofer.iosb.ilt.faaast.service.request.handler.DeleteSubmodelByIdRequestHandler)1