Home > Software design >  is there any way to download pact contract (.json) file from pact broker using java?
is there any way to download pact contract (.json) file from pact broker using java?

Time:08-05

by using Java, i am trying to download pact contract on provider side. Please suggest any way or tool to Download contract from pact broker on provider side.

CodePudding user response:

by using below dependency in java project (i have used gradle)

implementation group: 'au.com.dius', name: 'pact-jvm-provider-junit_2.11', version: '2.4.3'

and use below code to print contract

String provider = "PrintChartProvider";
        au.com.dius.pact.provider.junit.loader.PactBrokerLoader pactBrokerLoader = new au.com.dius.pact.provider.junit.loader.PactBrokerLoader("localhost", 8101,"http");
        System.out.println(pactBrokerLoader.load(provider));

to get a contract in file, simply write that text into any file using FileWriter

CodePudding user response:

Could you please elaborate on the use case as to why you want to download the contract on the provider side? Once you download the pact file, what are you planning on doing with it?

For verification, there are other recommended means.

  • Related