### Question:
EventObservable { public static Observable<Tup2<ServerWebSocket, Func1<Event, Boolean>>> convertFromWebSocketObservable(Observable<ServerWebSocket> webSocketObservable) { return webSocketObservable.map(s -> { try { List<NameValuePair> query = URLEncodedUtils.parse(new URI(s.uri()), "UTF-8"); NameValuePair nameValuePair = query.stream().filter(p -> "query".equals(p.getName())).findAny().get(); return Tup2.create(s, Query.parse(nameValuePair.getValue())); } catch (Exception e) { throw new NetSocketException(s, e); } }); }  static Observable<Tup2<ServerWebSocket, Func1<Event, Boolean>>> convertFromWebSocketObservable(Observable<ServerWebSocket> webSocketObservable);  }### Answer:
@Test public void testConversionFromWebSocket() { ServerWebSocket socket = mock(ServerWebSocket.class); when(socket.uri()).thenReturn("http: Observable<Tup2<ServerWebSocket, Func1<Event, Boolean>>> observable = EventObservable.convertFromWebSocketObservable(Observable.just(socket)); observable.subscribe(t -> { assertEquals(true, t.getRight().call(null)); testComplete(); }); await(); }
@Test public void testConversionFromWebSocketWithMoreComplexQuery() { ServerWebSocket socket = mock(ServerWebSocket.class); when(socket.uri()).thenReturn("http: Observable<Tup2<ServerWebSocket, Func1<Event, Boolean>>> observable = EventObservable.convertFromWebSocketObservable(Observable.just(socket)); observable.subscribe(t -> { assertEquals(true, t.getRight().call(Event.builder().withHost("test").build())); assertEquals(false, t.getRight().call(Event.builder().withHost("fail").build())); testComplete(); }); await(); }
@Test public void testConversionFromWebSocketWithInvalidUri() { ServerWebSocket socket = mock(ServerWebSocket.class); when(socket.uri()).thenReturn("httpquery=true"); Observable<Tup2<ServerWebSocket, Func1<Event, Boolean>>> observable = EventObservable.convertFromWebSocketObservable(Observable.just(socket)); observable.subscribe(t -> { fail(); testComplete(); }, e -> { testComplete(); }); await(); }