WebSocket implements AutoCloseable { void send(Event event) { connect(); log.debug("Sending Event: {}", event); synchronized (session) { try { session .getBasicRemote() .sendBinary(ByteBuffer.wrap(mapper.writeValueAsBytes(event))); } catch (IOException e) { throw new UncheckedIOException(e); } } } WebSocket(
      String username,
      String password,
      URI uri,
      ObjectMapper mapper,
      TLSConfig.Factory tlsConfigFactory,
      long keepAliveSeconds,
      EventHandler eventHandler,
      ErrorHandler errorHandler,
      CloseHandler closeHandler); @Override void close();  }
@Test public void send() throws Exception { underTest.connect(); RemoteEndpoint.Basic basicRemote = mock(RemoteEndpoint.Basic.class); doReturn(basicRemote).when(session).getBasicRemote(); underTest.send(new Cancel()); verify(basicRemote).sendBinary(ByteBuffer.wrap("{\"type\":\"CANCEL\"}".getBytes())); }