Sentence implements AbstractServerSocket<Sentence> { @Override public void close() { execute(new CloseAction()); } Sentence(Server server, ServerSocketPredicate predicate); Sentence find(ServerSocketPredicate predicate); Sentence execute(SerializableAction<ServerSocket> action); @Override Sentence send(String event, Object data); @Override void close(); @Override Sentence tag(String... names); @Override Sentence untag(String... names);  }
@Test public void close() { ServerSocket socket = mock(ServerSocket.class); Server server = new DefaultServer() { @Override public Server find(ServerSocketPredicate predicate, SerializableAction<ServerSocket> action) { action.on(socket); return this; } }; server.find(NOOP_PREDICATE).close(); verify(socket, times(1)).close(); }