Class PactBrokerClient
-
- All Implemented Interfaces:
-
au.com.dius.pact.core.pactbroker.IPactBrokerClient
public class PactBrokerClient implements IPactBrokerClient
Client for the pact broker service
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classPactBrokerClient.Companion
-
Field Summary
Fields Modifier and Type Field Description public final static StringLATEST_PROVIDER_PACTS_WITH_NO_TAGpublic final static StringLATEST_PROVIDER_PACTSpublic final static StringLATEST_PROVIDER_PACTS_WITH_TAGpublic final static StringPROVIDER_PACTS_FOR_VERIFICATIONpublic final static StringBETA_PROVIDER_PACTS_FOR_VERIFICATIONpublic final static StringPROVIDERpublic final static StringPROVIDER_TAG_VERSIONpublic final static StringPROVIDER_BRANCH_VERSIONpublic final static StringPACTSpublic final static StringUTF8public final static StringPUBLISH_CONTRACTS_LINKprivate final StringpactBrokerUrlprivate final Map<String, Object>optionsprivate final PactBrokerClientConfigconfigpublic final static PactBrokerClient.CompanionCompanion
-
Constructor Summary
Constructors Constructor Description PactBrokerClient(String pactBrokerUrl)PactBrokerClient(String pactBrokerUrl, Map<String, Object> options, PactBrokerClientConfig config)
-
Method Summary
Modifier and Type Method Description final StringgetPactBrokerUrl()Map<String, Object>getOptions()final PactBrokerClientConfiggetConfig()List<PactBrokerResult>fetchConsumers(String provider)Fetches all consumers for the given provider List<PactBrokerResult>fetchConsumersWithTag(String provider, String tag)Fetches all consumers for the given provider and tag Result<List<PactBrokerResult>, Exception>fetchConsumersWithSelectors(String providerName, List<ConsumerVersionSelector> selectors, List<String> providerTags, String providerBranch, Boolean enablePending, String includeWipPactsSince)Fetches all consumers for the given provider and selectors. Result<List<PactBrokerResult>, Exception>fetchConsumersWithSelectorsV2(String providerName, List<ConsumerVersionSelectors> selectors, List<String> providerTags, String providerBranch, Boolean enablePending, String includeWipPactsSince)Fetches all consumers for the given provider and selectors. Result<String, Exception>uploadPactFile(File pactFile, String version)Uploads the given pact file to the broker, and optionally applies any tags Result<String, Exception>uploadPactFile(File pactFile, String version, List<String> tags)Uploads the given pact file to the broker, and optionally applies any tags Result<String, Exception>uploadPactFile(File pactFile, PublishConfiguration config)Uploads the given pact file to the broker and applies any tags/Branch final Result<JsonValue.Object, Exception>publishContract(IHalClient halClient, String providerName, String consumerName, PublishConfiguration config, String pactText)Publish the contract using the "Publish Contracts" endpoint StringgetUrlForProvider(String providerName, String tag)PactResponsefetchPact(String url, Boolean encodePath)IHalClientnewHalClient()Result<Boolean, String>publishVerificationResults(Map<String, Object> docAttributes, TestResult result, String version)Publishes the result to the "pb:publish-verification-results" link in the document attributes. Result<Boolean, String>publishVerificationResults(Map<String, Object> docAttributes, TestResult result, String version, String buildUrl)Publishes the result to the "pb:publish-verification-results" link in the document attributes. final JsonValue.ObjectbuildPayload(TestResult result, String version, String buildUrl)List<PactBrokerResult>fetchLatestConsumersWithNoTag(String provider)Fetches the consumers of the provider that have no associated tag final UnitpublishProviderTag(Map<String, Object> docAttributes, String name, String tag, String version)Result<Boolean, List<String>>publishProviderTags(Map<String, Object> docAttributes, String name, List<String> tags, String version)Publish all the tags for the provider to the Pact broker Result<Boolean, String>publishProviderBranch(Map<String, Object> docAttributes, String name, String branch, String version)Publish provider branch to the Pact broker CanIDeployResultcanIDeploy(String pacticipant, String pacticipantVersion, Latest latest, To to, List<IgnoreSelector> ignore)CanIDeployResultcanIDeploy(String pacticipant, String pacticipantVersion, Latest latest, To to)Result<String, Exception>createVersionTag(String pacticipant, String pacticipantVersion, String tag)final static StringinternalBuildMatrixQuery(String pacticipant, String pacticipantVersion, Latest latest, To to, List<IgnoreSelector> ignore)Internal: Public for testing -
-
Method Detail
-
getPactBrokerUrl
final String getPactBrokerUrl()
-
getOptions
Map<String, Object> getOptions()
-
getConfig
final PactBrokerClientConfig getConfig()
-
fetchConsumers
@Deprecated(message = "Use the version that takes selectors instead", replaceWith = @ReplaceWith(imports = {}, expression = "fetchConsumersWithSelectors")) List<PactBrokerResult> fetchConsumers(String provider)
Fetches all consumers for the given provider
-
fetchConsumersWithTag
@Deprecated(message = "Use fetchConsumersWithSelectors") List<PactBrokerResult> fetchConsumersWithTag(String provider, String tag)
Fetches all consumers for the given provider and tag
-
fetchConsumersWithSelectors
Result<List<PactBrokerResult>, Exception> fetchConsumersWithSelectors(String providerName, List<ConsumerVersionSelector> selectors, List<String> providerTags, String providerBranch, Boolean enablePending, String includeWipPactsSince)
Fetches all consumers for the given provider and selectors. If
pactbroker.consumerversionselectors.rawjsonis set as a system property or environment variable, that will override the selectors provided to this method.
-
fetchConsumersWithSelectorsV2
Result<List<PactBrokerResult>, Exception> fetchConsumersWithSelectorsV2(String providerName, List<ConsumerVersionSelectors> selectors, List<String> providerTags, String providerBranch, Boolean enablePending, String includeWipPactsSince)
Fetches all consumers for the given provider and selectors. If
pactbroker.consumerversionselectors.rawjsonis set as a system property or environment variable, that will override the selectors provided to this method.
-
uploadPactFile
Result<String, Exception> uploadPactFile(File pactFile, String version)
Uploads the given pact file to the broker, and optionally applies any tags
-
uploadPactFile
Result<String, Exception> uploadPactFile(File pactFile, String version, List<String> tags)
Uploads the given pact file to the broker, and optionally applies any tags
-
uploadPactFile
Result<String, Exception> uploadPactFile(File pactFile, PublishConfiguration config)
Uploads the given pact file to the broker and applies any tags/Branch
-
publishContract
final Result<JsonValue.Object, Exception> publishContract(IHalClient halClient, String providerName, String consumerName, PublishConfiguration config, String pactText)
Publish the contract using the "Publish Contracts" endpoint
-
getUrlForProvider
String getUrlForProvider(String providerName, String tag)
-
fetchPact
PactResponse fetchPact(String url, Boolean encodePath)
-
newHalClient
IHalClient newHalClient()
-
publishVerificationResults
Result<Boolean, String> publishVerificationResults(Map<String, Object> docAttributes, TestResult result, String version)
Publishes the result to the "pb:publish-verification-results" link in the document attributes.
-
publishVerificationResults
Result<Boolean, String> publishVerificationResults(Map<String, Object> docAttributes, TestResult result, String version, String buildUrl)
Publishes the result to the "pb:publish-verification-results" link in the document attributes.
-
buildPayload
final JsonValue.Object buildPayload(TestResult result, String version, String buildUrl)
-
fetchLatestConsumersWithNoTag
@Deprecated(message = "Use the version that takes selectors instead", replaceWith = @ReplaceWith(imports = {}, expression = "fetchConsumersWithSelectors")) List<PactBrokerResult> fetchLatestConsumersWithNoTag(String provider)
Fetches the consumers of the provider that have no associated tag
-
publishProviderTag
@Deprecated(message = "Use publishProviderTags", replaceWith = @ReplaceWith(imports = {}, expression = "publishProviderTags")) final Unit publishProviderTag(Map<String, Object> docAttributes, String name, String tag, String version)
-
publishProviderTags
Result<Boolean, List<String>> publishProviderTags(Map<String, Object> docAttributes, String name, List<String> tags, String version)
Publish all the tags for the provider to the Pact broker
- Parameters:
docAttributes- Attributes associated with the fetched Pact filename- Provider nametags- Provider tags to tag the provider withversion- Provider version
-
publishProviderBranch
Result<Boolean, String> publishProviderBranch(Map<String, Object> docAttributes, String name, String branch, String version)
Publish provider branch to the Pact broker
- Parameters:
docAttributes- Attributes associated with the fetched Pact filename- Provider namebranch- Provider branchversion- Provider version
-
canIDeploy
@JvmOverloads() CanIDeployResult canIDeploy(String pacticipant, String pacticipantVersion, Latest latest, To to, List<IgnoreSelector> ignore)
-
canIDeploy
@JvmOverloads() CanIDeployResult canIDeploy(String pacticipant, String pacticipantVersion, Latest latest, To to)
-
createVersionTag
Result<String, Exception> createVersionTag(String pacticipant, String pacticipantVersion, String tag)
-
internalBuildMatrixQuery
final static String internalBuildMatrixQuery(String pacticipant, String pacticipantVersion, Latest latest, To to, List<IgnoreSelector> ignore)
Internal: Public for testing
-
-
-
-