use of io.vertx.core.buffer.impl.BufferFactoryImpl in project nem2-sdk-java by nemtech.
the class ListenerVertxTest method simulateWebSocketStartup.
private void simulateWebSocketStartup() throws InterruptedException, ExecutionException, TimeoutException {
ArgumentCaptor<Handler> webSocketHandlerCapture = ArgumentCaptor.forClass(Handler.class);
ArgumentCaptor<Handler> bufferHandlerCapture = ArgumentCaptor.forClass(Handler.class);
when(httpClientMock.websocket(any(RequestOptions.class), webSocketHandlerCapture.capture())).thenReturn(httpClientMock);
when(webSocketMock.handler(bufferHandlerCapture.capture())).thenReturn(webSocketMock);
CompletableFuture<Void> future = listener.open();
Handler<WebSocket> webSocketHandler = webSocketHandlerCapture.getValue();
Assertions.assertNotNull(webSocketHandler);
webSocketHandler.handle(webSocketMock);
Handler<Buffer> bufferHandler = bufferHandlerCapture.getValue();
Assertions.assertNotNull(bufferHandler);
Buffer event = new BufferFactoryImpl().buffer(jsonHelper.print(Collections.singletonMap("uid", wsId)));
bufferHandler.handle(event);
future.get(3, TimeUnit.SECONDS);
}
Aggregations