GrpcDocServicePlugin implements DocServicePlugin { @VisibleForTesting static MethodInfo newMethodInfo(MethodDescriptor method, ServiceEntry service) { final Set<EndpointInfo> methodEndpoints = service.endpointInfos.stream() .map(e -> { final EndpointInfoBuilder builder = EndpointInfo.builder( e.hostnamePattern(), e.pathMapping() + method.getName()); if (e.fragment() != null) { builder.fragment(e.fragment()); } if (e.defaultMimeType() != null) { builder.defaultMimeType(e.defaultMimeType()); } return builder.availableMimeTypes(e.availableMimeTypes()).build(); }) .collect(toImmutableSet()); return new MethodInfo( method.getName(), namedMessageSignature(method.getOutputType()), ImmutableList.of(FieldInfo.builder("request", namedMessageSignature(method.getInputType())) .requirement(FieldRequirement.REQUIRED).build()), ImmutableList.of(), methodEndpoints, ImmutableList.of(), defaultExamples(method), ImmutableList.of(), ImmutableList.of(), HttpMethod.POST, null); }  @Override String name(); @Override Set<Class<? extends Service<?, ?>>> supportedServiceTypes(); @Override ServiceSpecification generateSpecification(Set<ServiceConfig> serviceConfigs,
                                                      DocServiceFilter filter); @Override Map<String, String> loadDocStrings(Set<ServiceConfig> serviceConfigs); @Override Set<Class<?>> supportedExampleRequestTypes(); @Override String serializeExampleRequest(String serviceName, String methodName,
                                          Object exampleRequest);  }
@Test void newMethodInfo() throws Exception { final MethodInfo methodInfo = GrpcDocServicePlugin.newMethodInfo( TEST_SERVICE_DESCRIPTOR.findMethodByName("UnaryCall"), new ServiceEntry( TEST_SERVICE_DESCRIPTOR, ImmutableList.of( EndpointInfo.builder("*", "/foo/") .availableFormats(GrpcSerializationFormats.PROTO) .build(), EndpointInfo.builder("*", "/debug/foo/") .availableFormats(GrpcSerializationFormats.JSON) .build()))); assertThat(methodInfo.name()).isEqualTo("UnaryCall"); assertThat(methodInfo.returnTypeSignature().name()).isEqualTo("armeria.grpc.testing.SimpleResponse"); assertThat(methodInfo.returnTypeSignature().namedTypeDescriptor()) .isEqualTo(SimpleResponse.getDescriptor()); assertThat(methodInfo.parameters()).hasSize(1); assertThat(methodInfo.parameters().get(0).name()).isEqualTo("request"); assertThat(methodInfo.parameters().get(0).typeSignature().name()) .isEqualTo("armeria.grpc.testing.SimpleRequest"); assertThat(methodInfo.parameters().get(0).typeSignature().namedTypeDescriptor()) .isEqualTo(SimpleRequest.getDescriptor()); assertThat(methodInfo.exceptionTypeSignatures()).isEmpty(); assertThat(methodInfo.docString()).isNull(); assertThat(methodInfo.endpoints()).containsExactlyInAnyOrder( EndpointInfo.builder("*", "/foo/UnaryCall") .availableFormats(GrpcSerializationFormats.PROTO) .build(), EndpointInfo.builder("*", "/debug/foo/UnaryCall") .availableFormats(GrpcSerializationFormats.JSON) .build()); }