use of com.zsmartsystems.zigbee.CommandResultFuture in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeNetworkDiscovererTest method setupTest.
@Before
public void setupTest() {
networkManager = Mockito.mock(ZigBeeNetworkManager.class);
nodeCapture = ArgumentCaptor.forClass(ZigBeeNode.class);
// commandCapture = ArgumentCaptor.forClass(ZigBeeCommand.class);
// matcherCapture = ArgumentCaptor.forClass(CommandResponseMatcher.class);
// Mockito.when(networkManager.unicast(commandCapture.capture(), matcherCapture.capture())).thenReturn(null);
Mockito.doAnswer(new Answer<Future<CommandResult>>() {
@Override
public Future<CommandResult> answer(InvocationOnMock invocation) {
ZigBeeCommand command = (ZigBeeCommand) invocation.getArguments()[0];
CommandResultFuture commandFuture = new CommandResultFuture(networkManager);
CommandResult result = new CommandResult(responses.get(command.getClusterId()));
commandFuture.set(result);
return commandFuture;
}
}).when(networkManager).unicast(org.mockito.Matchers.any(ZigBeeCommand.class), org.mockito.Matchers.any(ZigBeeTransactionMatcher.class));
Mockito.doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) {
Runnable runnable = (Runnable) invocation.getArguments()[0];
new Thread(runnable).start();
return null;
}
}).when(networkManager).executeTask(org.mockito.Matchers.any(Runnable.class));
}
Aggregations