use of au.com.dius.pact.provider.junit.loader.PactFolderLoader in project pact-jvm by DiUS.
the class AmqpTarget method getProviderInfo.
protected ProviderInfo getProviderInfo() {
Provider provider = testClass.getAnnotation(Provider.class);
ProviderInfo providerInfo = new ProviderInfo(provider.value());
providerInfo.setVerificationType(PactVerification.ANNOTATED_METHOD);
providerInfo.setPackagesToScan(packagesToScan);
PactBroker annotation = testClass.getAnnotation(PactBroker.class);
PactFolder folder = testClass.getAnnotation(PactFolder.class);
if (annotation != null && annotation.host() != null) {
List list = providerInfo.hasPactsFromPactBroker(annotation.protocol() + "://" + annotation.host() + (annotation.port() != null ? ":" + annotation.port() : ""));
providerInfo.setConsumers(list);
} else if (folder != null && folder.value() != null) {
try {
PactFolderLoader folderLoader = new PactFolderLoader(folder);
Map<Pact, File> pactFileMap = folderLoader.loadPactsWithFiles(providerInfo.getName());
providerInfo.setConsumers(pactFileMap.entrySet().stream().map(e -> new ConsumerInfo(e.getKey().getConsumer().getName(), e.getValue())).collect(Collectors.toList()));
} catch (IOException e) {
e.printStackTrace();
}
}
return providerInfo;
}
Aggregations