Search in sources :

Example 1 with INVALID_ARGUMENT

use of io.servicetalk.grpc.api.GrpcStatusCode.INVALID_ARGUMENT in project servicetalk by apple.

the class SingleRequestOrResponseApiTest method serverResponseStreamingRouteFailsWithInvalidArgument.

private void serverResponseStreamingRouteFailsWithInvalidArgument(Iterable<TestRequest> requestItems, String expectedMsg) throws Exception {
    // No need to run the test with different client-side, always use blocking client
    assumeFalse(streamingClient);
    try (BlockingTesterClient client = newBlockingClient()) {
        GrpcStatusException e = assertThrows(GrpcStatusException.class, () -> client.testBiDiStream(requestItems).forEach(response -> {
        /* noop */
        }));
        assertThat(e.status().code(), is(INVALID_ARGUMENT));
        assertThat(e.status().description(), equalTo(expectedMsg));
    }
}
Also used : IntStream(java.util.stream.IntStream) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) StreamingHttpResponse(io.servicetalk.http.api.StreamingHttpResponse) Publisher(io.servicetalk.concurrent.api.Publisher) StreamingHttpRequester(io.servicetalk.http.api.StreamingHttpRequester) Collections.singletonList(java.util.Collections.singletonList) GrpcStatusException(io.servicetalk.grpc.api.GrpcStatusException) INVALID_ARGUMENT(io.servicetalk.grpc.api.GrpcStatusCode.INVALID_ARGUMENT) ServiceFactory(io.servicetalk.grpc.netty.TesterProto.Tester.ServiceFactory) Arrays.asList(java.util.Arrays.asList) Assumptions.assumeFalse(org.junit.jupiter.api.Assumptions.assumeFalse) TesterClient(io.servicetalk.grpc.netty.TesterProto.Tester.TesterClient) StreamingHttpRequest(io.servicetalk.http.api.StreamingHttpRequest) Publisher.fromIterable(io.servicetalk.concurrent.api.Publisher.fromIterable) AddressUtils.serverHostAndPort(io.servicetalk.transport.netty.internal.AddressUtils.serverHostAndPort) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) NoSuchElementException(java.util.NoSuchElementException) Publisher.from(io.servicetalk.concurrent.api.Publisher.from) Nullable(javax.annotation.Nullable) MethodSource(org.junit.jupiter.params.provider.MethodSource) BlockingTesterClient(io.servicetalk.grpc.netty.TesterProto.Tester.BlockingTesterClient) AddressUtils.localAddress(io.servicetalk.transport.netty.internal.AddressUtils.localAddress) ServerContext(io.servicetalk.transport.api.ServerContext) Single.defer(io.servicetalk.concurrent.api.Single.defer) Collections.emptyList(java.util.Collections.emptyList) Single(io.servicetalk.concurrent.api.Single) GrpcPayloadWriter(io.servicetalk.grpc.api.GrpcPayloadWriter) TesterService(io.servicetalk.grpc.netty.TesterProto.Tester.TesterService) TestRequest(io.servicetalk.grpc.netty.TesterProto.TestRequest) ClientFactory(io.servicetalk.grpc.netty.TesterProto.Tester.ClientFactory) StreamingHttpClientFilter(io.servicetalk.http.api.StreamingHttpClientFilter) Arguments(org.junit.jupiter.params.provider.Arguments) InetSocketAddress(java.net.InetSocketAddress) GrpcServiceContext(io.servicetalk.grpc.api.GrpcServiceContext) BlockingIterable(io.servicetalk.concurrent.BlockingIterable) ExecutionException(java.util.concurrent.ExecutionException) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) AfterEach(org.junit.jupiter.api.AfterEach) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Collectors.toList(java.util.stream.Collectors.toList) Stream(java.util.stream.Stream) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Matchers.is(org.hamcrest.Matchers.is) BlockingTestResponseStreamRpc(io.servicetalk.grpc.netty.TesterProto.Tester.BlockingTestResponseStreamRpc) BlockingTesterService(io.servicetalk.grpc.netty.TesterProto.Tester.BlockingTesterService) TestResponse(io.servicetalk.grpc.netty.TesterProto.TestResponse) GrpcClientBuilder(io.servicetalk.grpc.api.GrpcClientBuilder) HostAndPort(io.servicetalk.transport.api.HostAndPort) GrpcStatusException(io.servicetalk.grpc.api.GrpcStatusException) BlockingTesterClient(io.servicetalk.grpc.netty.TesterProto.Tester.BlockingTesterClient)

Aggregations

BlockingIterable (io.servicetalk.concurrent.BlockingIterable)1 Publisher (io.servicetalk.concurrent.api.Publisher)1 Publisher.from (io.servicetalk.concurrent.api.Publisher.from)1 Publisher.fromIterable (io.servicetalk.concurrent.api.Publisher.fromIterable)1 Single (io.servicetalk.concurrent.api.Single)1 Single.defer (io.servicetalk.concurrent.api.Single.defer)1 GrpcClientBuilder (io.servicetalk.grpc.api.GrpcClientBuilder)1 GrpcPayloadWriter (io.servicetalk.grpc.api.GrpcPayloadWriter)1 GrpcServiceContext (io.servicetalk.grpc.api.GrpcServiceContext)1 INVALID_ARGUMENT (io.servicetalk.grpc.api.GrpcStatusCode.INVALID_ARGUMENT)1 GrpcStatusException (io.servicetalk.grpc.api.GrpcStatusException)1 TestRequest (io.servicetalk.grpc.netty.TesterProto.TestRequest)1 TestResponse (io.servicetalk.grpc.netty.TesterProto.TestResponse)1 BlockingTestResponseStreamRpc (io.servicetalk.grpc.netty.TesterProto.Tester.BlockingTestResponseStreamRpc)1 BlockingTesterClient (io.servicetalk.grpc.netty.TesterProto.Tester.BlockingTesterClient)1 BlockingTesterService (io.servicetalk.grpc.netty.TesterProto.Tester.BlockingTesterService)1 ClientFactory (io.servicetalk.grpc.netty.TesterProto.Tester.ClientFactory)1 ServiceFactory (io.servicetalk.grpc.netty.TesterProto.Tester.ServiceFactory)1 TesterClient (io.servicetalk.grpc.netty.TesterProto.Tester.TesterClient)1 TesterService (io.servicetalk.grpc.netty.TesterProto.Tester.TesterService)1