### Question:
WebSocketEndpoint { @OnClose public void onClose(Session session, @PathParam("username") String username) { sessions.remove(username); broadcaster.removeSession(session); broadcaster.broadcast("#User: " + username + " left"); LOGGER.info(username + " is offline!"); }  @OnOpen void onOpen(Session session, @PathParam("username") String username); @OnClose void onClose(Session session, @PathParam("username") String username); @OnError void onError(Session session, @PathParam("username") String username, Throwable throwable); @OnMessage void onMessage(String message, @PathParam("username") String username);  }### Answer:
@Test void onClose() { webSocketEndpoint.onClose(session, "user2"); Mockito.verify(broadcaster).removeSession(session); Mockito.verify(broadcaster).broadcast("#User: user2 left"); }