最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

protocol buffers - PACT framework didn't generate all test methods into .json file - Stack Overflow

programmeradmin4浏览0评论
My java class    
@Pact(consumer = "P01819-ipa-mi")
    public V4Pact tradesByFilterProductTypeFXFWD(PactBuilder builder) throws InterruptedException {
        return builder
                .usingPlugin("protobuf")
                .expectsToReceive("a get trade by filter request", "core/interaction/synchronous-message")
                .with(Map.of(
                        "pact:proto", filePath("proto/tsServiceV2.proto"),
                        "pact:content-type", "application/grpc",
                        "pact:proto-service", "TradeStoreService/GetTradesByFilter",
                        "pact:protobuf-config", Map.of(
                                "additionalIncludes",
                                List.of(filePath("proto/tsService.proto"))),

                        // Details on the request message
                        "request", Map.of(
                                "productTypes",
                                Map.of("value",
                                        "matching(equalTo, 'FXFWD')")),

                        // Details on the response
                        "response",
                        Map.of("trade_key",
                                Map.of("product_type", "matching(equalTo, 'FXFWD')")))
                ).toPact();
    }

My Test

@Test
    @PactTestFor(pactMethod = "tradesByFilterProductTypeFXFWD")
    @MockServerConfig(implementation = MockServerImplementation.Plugin, registryEntry = "protobuf/transport/grpc")
    void testTradesByFilterProductTypeFXFWD(MockServer mockServer, V4Interaction.SynchronousMessages interaction) throws InvalidProtocolBufferException {
        boolean success = false;
        ManagedChannel channel = ManagedChannelBuilder.forTarget("127.0.0.1:" + mockServer.getPort())
                .usePlaintext()
                .build();
        try {
            TradeStoreServiceGrpc.TradeStoreServiceBlockingStub stub = TradeStoreServiceGrpc.newBlockingStub(channel);

            ts.api.TsServiceV2.TradeFilter tradeFilter = ts.api.TsServiceV2.TradeFilter.parseFrom(interaction.getRequest().getContents().getValue());

            Iterator<TsService.Trade> responseTrade = stub.getTradesByFilter(tradeFilter);
            Thread.sleep(10000);
            assertThat(responseTrade).as("getTradeByFilter is null").isNotNull();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        } finally {
            if (!success) {
                channel.shutdown();
            }
        }
    }
An error2025-02-17 10:52:31,966 ERROR [main] [:] io.pact.plugins.jvm.core.DefaultPluginManager: Failed to initialise the plugin
io.grpc.StatusRuntimeException: UNAVAILABLE: io exception   
at com.ing.ipami.pact.product_type.GetTradesByFilterProductTypeFXFWDTest.tradesByFilterProductTypeFXFWDONE(GetTradesByFilterProductTypeFXFWDTest.java:99)
Caused by: io.grpcty.shaded.ioty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: getsockopt: /[0:0:0:0:0:0:0:1]:64265

And in the result I have .json file with generated only ONE test method

I can't understand what a problem... Protobuf plugin is installed protoc version protobuf version

  1. Mock server correctly started and i get a request and response
  2. .usingPlugin("protobuf") trying to debug this part...nothing helps
发布评论

评论列表(0)

  1. 暂无评论