@Override
    public CompletableFuture<?> invoke(Object[] arguments) {
        T request = (T) arguments[0];
        StreamObserver<R> responseObserver = (StreamObserver<R>) arguments[1];
        func.accept(request, responseObserver);
        return CompletableFuture.completedFuture(null);
    }
@Test
    void invoke() {
        AtomicInteger nextCounter = new AtomicInteger();
        AtomicInteger completeCounter = new AtomicInteger();
        AtomicInteger errorCounter = new AtomicInteger();
        StreamObserver<String> responseObserver = Mockito.mock(StreamObserver.class);
        doAnswer(o -> nextCounter.incrementAndGet()).when(responseObserver).onNext(anyString());
        doAnswer(o -> completeCounter.incrementAndGet()).when(responseObserver).onCompleted();
        doAnswer(o -> errorCounter.incrementAndGet()).when(responseObserver).onError(any(Throwable.class));
        BiConsumer<String, StreamObserver<String>> consumer = (s, stringStreamObserver) -> {
            for (int i = 0; i < 10; i++) {
                stringStreamObserver.onNext(s + i);
            }
            stringStreamObserver.onCompleted();
        };
        ServerStreamMethodHandler<String, String> handler = new ServerStreamMethodHandler<>(consumer);
        CompletableFuture<?> future = handler.invoke(new Object[] {"test", responseObserver});
        Assertions.assertTrue(future.isDone());
        Assertions.assertEquals(10, nextCounter.get());
        Assertions.assertEquals(0, errorCounter.get());
        Assertions.assertEquals(1, completeCounter.get());
    }