use of io.helidon.grpc.server.ServiceDescriptor in project helidon by oracle.
the class MetricsConfigurerTest method shouldIgnoreSimpleTimerMetricFromInterfaceAnnotation.
@Test
public void shouldIgnoreSimpleTimerMetricFromInterfaceAnnotation() {
Class<?> serviceClass = ServiceTwoImpl.class;
Class<?> annotatedClass = ServiceTwo.class;
ServiceDescriptor.Builder builder = ServiceDescriptor.builder(new ServiceTwoImpl());
MetricsConfigurer configurer = new MetricsConfigurer();
configurer.accept(serviceClass, annotatedClass, builder);
ServiceDescriptor descriptor = builder.build();
List<ServerInterceptor> serviceInterceptors = descriptor.interceptors().stream().collect(Collectors.toList());
MethodDescriptor<?, ?> methodDescriptor = descriptor.method("simplyTimed");
List<ServerInterceptor> methodInterceptors = methodDescriptor.interceptors().stream().collect(Collectors.toList());
assertThat(serviceInterceptors, is(emptyIterable()));
assertThat(methodInterceptors, is(emptyIterable()));
}
use of io.helidon.grpc.server.ServiceDescriptor in project helidon by oracle.
the class MetricsConfigurerTest method shouldAddCounterMetricFromClassAnnotation.
@Test
public void shouldAddCounterMetricFromClassAnnotation() {
Class<?> serviceClass = ServiceOne.class;
Class<?> annotatedClass = ServiceOne.class;
ServiceDescriptor.Builder builder = ServiceDescriptor.builder(new ServiceOne());
MetricsConfigurer configurer = new MetricsConfigurer();
configurer.accept(serviceClass, annotatedClass, builder);
ServiceDescriptor descriptor = builder.build();
List<ServerInterceptor> serviceInterceptors = descriptor.interceptors().stream().collect(Collectors.toList());
MethodDescriptor<?, ?> methodDescriptor = descriptor.method("counted");
List<ServerInterceptor> methodInterceptors = methodDescriptor.interceptors().stream().collect(Collectors.toList());
assertThat(serviceInterceptors, is(emptyIterable()));
assertThat(methodInterceptors.size(), is(1));
assertThat(methodInterceptors.get(0), is(instanceOf(GrpcMetrics.class)));
assertThat(((GrpcMetrics) methodInterceptors.get(0)).metricType(), is(MetricType.COUNTER));
assertThat(updReg().getCounters().get(new MetricID(ServiceOne.class.getName() + ".counted")), is(notNullValue()));
}
use of io.helidon.grpc.server.ServiceDescriptor in project helidon by oracle.
the class GrpcServiceBuilderTest method assertSingleton.
@SuppressWarnings("unchecked")
public void assertSingleton(GrpcServiceBuilder builder) {
ServiceDescriptor descriptor = builder.build();
MethodDescriptor methodDescriptor = descriptor.method("unary");
ServerCallHandler handler = methodDescriptor.callHandler();
ServerCall<String, ServiceFive> callOne = mock(ServerCall.class);
ServerCall<String, ServiceFive> callTwo = mock(ServerCall.class);
when(callOne.getMethodDescriptor()).thenReturn(methodDescriptor.descriptor());
when(callTwo.getMethodDescriptor()).thenReturn(methodDescriptor.descriptor());
ServerCall.Listener listenerOne = handler.startCall(callOne, new Metadata());
ServerCall.Listener listenerTwo = handler.startCall(callTwo, new Metadata());
listenerOne.onMessage("foo");
listenerOne.onHalfClose();
listenerTwo.onMessage("foo");
listenerTwo.onHalfClose();
ArgumentCaptor<ServiceFive> captorOne = ArgumentCaptor.forClass(ServiceFive.class);
ArgumentCaptor<ServiceFive> captorTwo = ArgumentCaptor.forClass(ServiceFive.class);
verify(callOne).sendMessage(captorOne.capture());
verify(callTwo).sendMessage(captorTwo.capture());
assertThat(captorOne.getValue(), is(sameInstance(captorTwo.getValue())));
}
use of io.helidon.grpc.server.ServiceDescriptor in project helidon by oracle.
the class GrpcServiceBuilderTest method shouldCreateDescriptorFoServiceWithNestedGenericParameters.
@Test
public void shouldCreateDescriptorFoServiceWithNestedGenericParameters() {
GrpcServiceBuilder modeller = GrpcServiceBuilder.create(ServiceSix.class, beanManager);
ServiceDescriptor descriptor = modeller.build();
assertThat(descriptor.name(), is(ServiceSix.class.getSimpleName()));
}
use of io.helidon.grpc.server.ServiceDescriptor in project helidon by oracle.
the class GrpcServiceBuilderTest method shouldUseDefaultServiceName.
@Test
public void shouldUseDefaultServiceName() {
ServiceTwo service = new ServiceTwo();
GrpcServiceBuilder modeller = GrpcServiceBuilder.create(service, beanManager);
ServiceDescriptor descriptor = modeller.build();
assertThat(descriptor.name(), is("ServiceTwo"));
}
Aggregations