Search in sources :

Example 1 with MockGrpcMethodView

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;
}
Also used : MethodConfig(com.google.api.codegen.config.MethodConfig) MethodModel(com.google.api.codegen.config.MethodModel) MockGrpcMethodView(com.google.api.codegen.viewmodel.testing.MockGrpcMethodView) ArrayList(java.util.ArrayList)

Aggregations

MethodConfig (com.google.api.codegen.config.MethodConfig)1 MethodModel (com.google.api.codegen.config.MethodModel)1 MockGrpcMethodView (com.google.api.codegen.viewmodel.testing.MockGrpcMethodView)1 ArrayList (java.util.ArrayList)1