use of au.com.dius.pact.provider.junit.Provider 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;
}
use of au.com.dius.pact.provider.junit.Provider in project pact-jvm by DiUS.
the class HttpTarget method getProviderInfo.
protected ProviderInfo getProviderInfo() {
Provider provider = testClass.getAnnotation(Provider.class);
final ProviderInfo providerInfo = new ProviderInfo(provider.value());
providerInfo.setPort(port);
providerInfo.setHost(host);
providerInfo.setProtocol(protocol);
providerInfo.setPath(path);
providerInfo.setInsecure(insecure);
if (testClass != null) {
final List<FrameworkMethod> methods = testClass.getAnnotatedMethods(TargetRequestFilter.class);
if (!methods.isEmpty()) {
providerInfo.setRequestFilter((Consumer<HttpRequest>) httpRequest -> methods.forEach(method -> {
try {
method.invokeExplosively(testTarget, httpRequest);
} catch (Throwable t) {
throw new AssertionError("Request filter method " + method.getName() + " failed with an exception", t);
}
}));
}
}
return providerInfo;
}
use of au.com.dius.pact.provider.junit.Provider in project pact-jvm by DiUS.
the class MockMvcTarget method getProviderInfo.
@Override
protected ProviderInfo getProviderInfo() {
Provider provider = testClass.getAnnotation(Provider.class);
final ProviderInfo providerInfo = new ProviderInfo(provider.value());
if (testClass != null) {
final List<FrameworkMethod> methods = testClass.getAnnotatedMethods(TargetRequestFilter.class);
if (!methods.isEmpty()) {
providerInfo.setRequestFilter((Consumer<HttpRequest>) httpRequest -> methods.forEach(method -> {
try {
method.invokeExplosively(testTarget, httpRequest);
} catch (Throwable t) {
throw new AssertionError("Request filter method " + method.getName() + " failed with an exception", t);
}
}));
}
}
return providerInfo;
}
Aggregations