use of au.com.dius.pact.provider.broker.PactBrokerClient in project pact-jvm by DiUS.
the class PactBrokerLoader method loadPactsForProvider.
private List<Pact> loadPactsForProvider(final String providerName, final String tag) throws IOException {
LOGGER.debug("Loading pacts from pact broker for provider " + providerName + " and tag " + tag);
URIBuilder uriBuilder = new URIBuilder().setScheme(parseExpressions(pactBrokerProtocol)).setHost(parseExpressions(pactBrokerHost)).setPort(Integer.parseInt(parseExpressions(pactBrokerPort)));
try {
List<ConsumerInfo> consumers;
PactBrokerClient pactBrokerClient = newPactBrokerClient(uriBuilder.build());
if (StringUtils.isEmpty(tag)) {
consumers = pactBrokerClient.fetchConsumers(providerName);
} else {
consumers = pactBrokerClient.fetchConsumersWithTag(providerName, tag);
}
if (failIfNoPactsFound && consumers.isEmpty()) {
throw new NoPactsFoundException("No consumer pacts were found for provider '" + providerName + "' and tag '" + tag + "'. (URL " + pactBrokerClient.getUrlForProvider(providerName, tag) + ")");
}
return consumers.stream().map(consumer -> this.loadPact(consumer, pactBrokerClient.getOptions())).collect(toList());
} catch (URISyntaxException e) {
throw new IOException("Was not able load pacts from broker as the broker URL was invalid", e);
}
}
Aggregations