use of io.helidon.grpc.client.ClientMethodDescriptor in project helidon by oracle.
the class GrpcClientBuilderTest method assertServiceOne.
public void assertServiceOne(GrpcClientBuilder builder) {
ClientServiceDescriptor.Builder descriptorBuilder = builder.build();
ClientServiceDescriptor descriptor = descriptorBuilder.build();
assertThat(descriptor.name(), is("ServiceOne/foo"));
assertThat(descriptor.methods().size(), is(4));
ClientMethodDescriptor ClientMethodDescriptor;
io.grpc.MethodDescriptor grpcDescriptor;
ClientMethodDescriptor = descriptor.method("unary");
assertThat(ClientMethodDescriptor, is(notNullValue()));
assertThat(ClientMethodDescriptor.name(), is("unary"));
grpcDescriptor = ClientMethodDescriptor.descriptor();
assertThat(grpcDescriptor, is(notNullValue()));
assertThat(grpcDescriptor.getFullMethodName(), is("ServiceOne/foo/unary"));
assertThat(grpcDescriptor.getType(), is(io.grpc.MethodDescriptor.MethodType.UNARY));
assertThat(grpcDescriptor.getRequestMarshaller(), is(instanceOf(JavaMarshaller.class)));
assertThat(grpcDescriptor.getResponseMarshaller(), is(instanceOf(JavaMarshaller.class)));
ClientMethodDescriptor = descriptor.method("clientStreaming");
assertThat(ClientMethodDescriptor, is(notNullValue()));
assertThat(ClientMethodDescriptor.name(), is("clientStreaming"));
grpcDescriptor = ClientMethodDescriptor.descriptor();
assertThat(grpcDescriptor, is(notNullValue()));
assertThat(grpcDescriptor.getFullMethodName(), is("ServiceOne/foo/clientStreaming"));
assertThat(grpcDescriptor.getType(), is(io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING));
assertThat(grpcDescriptor.getRequestMarshaller(), is(instanceOf(JavaMarshaller.class)));
assertThat(grpcDescriptor.getResponseMarshaller(), is(instanceOf(JavaMarshaller.class)));
ClientMethodDescriptor = descriptor.method("serverStreaming");
assertThat(ClientMethodDescriptor, is(notNullValue()));
assertThat(ClientMethodDescriptor.name(), is("serverStreaming"));
grpcDescriptor = ClientMethodDescriptor.descriptor();
assertThat(grpcDescriptor, is(notNullValue()));
assertThat(grpcDescriptor.getFullMethodName(), is("ServiceOne/foo/serverStreaming"));
assertThat(grpcDescriptor.getType(), is(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING));
assertThat(grpcDescriptor.getRequestMarshaller(), is(instanceOf(JavaMarshaller.class)));
assertThat(grpcDescriptor.getResponseMarshaller(), is(instanceOf(JavaMarshaller.class)));
ClientMethodDescriptor = descriptor.method("bidiStreaming");
assertThat(ClientMethodDescriptor, is(notNullValue()));
assertThat(ClientMethodDescriptor.name(), is("bidiStreaming"));
grpcDescriptor = ClientMethodDescriptor.descriptor();
assertThat(grpcDescriptor, is(notNullValue()));
assertThat(grpcDescriptor.getFullMethodName(), is("ServiceOne/foo/bidiStreaming"));
assertThat(grpcDescriptor.getType(), is(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING));
assertThat(grpcDescriptor.getRequestMarshaller(), is(instanceOf(JavaMarshaller.class)));
assertThat(grpcDescriptor.getResponseMarshaller(), is(instanceOf(JavaMarshaller.class)));
}
use of io.helidon.grpc.client.ClientMethodDescriptor in project helidon by oracle.
the class GrpcClientBuilderTest method shouldCreateServiceWithMethodNamesFromAnnotation.
@Test
public void shouldCreateServiceWithMethodNamesFromAnnotation() {
ServiceTwo service = new ServiceTwo();
GrpcClientBuilder builder = GrpcClientBuilder.create(service);
ClientServiceDescriptor.Builder descriptorBuilder = builder.build();
ClientServiceDescriptor descriptor = descriptorBuilder.build();
assertThat(descriptor.name(), is("ServiceTwo"));
assertThat(descriptor.methods().size(), is(4));
ClientMethodDescriptor ClientMethodDescriptor;
io.grpc.MethodDescriptor grpcDescriptor;
ClientMethodDescriptor = descriptor.method("One");
assertThat(ClientMethodDescriptor, is(notNullValue()));
assertThat(ClientMethodDescriptor.name(), is("One"));
grpcDescriptor = ClientMethodDescriptor.descriptor();
assertThat(grpcDescriptor, is(notNullValue()));
assertThat(grpcDescriptor.getFullMethodName(), is("ServiceTwo/One"));
assertThat(grpcDescriptor.getType(), is(io.grpc.MethodDescriptor.MethodType.UNARY));
assertThat(grpcDescriptor.getRequestMarshaller(), is(instanceOf(JavaMarshaller.class)));
assertThat(grpcDescriptor.getResponseMarshaller(), is(instanceOf(JavaMarshaller.class)));
ClientMethodDescriptor = descriptor.method("Two");
assertThat(ClientMethodDescriptor, is(notNullValue()));
assertThat(ClientMethodDescriptor.name(), is("Two"));
grpcDescriptor = ClientMethodDescriptor.descriptor();
assertThat(grpcDescriptor, is(notNullValue()));
assertThat(grpcDescriptor.getFullMethodName(), is("ServiceTwo/Two"));
assertThat(grpcDescriptor.getType(), is(io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING));
assertThat(grpcDescriptor.getRequestMarshaller(), is(instanceOf(JavaMarshaller.class)));
assertThat(grpcDescriptor.getResponseMarshaller(), is(instanceOf(JavaMarshaller.class)));
ClientMethodDescriptor = descriptor.method("Three");
assertThat(ClientMethodDescriptor, is(notNullValue()));
assertThat(ClientMethodDescriptor.name(), is("Three"));
grpcDescriptor = ClientMethodDescriptor.descriptor();
assertThat(grpcDescriptor, is(notNullValue()));
assertThat(grpcDescriptor.getFullMethodName(), is("ServiceTwo/Three"));
assertThat(grpcDescriptor.getType(), is(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING));
assertThat(grpcDescriptor.getRequestMarshaller(), is(instanceOf(JavaMarshaller.class)));
assertThat(grpcDescriptor.getResponseMarshaller(), is(instanceOf(JavaMarshaller.class)));
ClientMethodDescriptor = descriptor.method("Four");
assertThat(ClientMethodDescriptor, is(notNullValue()));
assertThat(ClientMethodDescriptor.name(), is("Four"));
grpcDescriptor = ClientMethodDescriptor.descriptor();
assertThat(grpcDescriptor, is(notNullValue()));
assertThat(grpcDescriptor.getFullMethodName(), is("ServiceTwo/Four"));
assertThat(grpcDescriptor.getType(), is(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING));
assertThat(grpcDescriptor.getRequestMarshaller(), is(instanceOf(JavaMarshaller.class)));
assertThat(grpcDescriptor.getResponseMarshaller(), is(instanceOf(JavaMarshaller.class)));
}
Aggregations