Search in sources :

Example 6 with NodeAttributes

use of org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.NodeAttributes in project smarthome by eclipse.

the class HomieThingHandlerTests method createSpyNode.

public Node createSpyNode(String propertyID, Device device) {
    // Create the node
    Node node = spy(device.createNode("node", spy(new NodeAttributes())));
    doReturn(future).when(node.attributes).subscribeAndReceive(any(), any(), anyString(), any(), anyInt());
    doReturn(future).when(node.attributes).unsubscribe();
    node.attributes.name = "testnode";
    node.attributes.properties = new String[] { "property" };
    doAnswer(this::createSubscriberAnswer).when(node.attributes).createSubscriber(any(), any(), any(), anyBoolean());
    // Intercept creating a property in the next call and inject a spy'ed property.
    doAnswer(i -> createSpyProperty("property", node)).when(node).createProperty(any());
    return node;
}
Also used : Node(org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Node) NodeAttributes(org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.NodeAttributes)

Aggregations

Node (org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Node)6 NodeAttributes (org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.NodeAttributes)6 Property (org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Property)3 PropertyAttributes (org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.PropertyAttributes)3 ChannelState (org.eclipse.smarthome.binding.mqtt.generic.internal.generic.ChannelState)3 Test (org.junit.Test)3 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)2 Device (org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Device)2 Value (org.eclipse.smarthome.binding.mqtt.generic.internal.values.Value)2 StringType (org.eclipse.smarthome.core.library.types.StringType)2 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ExecutionException (java.util.concurrent.ExecutionException)1 ScheduledFuture (java.util.concurrent.ScheduledFuture)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1 TimeUnit (java.util.concurrent.TimeUnit)1 NonNull (org.eclipse.jdt.annotation.NonNull)1