how test a gRPC endpoint that returns com.google.type.Money

Viewed 1959

I want manually test the bellow gRPC endpoint which returns com.google.type.Money. I am quite new to gRPC/proto world and I have manually tested them with BloomRPC. So far so good. But now there is a specific field type and BloomRPC is complaining with

Error while importing protos
no such Type or Enum 'google.type.Money' 

It seems it can't parse google.type.Money. Any clue how I could test my gRPC endpoint manually?

proto file:

syntax = "proto3";

    package com.mycomp.adapters.grpc.test;
    
    import "google/api/annotations.proto";
    import "google/type/money.proto";
    
    service TestService {
    
      rpc GetTest (GetTestRequest) returns (Test) {
      }
    }
    
    message GetTestRequest{
        string id_cliente = 1;
    }
    
    message Test {
      string id_cliente = 1;
      google.type.Money test_money = 2;
    }

gRPC endpoint

import com.google.type.Money
...other imports

@Singleton
class TestEndpoint() : TestServiceGrpcKt.TestServiceCoroutineImplBase() {

    override suspend fun getTest(request: GetTestRequest): Test {

        val test = Test.newBuilder()

        ...
        
        test.testMoney = Money.newBuilder()
           .setCurrencyCode("USD")
           .setUnits(999)
           .build();

        return test.build()
    }

build.gradle dependencies

dependencies {
    implementation("io.micronaut:micronaut-validation")
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}")
    implementation("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
    implementation("io.micronaut.kotlin:micronaut-kotlin-runtime")
    implementation("io.micronaut:micronaut-runtime")
    runtimeOnly("com.fasterxml.jackson.module:jackson-module-kotlin")

    implementation("io.micronaut:micronaut-http-client")
    
    implementation ("com.google.api.grpc:proto-google-common-protos:1.0.0")
}
1 Answers

The location to be added to "Import Paths" is expected to be a directory relative to which the path will be resolved (and not the path of protobuf file or the directory in which it is present).

Eg. If my extracted protobuf file's location is /home/lorefnon/Workspace/sample-project/spi/build/extracted-include-protos/main/google/type/money.proto then the import path to be added is /home/lorefnon/Workspace/sample-project/spi/build/extracted-include-protos/main relative to which the path google/type/money.proto can be resolved.

Related