Search in sources :

Example 1 with PactFolder

use of au.com.dius.pact.provider.junit.loader.PactFolder 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;
}
Also used : PactBroker(au.com.dius.pact.provider.junit.loader.PactBroker) Pact(au.com.dius.pact.model.Pact) ConsumerInfo(au.com.dius.pact.provider.ConsumerInfo) MethodClosure(org.codehaus.groovy.runtime.MethodClosure) URL(java.net.URL) PactVerification(au.com.dius.pact.provider.PactVerification) IOException(java.io.IOException) HashMap(java.util.HashMap) Interaction(au.com.dius.pact.model.Interaction) PactFolderLoader(au.com.dius.pact.provider.junit.loader.PactFolderLoader) Provider(au.com.dius.pact.provider.junit.Provider) Collectors(java.util.stream.Collectors) File(java.io.File) URLClassLoader(java.net.URLClassLoader) List(java.util.List) ProviderVerifier(au.com.dius.pact.provider.ProviderVerifier) ProviderInfo(au.com.dius.pact.provider.ProviderInfo) Map(java.util.Map) PactFolder(au.com.dius.pact.provider.junit.loader.PactFolder) Collections(java.util.Collections) ConsumerInfo(au.com.dius.pact.provider.ConsumerInfo) ProviderInfo(au.com.dius.pact.provider.ProviderInfo) PactFolderLoader(au.com.dius.pact.provider.junit.loader.PactFolderLoader) PactBroker(au.com.dius.pact.provider.junit.loader.PactBroker) PactFolder(au.com.dius.pact.provider.junit.loader.PactFolder) List(java.util.List) IOException(java.io.IOException) HashMap(java.util.HashMap) Map(java.util.Map) Provider(au.com.dius.pact.provider.junit.Provider)

Aggregations

Interaction (au.com.dius.pact.model.Interaction)1 Pact (au.com.dius.pact.model.Pact)1 ConsumerInfo (au.com.dius.pact.provider.ConsumerInfo)1 PactVerification (au.com.dius.pact.provider.PactVerification)1 ProviderInfo (au.com.dius.pact.provider.ProviderInfo)1 ProviderVerifier (au.com.dius.pact.provider.ProviderVerifier)1 Provider (au.com.dius.pact.provider.junit.Provider)1 PactBroker (au.com.dius.pact.provider.junit.loader.PactBroker)1 PactFolder (au.com.dius.pact.provider.junit.loader.PactFolder)1 PactFolderLoader (au.com.dius.pact.provider.junit.loader.PactFolderLoader)1 File (java.io.File)1 IOException (java.io.IOException)1 URL (java.net.URL)1 URLClassLoader (java.net.URLClassLoader)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 MethodClosure (org.codehaus.groovy.runtime.MethodClosure)1