### Question:
EventToJsonAction implements Action1<Tup2<ServerWebSocket, Func1<Event, Boolean>>> { @Override public void call(Tup2<ServerWebSocket, Func1<Event, Boolean>> r) { ServerWebSocket socket = r.getLeft(); Subscription subscription = eventObservable .filter(r.getRight()) .map(e -> new JsonObject() .put("tags", e.getTags()) .put("host", e.getHost()) .put("state", e.getState()) .put("service", e.getService()) .put("description", e.getDescription()) .put("metric", e.getMetric()) .put("time", e.getTime()) .put("ttl", e.getTtl()) ) .subscribe(json -> socket.writeFrame(frameFactory.call(json.encode()))); socket.closeHandler(h -> subscription.unsubscribe()); } EventToJsonAction(Observable<Event> eventObservable, Func1<String, WebSocketFrame> frameFactory); @Override void call(Tup2<ServerWebSocket, Func1<Event, Boolean>> r);  }### Answer:
@Test public void testEventAction() { WebSocketFrameImpl frame = new WebSocketFrameImpl(); ServerWebSocket socketMock = mock(ServerWebSocket.class); Event event = new Event("host", "service", "state", "desc", Arrays.asList("blaha"), null, 1, 1.0F, 1.0D); new EventToJsonAction(Observable.just(event), s -> { assertEquals(s, "{\"tags\":[\"blaha\"],\"host\":\"host\",\"state\":\"state\",\"service\":\"service\",\"description\":\"desc\",\"metric\":1.0,\"time\":1,\"ttl\":1.0}"); return frame; }).call(Tup2.create(socketMock, e -> true)); verify(socketMock).writeFrame(frame); }