Search in sources :

Example 1 with SubscribeFieldToMQTTtopic

use of org.openhab.binding.mqtt.generic.mapping.SubscribeFieldToMQTTtopic in project openhab-addons by openhab.

the class HomieThingHandlerTests method createSubscriberAnswer.

public Object createSubscriberAnswer(InvocationOnMock invocation) {
    final AbstractMqttAttributeClass attributes = (AbstractMqttAttributeClass) invocation.getMock();
    final ScheduledExecutorService scheduler = (ScheduledExecutorService) invocation.getArguments()[0];
    final Field field = (Field) invocation.getArguments()[1];
    final String topic = (String) invocation.getArguments()[2];
    final boolean mandatory = (boolean) invocation.getArguments()[3];
    final SubscribeFieldToMQTTtopic s = spy(new SubscribeFieldToMQTTtopic(scheduler, field, attributes, topic, mandatory));
    doReturn(CompletableFuture.completedFuture(true)).when(s).subscribeAndReceive(any(), anyInt());
    return s;
}
Also used : Field(java.lang.reflect.Field) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) SubscribeFieldToMQTTtopic(org.openhab.binding.mqtt.generic.mapping.SubscribeFieldToMQTTtopic) AbstractMqttAttributeClass(org.openhab.binding.mqtt.generic.mapping.AbstractMqttAttributeClass)

Aggregations

Field (java.lang.reflect.Field)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 AbstractMqttAttributeClass (org.openhab.binding.mqtt.generic.mapping.AbstractMqttAttributeClass)1 SubscribeFieldToMQTTtopic (org.openhab.binding.mqtt.generic.mapping.SubscribeFieldToMQTTtopic)1