use of com.google.api.codegen.viewmodel.testing.MockGrpcMethodView in project toolkit by googleapis.
the class MockServiceTransformer method createMockGrpcMethodViews.
public List<MockGrpcMethodView> createMockGrpcMethodViews(InterfaceContext context) {
if (!context.getProductConfig().getTransportProtocol().equals(TransportProtocol.GRPC)) {
return ImmutableList.of();
}
List<MethodModel> methods = context.getInterfaceMethods();
ArrayList<MockGrpcMethodView> mocks = new ArrayList<>(methods.size());
for (MethodModel method : methods) {
if (context.getMethodConfig(method) == null) {
continue;
}
MethodContext methodContext = context.asRequestMethodContext(method);
String requestTypeName = method.getAndSaveRequestTypeName(methodContext.getTypeTable(), methodContext.getNamer());
String responseTypeName = method.getAndSaveResponseTypeName(methodContext.getTypeTable(), methodContext.getNamer());
MethodConfig methodConfig = methodContext.getMethodConfig();
mocks.add(MockGrpcMethodView.newBuilder().name(methodContext.getNamer().getApiMethodName(method, VisibilityConfig.PUBLIC)).requestTypeName(requestTypeName).responseTypeName(responseTypeName).grpcStreamingType(methodConfig.getGrpcStreamingType()).streamHandleTypeName(methodContext.getNamer().getStreamingServerName(method)).build());
}
return mocks;
}
Aggregations