WebSocket implements AutoCloseable { void receiveByteArray(byte[] input) { try { Event event = mapper.readValue(input, Event.class); receive(event); } catch (IOException e) { log.error("Could not deserialise Event", 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 receiveInputStream() throws Exception { Message<String> event = new Message<String>(0, 1L, 2, 3L, "message"); byte[] input = mapper.writeValueAsBytes(event); underTest.receiveByteArray(input); verify(eventHandler).onEvent(event); }
@Test(expected = UncheckedIOException.class) public void receiveEmptyInputStreamException() throws Exception { byte[] input = new byte[0]; underTest.receiveByteArray(input); }