Search in sources :

Example 1 with OnFinishedHandler

use of com.canoo.dp.impl.client.legacy.communication.OnFinishedHandler in project dolphin-platform by canoo.

the class ClientConnectorTests method syncAndWaitUntilDone.

private void syncAndWaitUntilDone() {
    clientConnector.send(new EmptyCommand(), new OnFinishedHandler() {

        public void onFinished() {
            syncDone.countDown();
        }
    });
    Assert.assertTrue(waitForLatch());
}
Also used : EmptyCommand(com.canoo.dp.impl.remoting.legacy.communication.EmptyCommand) OnFinishedHandler(com.canoo.dp.impl.client.legacy.communication.OnFinishedHandler)

Example 2 with OnFinishedHandler

use of com.canoo.dp.impl.client.legacy.communication.OnFinishedHandler in project dolphin-platform by canoo.

the class BlindCommandBatcherTest method doNonBlindForcesBatch.

public void doNonBlindForcesBatch() {
    Assert.assertTrue(batcher.isEmpty());
    List<CommandAndHandler> list = new ArrayList<CommandAndHandler>();
    list.add(new CommandAndHandler(null));
    list.add(new CommandAndHandler(null));
    list.add(new CommandAndHandler(null));
    list.add(new CommandAndHandler(null, new OnFinishedHandler() {

        @Override
        public void onFinished() {
        }
    }));
    for (CommandAndHandler commandAndHandler : list) {
        batcher.batch(commandAndHandler);
    }
    Assert.assertEquals(4, ((ArrayList<CommandAndHandler>) list).size());
    try {
        Assert.assertEquals(list.subList(0, 3), batcher.getWaitingBatches().getVal());
    } catch (InterruptedException e) {
        e.printStackTrace();
        Assert.fail(e.getMessage());
    }
    try {
        Assert.assertEquals(Collections.singletonList(list.get(3)), batcher.getWaitingBatches().getVal());
    } catch (InterruptedException e) {
        e.printStackTrace();
        Assert.fail(e.getMessage());
    }
}
Also used : CommandAndHandler(com.canoo.dp.impl.client.legacy.communication.CommandAndHandler) ArrayList(java.util.ArrayList) OnFinishedHandler(com.canoo.dp.impl.client.legacy.communication.OnFinishedHandler)

Example 3 with OnFinishedHandler

use of com.canoo.dp.impl.client.legacy.communication.OnFinishedHandler in project dolphin-platform by canoo.

the class DolphinCommandHandler method invokeDolphinCommand.

public CompletableFuture<Void> invokeDolphinCommand(final Command command) {
    Assert.requireNonNull(command, "command");
    final CompletableFuture<Void> result = new CompletableFuture<>();
    clientConnector.send(command, new OnFinishedHandler() {

        @Override
        public void onFinished() {
            result.complete(null);
        }
    });
    return result;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) OnFinishedHandler(com.canoo.dp.impl.client.legacy.communication.OnFinishedHandler)

Aggregations

OnFinishedHandler (com.canoo.dp.impl.client.legacy.communication.OnFinishedHandler)3 CommandAndHandler (com.canoo.dp.impl.client.legacy.communication.CommandAndHandler)1 EmptyCommand (com.canoo.dp.impl.remoting.legacy.communication.EmptyCommand)1 ArrayList (java.util.ArrayList)1 CompletableFuture (java.util.concurrent.CompletableFuture)1