All Downloads are FREE. Search and download functionalities are using the official Maven repository.

Download JAR files tagged by level with all dependencies

Search JAR files by class name

SourceAnalyst from group io.github.leravolcevska (version 1.3.0)

The Source Analyst library is a powerful tool designed to streamline and expedite the tracking of traffic sources for mobile applications. This versatile library is aptly named "Source Analyst" and is an invaluable asset for app developers and marketers seeking to gain deeper insights into the performance of their advertising campaigns. With just one simple function call, Source Analyst empowers you to efficiently investigate the effectiveness of various advertising sources. Key Features: Effortless Tracking: Source Analyst simplifies the complex task of tracking the origins of traffic for your mobile app. No need for convoluted setups or extensive coding – one function is all it takes. Comprehensive Insights: Gain a comprehensive understanding of where your app's users are coming from. Whether it's through social media, search engines, referral links, or other channels, Source Analyst provides you with clear data on traffic sources. Performance Evaluation: Evaluate the performance of your advertising campaigns with precision. Discover which sources are driving the most valuable users to your app, helping you optimize your marketing efforts effectively. Time-Saving: Say goodbye to hours spent on manual data collection and analysis. Source Analyst automates the tracking process, freeing up your time to focus on making data-driven decisions. Customization: Tailor Source Analyst to your specific needs. Customize the library to track the metrics that matter most to your app's success. Real-time Data: Access real-time data, ensuring that you always have up-to-date insights into your traffic sources. Integration-Friendly: Seamlessly integrate Source Analyst into your existing mobile app infrastructure, whether you're developing for Android or iOS. User-Friendly: Source Analyst is designed with user-friendliness in mind. Its intuitive interface and straightforward documentation make it accessible to developers of all levels of expertise. How It Works: Using Source Analyst is as easy as calling a single function within your code. Simply integrate the library into your app, and you can begin tracking traffic sources immediately. From there, Source Analyst compiles and presents the data in a clear and organized manner, allowing you to make data-driven decisions with ease. In a world where understanding the origins of your app's traffic is essential for marketing success, Source Analyst is the go-to solution. Say goodbye to the complexity of tracking sources and embrace the simplicity and effectiveness of Source Analyst for your mobile app. Harness the power of Source Analyst and unlock a new level of insight into your app's performance today!

Group: io.github.leravolcevska Artifact: SourceAnalyst
Show all versions 
There is no JAR file uploaded. A download is not possible! Please choose another version.
0 downloads
Artifact SourceAnalyst
Group io.github.leravolcevska
Version 1.3.0
Last update 07. September 2023
Organization not specified
URL https://github.com/leravolcevska/SourceAnalyst
License MIT License
Dependencies amount 1
Dependencies kotlin-stdlib-jdk8,
There are maybe transitive dependencies!

commons-crypto from group org.apache.commons (version 1.2.0)

Apache Commons Crypto is a cryptographic library optimized with AES-NI (Advanced Encryption Standard New Instructions). It provides Java API for both cipher level and Java stream level. Developers can use it to implement high performance AES encryption/decryption with the minimum code and effort. Please note that Crypto doesn't implement the cryptographic algorithm such as AES directly. It wraps to OpenSSL or JCE which implement the algorithms. Features -------- 1. Cipher API for low level cryptographic operations. 2. Java stream API (CryptoInputStream/CryptoOutputStream) for high level stream encryption/decryption. 3. Both optimized with high performance AES encryption/decryption. (1400 MB/s - 1700 MB/s throughput in modern Xeon processors). 4. JNI-based implementation to achieve comparable performance to the native C/C++ version based on OpenSsl. 5. Portable across various operating systems (currently only Linux/MacOSX/Windows); Apache Commons Crypto loads the library according to your machine environment (it checks system properties, `os.name` and `os.arch`). 6. Simple usage. Add the commons-crypto-(version).jar file to your classpath. Export restrictions ------------------- This distribution includes cryptographic software. The country in which you currently reside may have restrictions on the import, possession, use, and/or re-export to another country, of encryption software. BEFORE using any encryption software, please check your country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted. See <http://www.wassenaar.org/> for more information. The U.S. Government Department of Commerce, Bureau of Industry and Security (BIS), has classified this software as Export Commodity Control Number (ECCN) 5D002.C.1, which includes information security software using or performing cryptographic functions with asymmetric algorithms. The form and manner of this Apache Software Foundation distribution makes it eligible for export under the License Exception ENC Technology Software Unrestricted (TSU) exception (see the BIS Export Administration Regulations, Section 740.13) for both object code and source code. The following provides more details on the included cryptographic software: * Commons Crypto use [Java Cryptography Extension](http://docs.oracle.com/javase/8/docs/technotes/guides/security/crypto/CryptoSpec.html) provided by Java * Commons Crypto link to and use [OpenSSL](https://www.openssl.org/) ciphers

Group: org.apache.commons Artifact: commons-crypto
Show all versions Show documentation Show source 
 

74 downloads
Artifact commons-crypto
Group org.apache.commons
Version 1.2.0
Last update 14. January 2023
Organization not specified
URL https://commons.apache.org/proper/commons-crypto/
License Apache License, Version 2.0
Dependencies amount 1
Dependencies jna,
There are maybe transitive dependencies!

HockeySDK from group net.hockeyapp.android (version 5.2.0)

HockeySDK-Android implements support for using HockeyApp in your Android application. The following features are currently supported: Collect crash reports:If your app crashes, a crash log is written to the device's storage. If the user starts the app again, they will be asked asked to submit the crash report to HockeyApp. This works for both beta and live apps, i.e. those submitted to Google Play or other app stores. Crash logs contain viable information for you to help resolve the issue. Furthermore, you as a developer can add additional information to the report as well. Update Alpha/Beta apps: The app will check with HockeyApp if a new version for your alpha/beta build is available. If yes, it will show a dialog to users and let them see the release notes, the version history and start the installation process right away. You can even force the installation of certain updates. User Metrics: Understand user behavior to improve your app. Track usage through daily and monthly active users. Monitor crash impacted users. Measure customer engagement through session count. Add custom tracking calls to learn which features your users are actually using. This feature requires a minimum API level of 14 (Android 4.x Ice Cream Sandwich). Feedback: Besides crash reports, collecting feedback from your users from within your app is a great option to help with improving your app. You act on and answer feedback directly from the HockeyApp backend. Authenticate: Identify and authenticate users against your registered testers with the HockeyApp backend.

Group: net.hockeyapp.android Artifact: HockeySDK
Show all versions Show documentation 
There is no JAR file uploaded. A download is not possible! Please choose another version.
0 downloads
Artifact HockeySDK
Group net.hockeyapp.android
Version 5.2.0
Last update 21. May 2019
Organization not specified
URL https://github.com/bitstadium/hockeysdk-android
License MIT
Dependencies amount 0
Dependencies No dependencies
There are maybe transitive dependencies!

pact-jvm-provider-lein_2.12 from group au.com.dius (version 3.6.15)

# Leiningen plugin to verify a provider [version 2.2.14+, 3.0.3+] Leiningen plugin for verifying pacts against a provider. The plugin provides a `pact-verify` task which will verify all configured pacts against your provider. ## To Use It ### 1. Add the plugin to your project plugins, preferably in it&apos;s own profile. ```clojure :profiles { :pact { :plugins [[au.com.dius/pact-jvm-provider-lein_2.11 &quot;3.2.11&quot; :exclusions [commons-logging]]] :dependencies [[ch.qos.logback/logback-core &quot;1.1.3&quot;] [ch.qos.logback/logback-classic &quot;1.1.3&quot;] [org.apache.httpcomponents/httpclient &quot;4.4.1&quot;]] }}} ``` ### 2. Define the pacts between your consumers and providers You define all the providers and consumers within the `:pact` configuration element of your project. ```clojure :pact { :service-providers { ; You can define as many as you need, but each must have a unique name :provider1 { ; All the provider properties are optional, and have sensible defaults (shown below) :protocol &quot;http&quot; :host &quot;localhost&quot; :port 8080 :path &quot;/&quot; :has-pact-with { ; Again, you can define as many consumers for each provider as you need, but each must have a unique name :consumer1 { ; pact file can be either a path or an URL :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` ### 3. Execute `lein with-profile pact pact-verify` You will have to have your provider running for this to pass. ## Enabling insecure SSL For providers that are running on SSL with self-signed certificates, you need to enable insecure SSL mode by setting `:insecure true` on the provider. ```clojure :pact { :service-providers { :provider1 { :protocol &quot;https&quot; :host &quot;localhost&quot; :port 8443 :insecure true :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` ## Specifying a custom trust store For environments that are running their own certificate chains: ```clojure :pact { :service-providers { :provider1 { :protocol &quot;https&quot; :host &quot;localhost&quot; :port 8443 :trust-store &quot;relative/path/to/trustStore.jks&quot; :trust-store-password &quot;changeme&quot; :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` `:trust-store` is relative to the current working (build) directory. `:trust-store-password` defaults to `changeit`. NOTE: The hostname will still be verified against the certificate. ## Modifying the requests before they are sent Sometimes you may need to add things to the requests that can&apos;t be persisted in a pact file. Examples of these would be authentication tokens, which have a small life span. The Leiningen plugin provides a request filter that can be set to an anonymous function on the provider that will be called before the request is made. This function will receive the HttpRequest object as a parameter. ```clojure :pact { :service-providers { :provider1 { ; function that adds an Authorization header to each request :request-filter #(.addHeader % &quot;Authorization&quot; &quot;oauth-token eyJhbGciOiJSUzI1NiIsIm...&quot;) :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` __*Important Note:*__ You should only use this feature for things that can not be persisted in the pact file. By modifying the request, you are potentially modifying the contract from the consumer tests! ## Modifying the HTTP Client Used The default HTTP client is used for all requests to providers (created with a call to `HttpClients.createDefault()`). This can be changed by specifying a function assigned to `:create-client` on the provider that returns a `CloseableHttpClient`. The function will receive the provider info as a parameter. ## Turning off URL decoding of the paths in the pact file [version 3.3.3+] By default the paths loaded from the pact file will be decoded before the request is sent to the provider. To turn this behaviour off, set the system property `pact.verifier.disableUrlPathDecoding` to `true`. __*Important Note:*__ If you turn off the url path decoding, you need to ensure that the paths in the pact files are correctly encoded. The verifier will not be able to make a request with an invalid encoded path. ## Plugin Properties The following plugin options can be specified on the command line: |Property|Description| |--------|-----------| |:pact.showStacktrace|This turns on stacktrace printing for each request. It can help with diagnosing network errors| |:pact.showFullDiff|This turns on displaying the full diff of the expected versus actual bodies [version 3.3.6+]| |:pact.filter.consumers|Comma seperated list of consumer names to verify| |:pact.filter.description|Only verify interactions whose description match the provided regular expression| |:pact.filter.providerState|Only verify interactions whose provider state match the provided regular expression. An empty string matches interactions that have no state| |:pact.verifier.publishResults|Publishing of verification results will be skipped unless this property is set to &apos;true&apos; [version 3.5.18+]| |:pact.matching.wildcard|Enables matching of map values ignoring the keys when this property is set to &apos;true&apos;| Example, to run verification only for a particular consumer: ``` $ lein with-profile pact pact-verify :pact.filter.consumers=:consumer2 ``` ## Provider States For each provider you can specify a state change URL to use to switch the state of the provider. This URL will receive the `providerState` description from the pact file before each interaction via a POST. The `:state-change-uses-body` controls if the state is passed in the request body or as a query parameter. These values can be set at the provider level, or for a specific consumer. Consumer values take precedent if both are given. ```clojure :pact { :service-providers { :provider1 { :state-change-url &quot;http://localhost:8080/tasks/pactStateChange&quot; :state-change-uses-body false ; defaults to true :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` If the `:state-change-uses-body` is not specified, or is set to true, then the provider state description will be sent as JSON in the body of the request. If it is set to false, it will passed as a query parameter. As for normal requests (see Modifying the requests before they are sent), a state change request can be modified before it is sent. Set `:state-change-request-filter` to an anonymous function on the provider that will be called before the request is made. #### Returning values that can be injected (3.6.11+) You can have values from the provider state callbacks be injected into most places (paths, query parameters, headers, bodies, etc.). This works by using the V3 spec generators with provider state callbacks that return values. One example of where this would be useful is API calls that require an ID which would be auto-generated by the database on the provider side, so there is no way to know what the ID would be beforehand. There are methods on the consumer DSLs that can provider an expression that contains variables (like &apos;/api/user/${id}&apos; for the path). The provider state callback can then return a map for values, and the `id` attribute from the map will be expanded in the expression. For URL callbacks, the values need to be returned as JSON in the response body. ## Filtering the interactions that are verified You can filter the interactions that are run using three properties: `:pact.filter.consumers`, `:pact.filter.description` and `:pact.filter.providerState`. Adding `:pact.filter.consumers=:consumer1,:consumer2` to the command line will only run the pact files for those consumers (consumer1 and consumer2). Adding `:pact.filter.description=a request for payment.*` will only run those interactions whose descriptions start with &apos;a request for payment&apos;. `:pact.filter.providerState=.*payment` will match any interaction that has a provider state that ends with payment, and `:pact.filter.providerState=` will match any interaction that does not have a provider state. ## Starting and shutting down your provider For the pact verification to run, the provider needs to be running. Leiningen provides a `do` task that can chain tasks together. So, by creating a `start-app` and `terminate-app` alias, you could so something like: $ lein with-profile pact do start-app, pact-verify, terminate-app However, if the pact verification fails the build will abort without running the `terminate-app` task. To have the start and terminate tasks always run regardless of the state of the verification, you can assign them to `:start-provider-task` and `:terminate-provider-task` on the provider. ```clojure :aliases {&quot;start-app&quot; ^{:doc &quot;Starts the app&quot;} [&quot;tasks to start app ...&quot;] ; insert tasks to start the app here &quot;terminate-app&quot; ^{:doc &quot;Kills the app&quot;} [&quot;tasks to terminate app ...&quot;] ; insert tasks to stop the app here } :pact { :service-providers { :provider1 { :start-provider-task &quot;start-app&quot; :terminate-provider-task &quot;terminate-app&quot; :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` Then you can just run: $ lein with-profile pact pact-verify and the `start-app` and `terminate-app` tasks will run before and after the provider verification. ## Specifying the provider hostname at runtime [3.0.4+] If you need to calculate the provider hostname at runtime (for instance it is run as a new docker container or AWS instance), you can give an anonymous function as the provider host that returns the host name. The function will receive the provider information as a parameter. ```clojure :pact { :service-providers { :provider1 { :host #(calculate-host-name %) :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ```

Group: au.com.dius Artifact: pact-jvm-provider-lein_2.12
Show all versions Show documentation Show source 
 

0 downloads
Artifact pact-jvm-provider-lein_2.12
Group au.com.dius
Version 3.6.15
Last update 29. April 2020
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 8
Dependencies pact-jvm-provider_2.12, clojure, core.match, leiningen-core, logback-core, logback-classic, httpclient, jansi,
There are maybe transitive dependencies!

pact-jvm-provider-lein from group au.com.dius (version 4.0.10)

# Leiningen plugin to verify a provider Leiningen plugin for verifying pacts against a provider. The plugin provides a `pact-verify` task which will verify all configured pacts against your provider. ## To Use It ### 1. Add the plugin to your project plugins, preferably in it&apos;s own profile. ```clojure :profiles { :pact { :plugins [[au.com.dius/pact-jvm-provider-lein &quot;4.0.0&quot; :exclusions [commons-logging]]] :dependencies [[ch.qos.logback/logback-core &quot;1.1.3&quot;] [ch.qos.logback/logback-classic &quot;1.1.3&quot;] [org.apache.httpcomponents/httpclient &quot;4.4.1&quot;]] }}} ``` ### 2. Define the pacts between your consumers and providers You define all the providers and consumers within the `:pact` configuration element of your project. ```clojure :pact { :service-providers { ; You can define as many as you need, but each must have a unique name :provider1 { ; All the provider properties are optional, and have sensible defaults (shown below) :protocol &quot;http&quot; :host &quot;localhost&quot; :port 8080 :path &quot;/&quot; :has-pact-with { ; Again, you can define as many consumers for each provider as you need, but each must have a unique name :consumer1 { ; pact file can be either a path or an URL :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` ### 3. Execute `lein with-profile pact pact-verify` You will have to have your provider running for this to pass. ## Enabling insecure SSL For providers that are running on SSL with self-signed certificates, you need to enable insecure SSL mode by setting `:insecure true` on the provider. ```clojure :pact { :service-providers { :provider1 { :protocol &quot;https&quot; :host &quot;localhost&quot; :port 8443 :insecure true :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` ## Specifying a custom trust store For environments that are running their own certificate chains: ```clojure :pact { :service-providers { :provider1 { :protocol &quot;https&quot; :host &quot;localhost&quot; :port 8443 :trust-store &quot;relative/path/to/trustStore.jks&quot; :trust-store-password &quot;changeme&quot; :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` `:trust-store` is relative to the current working (build) directory. `:trust-store-password` defaults to `changeit`. NOTE: The hostname will still be verified against the certificate. ## Modifying the requests before they are sent Sometimes you may need to add things to the requests that can&apos;t be persisted in a pact file. Examples of these would be authentication tokens, which have a small life span. The Leiningen plugin provides a request filter that can be set to an anonymous function on the provider that will be called before the request is made. This function will receive the HttpRequest object as a parameter. ```clojure :pact { :service-providers { :provider1 { ; function that adds an Authorization header to each request :request-filter #(.addHeader % &quot;Authorization&quot; &quot;oauth-token eyJhbGciOiJSUzI1NiIsIm...&quot;) :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` __*Important Note:*__ You should only use this feature for things that can not be persisted in the pact file. By modifying the request, you are potentially modifying the contract from the consumer tests! ## Modifying the HTTP Client Used The default HTTP client is used for all requests to providers (created with a call to `HttpClients.createDefault()`). This can be changed by specifying a function assigned to `:create-client` on the provider that returns a `CloseableHttpClient`. The function will receive the provider info as a parameter. ## Turning off URL decoding of the paths in the pact file By default the paths loaded from the pact file will be decoded before the request is sent to the provider. To turn this behaviour off, set the system property `pact.verifier.disableUrlPathDecoding` to `true`. __*Important Note:*__ If you turn off the url path decoding, you need to ensure that the paths in the pact files are correctly encoded. The verifier will not be able to make a request with an invalid encoded path. ## Plugin Properties The following plugin options can be specified on the command line: |Property|Description| |--------|-----------| |:pact.showStacktrace|This turns on stacktrace printing for each request. It can help with diagnosing network errors| |:pact.showFullDiff|This turns on displaying the full diff of the expected versus actual bodies [version 3.3.6+]| |:pact.filter.consumers|Comma seperated list of consumer names to verify| |:pact.filter.description|Only verify interactions whose description match the provided regular expression| |:pact.filter.providerState|Only verify interactions whose provider state match the provided regular expression. An empty string matches interactions that have no state| |:pact.verifier.publishResults|Publishing of verification results will be skipped unless this property is set to &apos;true&apos; [version 3.5.18+]| |:pact.matching.wildcard|Enables matching of map values ignoring the keys when this property is set to &apos;true&apos;| Example, to run verification only for a particular consumer: ``` $ lein with-profile pact pact-verify :pact.filter.consumers=:consumer2 ``` ## Provider States For each provider you can specify a state change URL to use to switch the state of the provider. This URL will receive the `providerState` description from the pact file before each interaction via a POST. The `:state-change-uses-body` controls if the state is passed in the request body or as a query parameter. These values can be set at the provider level, or for a specific consumer. Consumer values take precedent if both are given. ```clojure :pact { :service-providers { :provider1 { :state-change-url &quot;http://localhost:8080/tasks/pactStateChange&quot; :state-change-uses-body false ; defaults to true :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` If the `:state-change-uses-body` is not specified, or is set to true, then the provider state description will be sent as JSON in the body of the request. If it is set to false, it will passed as a query parameter. As for normal requests (see Modifying the requests before they are sent), a state change request can be modified before it is sent. Set `:state-change-request-filter` to an anonymous function on the provider that will be called before the request is made. #### Returning values that can be injected (3.6.11+) You can have values from the provider state callbacks be injected into most places (paths, query parameters, headers, bodies, etc.). This works by using the V3 spec generators with provider state callbacks that return values. One example of where this would be useful is API calls that require an ID which would be auto-generated by the database on the provider side, so there is no way to know what the ID would be beforehand. There are methods on the consumer DSLs that can provider an expression that contains variables (like &apos;/api/user/${id}&apos; for the path). The provider state callback can then return a map for values, and the `id` attribute from the map will be expanded in the expression. For URL callbacks, the values need to be returned as JSON in the response body. ## Filtering the interactions that are verified You can filter the interactions that are run using three properties: `:pact.filter.consumers`, `:pact.filter.description` and `:pact.filter.providerState`. Adding `:pact.filter.consumers=:consumer1,:consumer2` to the command line will only run the pact files for those consumers (consumer1 and consumer2). Adding `:pact.filter.description=a request for payment.*` will only run those interactions whose descriptions start with &apos;a request for payment&apos;. `:pact.filter.providerState=.*payment` will match any interaction that has a provider state that ends with payment, and `:pact.filter.providerState=` will match any interaction that does not have a provider state. ## Starting and shutting down your provider For the pact verification to run, the provider needs to be running. Leiningen provides a `do` task that can chain tasks together. So, by creating a `start-app` and `terminate-app` alias, you could so something like: $ lein with-profile pact do start-app, pact-verify, terminate-app However, if the pact verification fails the build will abort without running the `terminate-app` task. To have the start and terminate tasks always run regardless of the state of the verification, you can assign them to `:start-provider-task` and `:terminate-provider-task` on the provider. ```clojure :aliases {&quot;start-app&quot; ^{:doc &quot;Starts the app&quot;} [&quot;tasks to start app ...&quot;] ; insert tasks to start the app here &quot;terminate-app&quot; ^{:doc &quot;Kills the app&quot;} [&quot;tasks to terminate app ...&quot;] ; insert tasks to stop the app here } :pact { :service-providers { :provider1 { :start-provider-task &quot;start-app&quot; :terminate-provider-task &quot;terminate-app&quot; :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` Then you can just run: $ lein with-profile pact pact-verify and the `start-app` and `terminate-app` tasks will run before and after the provider verification. ## Specifying the provider hostname at runtime If you need to calculate the provider hostname at runtime (for instance it is run as a new docker container or AWS instance), you can give an anonymous function as the provider host that returns the host name. The function will receive the provider information as a parameter. ```clojure :pact { :service-providers { :provider1 { :host #(calculate-host-name %) :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ```

Group: au.com.dius Artifact: pact-jvm-provider-lein
Show all versions Show documentation Show source 
 

0 downloads
Artifact pact-jvm-provider-lein
Group au.com.dius
Version 4.0.10
Last update 18. April 2020
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 10
Dependencies pact-jvm-provider, clojure, core.match, leiningen-core, maven-aether-provider, aether-connector-file, aether-connector-wagon, httpclient, jansi, groovy,
There are maybe transitive dependencies!

pact-jvm-provider-lein_2.11 from group au.com.dius (version 3.5.24)

# Leiningen plugin to verify a provider [version 2.2.14+, 3.0.3+] Leiningen plugin for verifying pacts against a provider. The plugin provides a `pact-verify` task which will verify all configured pacts against your provider. ## To Use It ### 1. Add the plugin to your project plugins, preferably in it&apos;s own profile. ```clojure :profiles { :pact { :plugins [[au.com.dius/pact-jvm-provider-lein_2.11 &quot;3.2.11&quot; :exclusions [commons-logging]]] :dependencies [[ch.qos.logback/logback-core &quot;1.1.3&quot;] [ch.qos.logback/logback-classic &quot;1.1.3&quot;] [org.apache.httpcomponents/httpclient &quot;4.4.1&quot;]] }}} ``` ### 2. Define the pacts between your consumers and providers You define all the providers and consumers within the `:pact` configuration element of your project. ```clojure :pact { :service-providers { ; You can define as many as you need, but each must have a unique name :provider1 { ; All the provider properties are optional, and have sensible defaults (shown below) :protocol &quot;http&quot; :host &quot;localhost&quot; :port 8080 :path &quot;/&quot; :has-pact-with { ; Again, you can define as many consumers for each provider as you need, but each must have a unique name :consumer1 { ; pact file can be either a path or an URL :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` ### 3. Execute `lein with-profile pact pact-verify` You will have to have your provider running for this to pass. ## Enabling insecure SSL For providers that are running on SSL with self-signed certificates, you need to enable insecure SSL mode by setting `:insecure true` on the provider. ```clojure :pact { :service-providers { :provider1 { :protocol &quot;https&quot; :host &quot;localhost&quot; :port 8443 :insecure true :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` ## Specifying a custom trust store For environments that are running their own certificate chains: ```clojure :pact { :service-providers { :provider1 { :protocol &quot;https&quot; :host &quot;localhost&quot; :port 8443 :trust-store &quot;relative/path/to/trustStore.jks&quot; :trust-store-password &quot;changeme&quot; :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` `:trust-store` is relative to the current working (build) directory. `:trust-store-password` defaults to `changeit`. NOTE: The hostname will still be verified against the certificate. ## Modifying the requests before they are sent Sometimes you may need to add things to the requests that can&apos;t be persisted in a pact file. Examples of these would be authentication tokens, which have a small life span. The Leiningen plugin provides a request filter that can be set to an anonymous function on the provider that will be called before the request is made. This function will receive the HttpRequest object as a parameter. ```clojure :pact { :service-providers { :provider1 { ; function that adds an Authorization header to each request :request-filter #(.addHeader % &quot;Authorization&quot; &quot;oauth-token eyJhbGciOiJSUzI1NiIsIm...&quot;) :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` __*Important Note:*__ You should only use this feature for things that can not be persisted in the pact file. By modifying the request, you are potentially modifying the contract from the consumer tests! ## Modifying the HTTP Client Used The default HTTP client is used for all requests to providers (created with a call to `HttpClients.createDefault()`). This can be changed by specifying a function assigned to `:create-client` on the provider that returns a `CloseableHttpClient`. The function will receive the provider info as a parameter. ## Turning off URL decoding of the paths in the pact file [version 3.3.3+] By default the paths loaded from the pact file will be decoded before the request is sent to the provider. To turn this behaviour off, set the system property `pact.verifier.disableUrlPathDecoding` to `true`. __*Important Note:*__ If you turn off the url path decoding, you need to ensure that the paths in the pact files are correctly encoded. The verifier will not be able to make a request with an invalid encoded path. ## Plugin Properties The following plugin options can be specified on the command line: |Property|Description| |--------|-----------| |:pact.showStacktrace|This turns on stacktrace printing for each request. It can help with diagnosing network errors| |:pact.showFullDiff|This turns on displaying the full diff of the expected versus actual bodies [version 3.3.6+]| |:pact.filter.consumers|Comma seperated list of consumer names to verify| |:pact.filter.description|Only verify interactions whose description match the provided regular expression| |:pact.filter.providerState|Only verify interactions whose provider state match the provided regular expression. An empty string matches interactions that have no state| |:pact.verifier.publishResults|Publishing of verification results will be skipped unless this property is set to &apos;true&apos; [version 3.5.18+]| |:pact.matching.wildcard|Enables matching of map values ignoring the keys when this property is set to &apos;true&apos;| Example, to run verification only for a particular consumer: ``` $ lein with-profile pact pact-verify :pact.filter.consumers=consumer2 ``` ## Provider States For each provider you can specify a state change URL to use to switch the state of the provider. This URL will receive the `providerState` description from the pact file before each interaction via a POST. The `:state-change-uses-body` controls if the state is passed in the request body or as a query parameter. These values can be set at the provider level, or for a specific consumer. Consumer values take precedent if both are given. ```clojure :pact { :service-providers { :provider1 { :state-change-url &quot;http://localhost:8080/tasks/pactStateChange&quot; :state-change-uses-body false ; defaults to true :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` If the `:state-change-uses-body` is not specified, or is set to true, then the provider state description will be sent as JSON in the body of the request. If it is set to false, it will passed as a query parameter. As for normal requests (see Modifying the requests before they are sent), a state change request can be modified before it is sent. Set `:state-change-request-filter` to an anonymous function on the provider that will be called before the request is made. ## Filtering the interactions that are verified You can filter the interactions that are run using three properties: `:pact.filter.consumers`, `:pact.filter.description` and `:pact.filter.providerState`. Adding `:pact.filter.consumers=consumer1,consumer2` to the command line will only run the pact files for those consumers (consumer1 and consumer2). Adding `:pact.filter.description=a request for payment.*` will only run those interactions whose descriptions start with &apos;a request for payment&apos;. `:pact.filter.providerState=.*payment` will match any interaction that has a provider state that ends with payment, and `:pact.filter.providerState=` will match any interaction that does not have a provider state. ## Starting and shutting down your provider For the pact verification to run, the provider needs to be running. Leiningen provides a `do` task that can chain tasks together. So, by creating a `start-app` and `terminate-app` alias, you could so something like: $ lein with-profile pact do start-app, pact-verify, terminate-app However, if the pact verification fails the build will abort without running the `terminate-app` task. To have the start and terminate tasks always run regardless of the state of the verification, you can assign them to `:start-provider-task` and `:terminate-provider-task` on the provider. ```clojure :aliases {&quot;start-app&quot; ^{:doc &quot;Starts the app&quot;} [&quot;tasks to start app ...&quot;] ; insert tasks to start the app here &quot;terminate-app&quot; ^{:doc &quot;Kills the app&quot;} [&quot;tasks to terminate app ...&quot;] ; insert tasks to stop the app here } :pact { :service-providers { :provider1 { :start-provider-task &quot;start-app&quot; :terminate-provider-task &quot;terminate-app&quot; :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` Then you can just run: $ lein with-profile pact pact-verify and the `start-app` and `terminate-app` tasks will run before and after the provider verification. ## Specifying the provider hostname at runtime [3.0.4+] If you need to calculate the provider hostname at runtime (for instance it is run as a new docker container or AWS instance), you can give an anonymous function as the provider host that returns the host name. The function will receive the provider information as a parameter. ```clojure :pact { :service-providers { :provider1 { :host #(calculate-host-name %) :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ```

Group: au.com.dius Artifact: pact-jvm-provider-lein_2.11
Show all versions Show documentation Show source 
 

0 downloads
Artifact pact-jvm-provider-lein_2.11
Group au.com.dius
Version 3.5.24
Last update 04. November 2018
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 15
Dependencies kotlin-stdlib-jdk8, kotlin-reflect, slf4j-api, groovy-all, kotlin-logging, scala-library, scala-logging_2.11, pact-jvm-provider_2.11, clojure, core.match, leiningen-core, logback-core, logback-classic, httpclient, jansi,
There are maybe transitive dependencies!

pact-jvm-provider-lein_2.10 from group au.com.dius (version 2.4.20)

# Leiningen plugin to verify a provider [version 2.2.14+, 3.0.3+] Leiningen plugin for verifying pacts against a provider. The plugin provides a `pact-verify` task which will verify all configured pacts against your provider. ## To Use It ### 1. Add the plugin to your project plugins, preferably in it&apos;s own profile. ```clojure :profiles { :pact { :plugins [[au.com.dius/pact-jvm-provider-lein_2.11 &quot;3.0.3&quot; :exclusions [commons-logging]]] :dependencies [[ch.qos.logback/logback-core &quot;1.1.3&quot;] [ch.qos.logback/logback-classic &quot;1.1.3&quot;] [org.apache.httpcomponents/httpclient &quot;4.4.1&quot;]] }}} ``` ### 2. Define the pacts between your consumers and providers You define all the providers and consumers within the `:pact` configuration element of your project. ```clojure :pact { :service-providers { ; You can define as many as you need, but each must have a unique name :provider1 { ; All the provider properties are optional, and have sensible defaults (shown below) :protocol &quot;http&quot; :host &quot;localhost&quot; :port 8080 :path &quot;/&quot; :has-pact-with { ; Again, you can define as many consumers for each provider as you need, but each must have a unique name :consumer1 { ; pact file can be either a path or an URL :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` ### 3. Execute `lein with-profile pact pact-verify` You will have to have your provider running for this to pass. ## Enabling insecure SSL For providers that are running on SSL with self-signed certificates, you need to enable insecure SSL mode by setting `:insecure true` on the provider. ```clojure :pact { :service-providers { :provider1 { :protocol &quot;https&quot; :host &quot;localhost&quot; :port 8443 :insecure true :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` ## Specifying a custom trust store For environments that are running their own certificate chains: ```clojure :pact { :service-providers { :provider1 { :protocol &quot;https&quot; :host &quot;localhost&quot; :port 8443 :trust-store &quot;relative/path/to/trustStore.jks&quot; :trust-store-password &quot;changeme&quot; :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` `:trust-store` is relative to the current working (build) directory. `:trust-store-password` defaults to `changeit`. NOTE: The hostname will still be verified against the certificate. ## Modifying the requests before they are sent Sometimes you may need to add things to the requests that can&apos;t be persisted in a pact file. Examples of these would be authentication tokens, which have a small life span. The Leiningen plugin provides a request filter that can be set to an anonymous function on the provider that will be called before the request is made. This function will receive the HttpRequest object as a parameter. ```clojure :pact { :service-providers { :provider1 { ; function that adds an Authorization header to each request :request-filter #(.addHeader % &quot;Authorization&quot; &quot;oauth-token eyJhbGciOiJSUzI1NiIsIm...&quot;) :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` __*Important Note:*__ You should only use this feature for things that can not be persisted in the pact file. By modifying the request, you are potentially modifying the contract from the consumer tests! ## Modifying the HTTP Client Used The default HTTP client is used for all requests to providers (created with a call to `HttpClients.createDefault()`). This can be changed by specifying a function assigned to `:create-client` on the provider that returns a `CloseableHttpClient`. The function will receive the provider info as a parameter. ## Turning off URL decoding of the paths in the pact file [version 3.3.3+] By default the paths loaded from the pact file will be decoded before the request is sent to the provider. To turn this behaviour off, set the system property `pact.verifier.disableUrlPathDecoding` to `true`. __*Important Note:*__ If you turn off the url path decoding, you need to ensure that the paths in the pact files are correctly encoded. The verifier will not be able to make a request with an invalid encoded path. ## Plugin Properties The following plugin options can be specified on the command line: |Property|Description| |--------|-----------| |:pact.showStacktrace|This turns on stacktrace printing for each request. It can help with diagnosing network errors| |:pact.showFullDiff|This turns on displaying the full diff of the expected versus actual bodies [version 3.3.6+]| |:pact.filter.consumers|Comma seperated list of consumer names to verify| |:pact.filter.description|Only verify interactions whose description match the provided regular expression| |:pact.filter.providerState|Only verify interactions whose provider state match the provided regular expression. An empty string matches interactions that have no state| Example, to run verification only for a particular consumer: ``` $ lein with-profile pact pact-verify :pact.filter.consumers=consumer2 ``` ## Provider States For each provider you can specify a state change URL to use to switch the state of the provider. This URL will receive the `providerState` description from the pact file before each interaction via a POST. The `:state-change-uses-body` controls if the state is passed in the request body or as a query parameter. These values can be set at the provider level, or for a specific consumer. Consumer values take precedent if both are given. ```clojure :pact { :service-providers { :provider1 { :state-change-url &quot;http://localhost:8080/tasks/pactStateChange&quot; :state-change-uses-body false ; defaults to true :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` If the `:state-change-uses-body` is not specified, or is set to true, then the provider state description will be sent as JSON in the body of the request. If it is set to false, it will passed as a query parameter. As for normal requests (see Modifying the requests before they are sent), a state change request can be modified before it is sent. Set `:state-change-request-filter` to an anonymous function on the provider that will be called before the request is made. ## Filtering the interactions that are verified You can filter the interactions that are run using three properties: `:pact.filter.consumers`, `:pact.filter.description` and `:pact.filter.providerState`. Adding `:pact.filter.consumers=consumer1,consumer2` to the command line will only run the pact files for those consumers (consumer1 and consumer2). Adding `:pact.filter.description=a request for payment.*` will only run those interactions whose descriptions start with &apos;a request for payment&apos;. `:pact.filter.providerState=.*payment` will match any interaction that has a provider state that ends with payment, and `:pact.filter.providerState=` will match any interaction that does not have a provider state. ## Starting and shutting down your provider For the pact verification to run, the provider needs to be running. Leiningen provides a `do` task that can chain tasks together. So, by creating a `start-app` and `terminate-app` alias, you could so something like: $ lein with-profile pact do start-app, pact-verify, terminate-app However, if the pact verification fails the build will abort without running the `terminate-app` task. To have the start and terminate tasks always run regardless of the state of the verification, you can assign them to `:start-provider-task` and `:terminate-provider-task` on the provider. ```clojure :aliases {&quot;start-app&quot; ^{:doc &quot;Starts the app&quot;} [&quot;tasks to start app ...&quot;] ; insert tasks to start the app here &quot;terminate-app&quot; ^{:doc &quot;Kills the app&quot;} [&quot;tasks to terminate app ...&quot;] ; insert tasks to stop the app here } :pact { :service-providers { :provider1 { :start-provider-task &quot;start-app&quot; :terminate-provider-task &quot;terminate-app&quot; :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` Then you can just run: $ lein with-profile pact pact-verify and the `start-app` and `terminate-app` tasks will run before and after the provider verification. ## Specifying the provider hostname at runtime [3.0.4+] If you need to calculate the provider hostname at runtime (for instance it is run as a new docker container or AWS instance), you can give an anonymous function as the provider host that returns the host name. The function will receive the provider information as a parameter. ```clojure :pact { :service-providers { :provider1 { :host #(calculate-host-name %) :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ```

Group: au.com.dius Artifact: pact-jvm-provider-lein_2.10
Show all versions Show documentation Show source 
 

0 downloads
Artifact pact-jvm-provider-lein_2.10
Group au.com.dius
Version 2.4.20
Last update 14. April 2018
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 10
Dependencies slf4j-api, scala-library, pact-jvm-provider_2.10, clojure, core.match, leiningen-core, logback-core, logback-classic, httpclient, jansi,
There are maybe transitive dependencies!

pact-jvm-consumer_2.10 from group au.com.dius (version 2.4.20)

Pact consumer ============= Pact Consumer is used by projects that are consumers of an API. Most projects will want to use pact-consumer via one of the test framework specific projects. If your favourite framework is not implemented, this module should give you all the hooks you need. Provides a DSL for use with Java to build consumer pacts. ## Dependency The library is available on maven central using: * group-id = `au.com.dius` * artifact-id = `pact-jvm-consumer_2.11` ## DSL Usage Example in a JUnit test: ```java import au.com.dius.pact.model.MockProviderConfig; import au.com.dius.pact.model.PactFragment; import org.junit.Test; import java.io.IOException; import java.util.HashMap; import java.util.Map; import static org.junit.Assert.assertEquals; public class PactTest { @Test public void testPact() { PactFragment pactFragment = ConsumerPactBuilder .consumer(&quot;Some Consumer&quot;) .hasPactWith(&quot;Some Provider&quot;) .uponReceiving(&quot;a request to say Hello&quot;) .path(&quot;/hello&quot;) .method(&quot;POST&quot;) .body(&quot;{\&quot;name\&quot;: \&quot;harry\&quot;}&quot;) .willRespondWith() .status(200) .body(&quot;{\&quot;hello\&quot;: \&quot;harry\&quot;}&quot;) .toFragment(); MockProviderConfig config = MockProviderConfig.createDefault(); VerificationResult result = pactFragment.runConsumer(config, new TestRun() { @Override public void run(MockProviderConfig config) { Map expectedResponse = new HashMap(); expectedResponse.put(&quot;hello&quot;, &quot;harry&quot;); try { assertEquals(new ProviderClient(config.url()).hello(&quot;{\&quot;name\&quot;: \&quot;harry\&quot;}&quot;), expectedResponse); } catch (IOException e) {} } }); if (result instanceof PactError) { throw new RuntimeException(((PactError)result).error()); } assertEquals(ConsumerPactTest.PACT_VERIFIED, result); } } ``` The DSL has the following pattern: ```java .consumer(&quot;Some Consumer&quot;) .hasPactWith(&quot;Some Provider&quot;) .given(&quot;a certain state on the provider&quot;) .uponReceiving(&quot;a request for something&quot;) .path(&quot;/hello&quot;) .method(&quot;POST&quot;) .body(&quot;{\&quot;name\&quot;: \&quot;harry\&quot;}&quot;) .willRespondWith() .status(200) .body(&quot;{\&quot;hello\&quot;: \&quot;harry\&quot;}&quot;) .uponReceiving(&quot;another request for something&quot;) .path(&quot;/hello&quot;) .method(&quot;POST&quot;) .body(&quot;{\&quot;name\&quot;: \&quot;harry\&quot;}&quot;) .willRespondWith() .status(200) .body(&quot;{\&quot;hello\&quot;: \&quot;harry\&quot;}&quot;) . . . .toFragment() ``` You can define as many interactions as required. Each interaction starts with `uponReceiving` followed by `willRespondWith`. The test state setup with `given` is a mechanism to describe what the state of the provider should be in before the provider is verified. It is only recorded in the consumer tests and used by the provider verification tasks. ### Building JSON bodies with PactDslJsonBody DSL The body method of the ConsumerPactBuilder can accept a PactDslJsonBody, which can construct a JSON body as well as define regex and type matchers. For example: ```java PactDslJsonBody body = new PactDslJsonBody() .stringType(&quot;name&quot;) .booleanType(&quot;happy&quot;) .hexValue(&quot;hexCode&quot;) .id() .ipAddress(&quot;localAddress&quot;) .numberValue(&quot;age&quot;, 100) .timestamp(); ``` #### DSL Matching methods The following matching methods are provided with the DSL. In most cases, they take an optional value parameter which will be used to generate example values (i.e. when returning a mock response). If no example value is given, a random one will be generated. | method | description | |--------|-------------| | string, stringValue | Match a string value (using string equality) | | number, numberValue | Match a number value (using Number.equals)\* | | booleanValue | Match a boolean value (using equality) | | stringType | Will match all Strings | | numberType | Will match all numbers\* | | integerType | Will match all numbers that are integers (both ints and longs)\* | | decimalType | Will match all real numbers (floating point and decimal)\* | | booleanType | Will match all boolean values (true and false) | | stringMatcher | Will match strings using the provided regular expression | | timestamp | Will match string containing timestamps. If a timestamp format is not given, will match an ISO timestamp format | | date | Will match string containing dates. If a date format is not given, will match an ISO date format | | time | Will match string containing times. If a time format is not given, will match an ISO time format | | ipAddress | Will match string containing IP4 formatted address. | | id | Will match all numbers by type | | hexValue | Will match all hexadecimal encoded strings | | uuid | Will match strings containing UUIDs | _\* Note:_ JSON only supports double precision floating point values. Depending on the language implementation, they may parsed as integer, floating point or decimal numbers. #### Ensuring all items in a list match an example (2.2.0+) Lots of the time you might not know the number of items that will be in a list, but you want to ensure that the list has a minimum or maximum size and that each item in the list matches a given example. You can do this with the `arrayLike`, `minArrayLike` and `maxArrayLike` functions. | function | description | |----------|-------------| | `eachLike` | Ensure that each item in the list matches the provided example | | `maxArrayLike` | Ensure that each item in the list matches the provided example and the list is no bigger than the provided max | | `minArrayLike` | Ensure that each item in the list matches the provided example and the list is no smaller than the provided min | For example: ```java DslPart body = new PactDslJsonBody() .minArrayLike(&quot;users&quot;) .id() .stringType(&quot;name&quot;) .closeObject() .closeArray(); ``` This will ensure that the users list is never empty and that each user has an identifier that is a number and a name that is a string. #### Matching JSON values at the root (Version 3.2.2/2.4.3+) For cases where you are expecting basic JSON values (strings, numbers, booleans and null) at the root level of the body and need to use matchers, you can use the `PactDslJsonRootValue` class. It has all the DSL matching methods for basic values that you can use. For example: ```java .consumer(&quot;Some Consumer&quot;) .hasPactWith(&quot;Some Provider&quot;) .uponReceiving(&quot;a request for a basic JSON value&quot;) .path(&quot;/hello&quot;) .willRespondWith() .status(200) .body(PactDslJsonRootValue.integerType()) ``` #### Root level arrays that match all items (version 2.2.11+) If the root of the body is an array, you can create PactDslJsonArray classes with the following methods: | function | description | |----------|-------------| | `arrayEachLike` | Ensure that each item in the list matches the provided example | | `arrayMinLike` | Ensure that each item in the list matches the provided example and the list is no bigger than the provided max | | `arrayMaxLike` | Ensure that each item in the list matches the provided example and the list is no smaller than the provided min | For example: ```java PactDslJsonArray.arrayEachLike() .date(&quot;clearedDate&quot;, &quot;mm/dd/yyyy&quot;, date) .stringType(&quot;status&quot;, &quot;STATUS&quot;) .decimalType(&quot;amount&quot;, 100.0) .closeObject() ``` This will then match a body like: ```json [ { &quot;clearedDate&quot; : &quot;07/22/2015&quot;, &quot;status&quot; : &quot;C&quot;, &quot;amount&quot; : 15.0 }, { &quot;clearedDate&quot; : &quot;07/22/2015&quot;, &quot;status&quot; : &quot;C&quot;, &quot;amount&quot; : 15.0 }, { &quot;clearedDate&quot; : &quot;07/22/2015&quot;, &quot;status&quot; : &quot;C&quot;, &quot;amount&quot; : 15.0 } ] ``` #### Matching arrays of arrays (version 3.2.12/2.4.14+) For the case where you have arrays of arrays (GeoJSON is an example), the following methods have been provided: | function | description | |----------|-------------| | `eachArrayLike` | Ensure that each item in the array is an array that matches the provided example | | `eachArrayWithMaxLike` | Ensure that each item in the array is an array that matches the provided example and the array is no bigger than the provided max | | `eachArrayWithMinLike` | Ensure that each item in the array is an array that matches the provided example and the array is no smaller than the provided min | For example (with GeoJSON structure): ```java new PactDslJsonBody() .stringType(&quot;type&quot;,&quot;FeatureCollection&quot;) .eachLike(&quot;features&quot;) .stringType(&quot;type&quot;,&quot;Feature&quot;) .object(&quot;geometry&quot;) .stringType(&quot;type&quot;,&quot;Point&quot;) .eachArrayLike(&quot;coordinates&quot;) // coordinates is an array of arrays .decimalType(-7.55717) .decimalType(49.766896) .closeArray() .closeArray() .closeObject() .object(&quot;properties&quot;) .stringType(&quot;prop0&quot;,&quot;value0&quot;) .closeObject() .closeObject() .closeArray() ``` This generated the following JSON: ```json { &quot;features&quot;: [ { &quot;geometry&quot;: { &quot;coordinates&quot;: [[-7.55717, 49.766896]], &quot;type&quot;: &quot;Point&quot; }, &quot;type&quot;: &quot;Feature&quot;, &quot;properties&quot;: { &quot;prop0&quot;: &quot;value0&quot; } } ], &quot;type&quot;: &quot;FeatureCollection&quot; } ``` and will be able to match all coordinates regardless of the number of coordinates. #### Matching any key in a map (3.3.1/2.5.0+) The DSL has been extended for cases where the keys in a map are IDs. For an example of this, see [#313](https://github.com/DiUS/pact-jvm/issues/131). In this case you can use the `eachKeyLike` method, which takes an example key as a parameter. For example: ```java DslPart body = new PactDslJsonBody() .object(&quot;one&quot;) .eachKeyLike(&quot;001&quot;, PactDslJsonRootValue.id(12345L)) // key like an id mapped to a matcher .closeObject() .object(&quot;two&quot;) .eachKeyLike(&quot;001-A&quot;) // key like an id where the value is matched by the following example .stringType(&quot;description&quot;, &quot;Some Description&quot;) .closeObject() .closeObject() .object(&quot;three&quot;) .eachKeyMappedToAnArrayLike(&quot;001&quot;) // key like an id mapped to an array where each item is matched by the following example .id(&quot;someId&quot;, 23456L) .closeObject() .closeArray() .closeObject(); ``` For an example, have a look at [WildcardKeysTest](src/test/java/au/com/dius/pact/consumer/WildcardKeysTest.java). **NOTE:** The `eachKeyLike` method adds a `*` to the matching path, so the matching definition will be applied to all keys of the map if there is not a more specific matcher defined for a particular key. Having more than one `eachKeyLike` condition applied to a map will result in only one being applied when the pact is verified (probably the last). ### Matching on paths (version 2.1.5+) You can use regular expressions to match incoming requests. The DSL has a `matchPath` method for this. You can provide a real path as a second value to use when generating requests, and if you leave it out it will generate a random one from the regular expression. For example: ```java .given(&quot;test state&quot;) .uponReceiving(&quot;a test interaction&quot;) .matchPath(&quot;/transaction/[0-9]+&quot;) // or .matchPath(&quot;/transaction/[0-9]+&quot;, &quot;/transaction/1234567890&quot;) .method(&quot;POST&quot;) .body(&quot;{\&quot;name\&quot;: \&quot;harry\&quot;}&quot;) .willRespondWith() .status(200) .body(&quot;{\&quot;hello\&quot;: \&quot;harry\&quot;}&quot;) ``` ### Matching on headers (version 2.2.2+) You can use regular expressions to match request and response headers. The DSL has a `matchHeader` method for this. You can provide an example header value to use when generating requests and responses, and if you leave it out it will generate a random one from the regular expression. For example: ```java .given(&quot;test state&quot;) .uponReceiving(&quot;a test interaction&quot;) .path(&quot;/hello&quot;) .method(&quot;POST&quot;) .matchHeader(&quot;testreqheader&quot;, &quot;test.*value&quot;) .body(&quot;{\&quot;name\&quot;: \&quot;harry\&quot;}&quot;) .willRespondWith() .status(200) .body(&quot;{\&quot;hello\&quot;: \&quot;harry\&quot;}&quot;) .matchHeader(&quot;Location&quot;, &quot;.*/hello/[0-9]+&quot;, &quot;/hello/1234&quot;) ``` ### Matching on query parameters (version 3.3.7+) You can use regular expressions to match request query parameters. The DSL has a `matchQuery` method for this. You can provide an example value to use when generating requests, and if you leave it out it will generate a random one from the regular expression. For example: ```java .given(&quot;test state&quot;) .uponReceiving(&quot;a test interaction&quot;) .path(&quot;/hello&quot;) .method(&quot;POST&quot;) .matchQuery(&quot;a&quot;, &quot;\\d+&quot;, &quot;100&quot;) .matchQuery(&quot;b&quot;, &quot;[A-Z]&quot;, &quot;X&quot;) .body(&quot;{\&quot;name\&quot;: \&quot;harry\&quot;}&quot;) .willRespondWith() .status(200) .body(&quot;{\&quot;hello\&quot;: \&quot;harry\&quot;}&quot;) ```

Group: au.com.dius Artifact: pact-jvm-consumer_2.10
Show all versions Show documentation Show source 
 

6 downloads
Artifact pact-jvm-consumer_2.10
Group au.com.dius
Version 2.4.20
Last update 14. April 2018
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 12
Dependencies slf4j-api, scala-library, pact-jvm-model, pact-jvm-matchers_2.10, groovy-all, diffutils, automaton, httpclient, jackson-databind, generex, unfiltered-netty-server_2.10, dispatch-core_2.10,
There are maybe transitive dependencies!

pact-jvm-consumer_2.12 from group au.com.dius (version 3.6.15)

Pact consumer ============= Pact Consumer is used by projects that are consumers of an API. Most projects will want to use pact-consumer via one of the test framework specific projects. If your favourite framework is not implemented, this module should give you all the hooks you need. Provides a DSL for use with Java to build consumer pacts. ## Dependency The library is available on maven central using: * group-id = `au.com.dius` * artifact-id = `pact-jvm-consumer_2.11` ## DSL Usage Example in a JUnit test: ```java import au.com.dius.pact.model.MockProviderConfig; import au.com.dius.pact.model.RequestResponsePact; import org.apache.http.entity.ContentType; import org.jetbrains.annotations.NotNull; import org.junit.Test; import java.io.IOException; import java.util.HashMap; import java.util.Map; import static au.com.dius.pact.consumer.ConsumerPactRunnerKt.runConsumerTest; import static org.junit.Assert.assertEquals; public class PactTest { @Test public void testPact() { RequestResponsePact pact = ConsumerPactBuilder .consumer(&quot;Some Consumer&quot;) .hasPactWith(&quot;Some Provider&quot;) .uponReceiving(&quot;a request to say Hello&quot;) .path(&quot;/hello&quot;) .method(&quot;POST&quot;) .body(&quot;{\&quot;name\&quot;: \&quot;harry\&quot;}&quot;) .willRespondWith() .status(200) .body(&quot;{\&quot;hello\&quot;: \&quot;harry\&quot;}&quot;) .toPact(); MockProviderConfig config = MockProviderConfig.createDefault(); PactVerificationResult result = runConsumerTest(pact, config, new PactTestRun() { @Override public void run(@NotNull MockServer mockServer) throws IOException { Map expectedResponse = new HashMap(); expectedResponse.put(&quot;hello&quot;, &quot;harry&quot;); assertEquals(expectedResponse, new ConsumerClient(mockServer.getUrl()).post(&quot;/hello&quot;, &quot;{\&quot;name\&quot;: \&quot;harry\&quot;}&quot;, ContentType.APPLICATION_JSON)); } }); if (result instanceof PactVerificationResult.Error) { throw new RuntimeException(((PactVerificationResult.Error)result).getError()); } assertEquals(PactVerificationResult.Ok.INSTANCE, result); } } ``` The DSL has the following pattern: ```java .consumer(&quot;Some Consumer&quot;) .hasPactWith(&quot;Some Provider&quot;) .given(&quot;a certain state on the provider&quot;) .uponReceiving(&quot;a request for something&quot;) .path(&quot;/hello&quot;) .method(&quot;POST&quot;) .body(&quot;{\&quot;name\&quot;: \&quot;harry\&quot;}&quot;) .willRespondWith() .status(200) .body(&quot;{\&quot;hello\&quot;: \&quot;harry\&quot;}&quot;) .uponReceiving(&quot;another request for something&quot;) .path(&quot;/hello&quot;) .method(&quot;POST&quot;) .body(&quot;{\&quot;name\&quot;: \&quot;harry\&quot;}&quot;) .willRespondWith() .status(200) .body(&quot;{\&quot;hello\&quot;: \&quot;harry\&quot;}&quot;) . . . .toPact() ``` You can define as many interactions as required. Each interaction starts with `uponReceiving` followed by `willRespondWith`. The test state setup with `given` is a mechanism to describe what the state of the provider should be in before the provider is verified. It is only recorded in the consumer tests and used by the provider verification tasks. ### Building JSON bodies with PactDslJsonBody DSL The body method of the ConsumerPactBuilder can accept a PactDslJsonBody, which can construct a JSON body as well as define regex and type matchers. For example: ```java PactDslJsonBody body = new PactDslJsonBody() .stringType(&quot;name&quot;) .booleanType(&quot;happy&quot;) .hexValue(&quot;hexCode&quot;) .id() .ipAddress(&quot;localAddress&quot;) .numberValue(&quot;age&quot;, 100) .timestamp(); ``` #### DSL Matching methods The following matching methods are provided with the DSL. In most cases, they take an optional value parameter which will be used to generate example values (i.e. when returning a mock response). If no example value is given, a random one will be generated. | method | description | |--------|-------------| | string, stringValue | Match a string value (using string equality) | | number, numberValue | Match a number value (using Number.equals)\* | | booleanValue | Match a boolean value (using equality) | | stringType | Will match all Strings | | numberType | Will match all numbers\* | | integerType | Will match all numbers that are integers (both ints and longs)\* | | decimalType | Will match all real numbers (floating point and decimal)\* | | booleanType | Will match all boolean values (true and false) | | stringMatcher | Will match strings using the provided regular expression | | timestamp | Will match string containing timestamps. If a timestamp format is not given, will match an ISO timestamp format | | date | Will match string containing dates. If a date format is not given, will match an ISO date format | | time | Will match string containing times. If a time format is not given, will match an ISO time format | | ipAddress | Will match string containing IP4 formatted address. | | id | Will match all numbers by type | | hexValue | Will match all hexadecimal encoded strings | | uuid | Will match strings containing UUIDs | | includesStr | Will match strings containing the provided string | | equalsTo | Will match using equals | | matchUrl | Defines a matcher for URLs, given the base URL path and a sequence of path fragments. The path fragments could be strings or regular expression matchers | _\* Note:_ JSON only supports double precision floating point values. Depending on the language implementation, they may parsed as integer, floating point or decimal numbers. #### Ensuring all items in a list match an example (2.2.0+) Lots of the time you might not know the number of items that will be in a list, but you want to ensure that the list has a minimum or maximum size and that each item in the list matches a given example. You can do this with the `arrayLike`, `minArrayLike` and `maxArrayLike` functions. | function | description | |----------|-------------| | `eachLike` | Ensure that each item in the list matches the provided example | | `maxArrayLike` | Ensure that each item in the list matches the provided example and the list is no bigger than the provided max | | `minArrayLike` | Ensure that each item in the list matches the provided example and the list is no smaller than the provided min | For example: ```java DslPart body = new PactDslJsonBody() .minArrayLike(&quot;users&quot;) .id() .stringType(&quot;name&quot;) .closeObject() .closeArray(); ``` This will ensure that the users list is never empty and that each user has an identifier that is a number and a name that is a string. #### Matching JSON values at the root (Version 3.2.2/2.4.3+) For cases where you are expecting basic JSON values (strings, numbers, booleans and null) at the root level of the body and need to use matchers, you can use the `PactDslJsonRootValue` class. It has all the DSL matching methods for basic values that you can use. For example: ```java .consumer(&quot;Some Consumer&quot;) .hasPactWith(&quot;Some Provider&quot;) .uponReceiving(&quot;a request for a basic JSON value&quot;) .path(&quot;/hello&quot;) .willRespondWith() .status(200) .body(PactDslJsonRootValue.integerType()) ``` #### Root level arrays that match all items (version 2.2.11+) If the root of the body is an array, you can create PactDslJsonArray classes with the following methods: | function | description | |----------|-------------| | `arrayEachLike` | Ensure that each item in the list matches the provided example | | `arrayMinLike` | Ensure that each item in the list matches the provided example and the list is no bigger than the provided max | | `arrayMaxLike` | Ensure that each item in the list matches the provided example and the list is no smaller than the provided min | For example: ```java PactDslJsonArray.arrayEachLike() .date(&quot;clearedDate&quot;, &quot;mm/dd/yyyy&quot;, date) .stringType(&quot;status&quot;, &quot;STATUS&quot;) .decimalType(&quot;amount&quot;, 100.0) .closeObject() ``` This will then match a body like: ```json [ { &quot;clearedDate&quot; : &quot;07/22/2015&quot;, &quot;status&quot; : &quot;C&quot;, &quot;amount&quot; : 15.0 }, { &quot;clearedDate&quot; : &quot;07/22/2015&quot;, &quot;status&quot; : &quot;C&quot;, &quot;amount&quot; : 15.0 }, { &quot;clearedDate&quot; : &quot;07/22/2015&quot;, &quot;status&quot; : &quot;C&quot;, &quot;amount&quot; : 15.0 } ] ``` #### Matching arrays of arrays (version 3.2.12/2.4.14+) For the case where you have arrays of arrays (GeoJSON is an example), the following methods have been provided: | function | description | |----------|-------------| | `eachArrayLike` | Ensure that each item in the array is an array that matches the provided example | | `eachArrayWithMaxLike` | Ensure that each item in the array is an array that matches the provided example and the array is no bigger than the provided max | | `eachArrayWithMinLike` | Ensure that each item in the array is an array that matches the provided example and the array is no smaller than the provided min | For example (with GeoJSON structure): ```java new PactDslJsonBody() .stringType(&quot;type&quot;,&quot;FeatureCollection&quot;) .eachLike(&quot;features&quot;) .stringType(&quot;type&quot;,&quot;Feature&quot;) .object(&quot;geometry&quot;) .stringType(&quot;type&quot;,&quot;Point&quot;) .eachArrayLike(&quot;coordinates&quot;) // coordinates is an array of arrays .decimalType(-7.55717) .decimalType(49.766896) .closeArray() .closeArray() .closeObject() .object(&quot;properties&quot;) .stringType(&quot;prop0&quot;,&quot;value0&quot;) .closeObject() .closeObject() .closeArray() ``` This generated the following JSON: ```json { &quot;features&quot;: [ { &quot;geometry&quot;: { &quot;coordinates&quot;: [[-7.55717, 49.766896]], &quot;type&quot;: &quot;Point&quot; }, &quot;type&quot;: &quot;Feature&quot;, &quot;properties&quot;: { &quot;prop0&quot;: &quot;value0&quot; } } ], &quot;type&quot;: &quot;FeatureCollection&quot; } ``` and will be able to match all coordinates regardless of the number of coordinates. #### Matching any key in a map (3.3.1/2.5.0+) The DSL has been extended for cases where the keys in a map are IDs. For an example of this, see [#313](https://github.com/DiUS/pact-jvm/issues/313). In this case you can use the `eachKeyLike` method, which takes an example key as a parameter. For example: ```java DslPart body = new PactDslJsonBody() .object(&quot;one&quot;) .eachKeyLike(&quot;001&quot;, PactDslJsonRootValue.id(12345L)) // key like an id mapped to a matcher .closeObject() .object(&quot;two&quot;) .eachKeyLike(&quot;001-A&quot;) // key like an id where the value is matched by the following example .stringType(&quot;description&quot;, &quot;Some Description&quot;) .closeObject() .closeObject() .object(&quot;three&quot;) .eachKeyMappedToAnArrayLike(&quot;001&quot;) // key like an id mapped to an array where each item is matched by the following example .id(&quot;someId&quot;, 23456L) .closeObject() .closeArray() .closeObject(); ``` For an example, have a look at [WildcardKeysTest](../pact-jvm-consumer-junit/src/test/java/au/com/dius/pact/consumer/WildcardKeysTest.java). **NOTE:** The `eachKeyLike` method adds a `*` to the matching path, so the matching definition will be applied to all keys of the map if there is not a more specific matcher defined for a particular key. Having more than one `eachKeyLike` condition applied to a map will result in only one being applied when the pact is verified (probably the last). **Further Note: From version 3.5.22 onwards pacts with wildcards applied to map keys will require the Java system property &quot;pact.matching.wildcard&quot; set to value &quot;true&quot; when the pact file is verified.** ### Matching on paths (version 2.1.5+) You can use regular expressions to match incoming requests. The DSL has a `matchPath` method for this. You can provide a real path as a second value to use when generating requests, and if you leave it out it will generate a random one from the regular expression. For example: ```java .given(&quot;test state&quot;) .uponReceiving(&quot;a test interaction&quot;) .matchPath(&quot;/transaction/[0-9]+&quot;) // or .matchPath(&quot;/transaction/[0-9]+&quot;, &quot;/transaction/1234567890&quot;) .method(&quot;POST&quot;) .body(&quot;{\&quot;name\&quot;: \&quot;harry\&quot;}&quot;) .willRespondWith() .status(200) .body(&quot;{\&quot;hello\&quot;: \&quot;harry\&quot;}&quot;) ``` ### Matching on headers (version 2.2.2+) You can use regular expressions to match request and response headers. The DSL has a `matchHeader` method for this. You can provide an example header value to use when generating requests and responses, and if you leave it out it will generate a random one from the regular expression. For example: ```java .given(&quot;test state&quot;) .uponReceiving(&quot;a test interaction&quot;) .path(&quot;/hello&quot;) .method(&quot;POST&quot;) .matchHeader(&quot;testreqheader&quot;, &quot;test.*value&quot;) .body(&quot;{\&quot;name\&quot;: \&quot;harry\&quot;}&quot;) .willRespondWith() .status(200) .body(&quot;{\&quot;hello\&quot;: \&quot;harry\&quot;}&quot;) .matchHeader(&quot;Location&quot;, &quot;.*/hello/[0-9]+&quot;, &quot;/hello/1234&quot;) ``` ### Matching on query parameters (version 3.3.7+) You can use regular expressions to match request query parameters. The DSL has a `matchQuery` method for this. You can provide an example value to use when generating requests, and if you leave it out it will generate a random one from the regular expression. For example: ```java .given(&quot;test state&quot;) .uponReceiving(&quot;a test interaction&quot;) .path(&quot;/hello&quot;) .method(&quot;POST&quot;) .matchQuery(&quot;a&quot;, &quot;\\d+&quot;, &quot;100&quot;) .matchQuery(&quot;b&quot;, &quot;[A-Z]&quot;, &quot;X&quot;) .body(&quot;{\&quot;name\&quot;: \&quot;harry\&quot;}&quot;) .willRespondWith() .status(200) .body(&quot;{\&quot;hello\&quot;: \&quot;harry\&quot;}&quot;) ``` # Forcing pact files to be overwritten (3.6.5+) By default, when the pact file is written, it will be merged with any existing pact file. To force the file to be overwritten, set the Java system property `pact.writer.overwrite` to `true`. # Having values injected from provider state callbacks (3.6.11+) You can have values from the provider state callbacks be injected into most places (paths, query parameters, headers, bodies, etc.). This works by using the V3 spec generators with provider state callbacks that return values. One example of where this would be useful is API calls that require an ID which would be auto-generated by the database on the provider side, so there is no way to know what the ID would be beforehand. The following DSL methods allow you to set an expression that will be parsed with the values returned from the provider states: For JSON bodies, use `valueFromProviderState`.&lt;br/&gt; For headers, use `headerFromProviderState`.&lt;br/&gt; For query parameters, use `queryParameterFromProviderState`.&lt;br/&gt; For paths, use `pathFromProviderState`. For example, assume that an API call is made to get the details of a user by ID. A provider state can be defined that specifies that the user must be exist, but the ID will be created when the user is created. So we can then define an expression for the path where the ID will be replaced with the value returned from the provider state callback. ```java .pathFromProviderState(&quot;/api/users/${id}&quot;, &quot;/api/users/100&quot;) ``` You can also just use the key instead of an expression: ```java .valueFromProviderState(&apos;userId&apos;, &apos;userId&apos;, 100) // will look value using userId as the key ```

Group: au.com.dius Artifact: pact-jvm-consumer_2.12
Show all versions Show documentation Show source 
 

2 downloads
Artifact pact-jvm-consumer_2.12
Group au.com.dius
Version 3.6.15
Last update 29. April 2020
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 12
Dependencies pact-jvm-model, pact-jvm-matchers_2.12, diffutils, automaton, httpclient, json, netty-handler, httpmime, unfiltered-netty-server_2.12, fluent-hc, scala-java8-compat_2.12, groovy-json,
There are maybe transitive dependencies!

pact-jvm-consumer from group au.com.dius (version 4.0.10)

Pact consumer ============= Pact Consumer is used by projects that are consumers of an API. Most projects will want to use pact-consumer via one of the test framework specific projects. If your favourite framework is not implemented, this module should give you all the hooks you need. Provides a DSL for use with Java to build consumer pacts. ## Dependency The library is available on maven central using: * group-id = `au.com.dius` * artifact-id = `pact-jvm-consumer` ## DSL Usage Example in a JUnit test: ```java import au.com.dius.pact.model.MockProviderConfig; import au.com.dius.pact.model.RequestResponsePact; import org.apache.http.entity.ContentType; import org.jetbrains.annotations.NotNull; import org.junit.Test; import java.io.IOException; import java.util.HashMap; import java.util.Map; import static au.com.dius.pact.consumer.ConsumerPactRunnerKt.runConsumerTest; import static org.junit.Assert.assertEquals; public class PactTest { @Test public void testPact() { RequestResponsePact pact = ConsumerPactBuilder .consumer(&quot;Some Consumer&quot;) .hasPactWith(&quot;Some Provider&quot;) .uponReceiving(&quot;a request to say Hello&quot;) .path(&quot;/hello&quot;) .method(&quot;POST&quot;) .body(&quot;{\&quot;name\&quot;: \&quot;harry\&quot;}&quot;) .willRespondWith() .status(200) .body(&quot;{\&quot;hello\&quot;: \&quot;harry\&quot;}&quot;) .toPact(); MockProviderConfig config = MockProviderConfig.createDefault(); PactVerificationResult result = runConsumerTest(pact, config, new PactTestRun() { @Override public void run(@NotNull MockServer mockServer) throws IOException { Map expectedResponse = new HashMap(); expectedResponse.put(&quot;hello&quot;, &quot;harry&quot;); assertEquals(expectedResponse, new ConsumerClient(mockServer.getUrl()).post(&quot;/hello&quot;, &quot;{\&quot;name\&quot;: \&quot;harry\&quot;}&quot;, ContentType.APPLICATION_JSON)); } }); if (result instanceof PactVerificationResult.Error) { throw new RuntimeException(((PactVerificationResult.Error)result).getError()); } assertEquals(PactVerificationResult.Ok.INSTANCE, result); } } ``` The DSL has the following pattern: ```java .consumer(&quot;Some Consumer&quot;) .hasPactWith(&quot;Some Provider&quot;) .given(&quot;a certain state on the provider&quot;) .uponReceiving(&quot;a request for something&quot;) .path(&quot;/hello&quot;) .method(&quot;POST&quot;) .body(&quot;{\&quot;name\&quot;: \&quot;harry\&quot;}&quot;) .willRespondWith() .status(200) .body(&quot;{\&quot;hello\&quot;: \&quot;harry\&quot;}&quot;) .uponReceiving(&quot;another request for something&quot;) .path(&quot;/hello&quot;) .method(&quot;POST&quot;) .body(&quot;{\&quot;name\&quot;: \&quot;harry\&quot;}&quot;) .willRespondWith() .status(200) .body(&quot;{\&quot;hello\&quot;: \&quot;harry\&quot;}&quot;) . . . .toPact() ``` You can define as many interactions as required. Each interaction starts with `uponReceiving` followed by `willRespondWith`. The test state setup with `given` is a mechanism to describe what the state of the provider should be in before the provider is verified. It is only recorded in the consumer tests and used by the provider verification tasks. ### Building JSON bodies with PactDslJsonBody DSL The body method of the ConsumerPactBuilder can accept a PactDslJsonBody, which can construct a JSON body as well as define regex and type matchers. For example: ```java PactDslJsonBody body = new PactDslJsonBody() .stringType(&quot;name&quot;) .booleanType(&quot;happy&quot;) .hexValue(&quot;hexCode&quot;) .id() .ipAddress(&quot;localAddress&quot;) .numberValue(&quot;age&quot;, 100) .timestamp(); ``` #### DSL Matching methods The following matching methods are provided with the DSL. In most cases, they take an optional value parameter which will be used to generate example values (i.e. when returning a mock response). If no example value is given, a random one will be generated. | method | description | |--------|-------------| | string, stringValue | Match a string value (using string equality) | | number, numberValue | Match a number value (using Number.equals)\* | | booleanValue | Match a boolean value (using equality) | | stringType | Will match all Strings | | numberType | Will match all numbers\* | | integerType | Will match all numbers that are integers (both ints and longs)\* | | decimalType | Will match all real numbers (floating point and decimal)\* | | booleanType | Will match all boolean values (true and false) | | stringMatcher | Will match strings using the provided regular expression | | timestamp | Will match string containing timestamps. If a timestamp format is not given, will match an ISO timestamp format | | date | Will match string containing dates. If a date format is not given, will match an ISO date format | | time | Will match string containing times. If a time format is not given, will match an ISO time format | | ipAddress | Will match string containing IP4 formatted address. | | id | Will match all numbers by type | | hexValue | Will match all hexadecimal encoded strings | | uuid | Will match strings containing UUIDs | | includesStr | Will match strings containing the provided string | | equalsTo | Will match using equals | | matchUrl | Defines a matcher for URLs, given the base URL path and a sequence of path fragments. The path fragments could be strings or regular expression matchers | _\* Note:_ JSON only supports double precision floating point values. Depending on the language implementation, they may parsed as integer, floating point or decimal numbers. #### Ensuring all items in a list match an example (2.2.0+) Lots of the time you might not know the number of items that will be in a list, but you want to ensure that the list has a minimum or maximum size and that each item in the list matches a given example. You can do this with the `arrayLike`, `minArrayLike` and `maxArrayLike` functions. | function | description | |----------|-------------| | `eachLike` | Ensure that each item in the list matches the provided example | | `maxArrayLike` | Ensure that each item in the list matches the provided example and the list is no bigger than the provided max | | `minArrayLike` | Ensure that each item in the list matches the provided example and the list is no smaller than the provided min | For example: ```java DslPart body = new PactDslJsonBody() .minArrayLike(&quot;users&quot;) .id() .stringType(&quot;name&quot;) .closeObject() .closeArray(); ``` This will ensure that the users list is never empty and that each user has an identifier that is a number and a name that is a string. #### Matching JSON values at the root For cases where you are expecting basic JSON values (strings, numbers, booleans and null) at the root level of the body and need to use matchers, you can use the `PactDslJsonRootValue` class. It has all the DSL matching methods for basic values that you can use. For example: ```java .consumer(&quot;Some Consumer&quot;) .hasPactWith(&quot;Some Provider&quot;) .uponReceiving(&quot;a request for a basic JSON value&quot;) .path(&quot;/hello&quot;) .willRespondWith() .status(200) .body(PactDslJsonRootValue.integerType()) ``` #### Root level arrays that match all items If the root of the body is an array, you can create PactDslJsonArray classes with the following methods: | function | description | |----------|-------------| | `arrayEachLike` | Ensure that each item in the list matches the provided example | | `arrayMinLike` | Ensure that each item in the list matches the provided example and the list is no bigger than the provided max | | `arrayMaxLike` | Ensure that each item in the list matches the provided example and the list is no smaller than the provided min | For example: ```java PactDslJsonArray.arrayEachLike() .date(&quot;clearedDate&quot;, &quot;mm/dd/yyyy&quot;, date) .stringType(&quot;status&quot;, &quot;STATUS&quot;) .decimalType(&quot;amount&quot;, 100.0) .closeObject() ``` This will then match a body like: ```json [ { &quot;clearedDate&quot; : &quot;07/22/2015&quot;, &quot;status&quot; : &quot;C&quot;, &quot;amount&quot; : 15.0 }, { &quot;clearedDate&quot; : &quot;07/22/2015&quot;, &quot;status&quot; : &quot;C&quot;, &quot;amount&quot; : 15.0 }, { &quot;clearedDate&quot; : &quot;07/22/2015&quot;, &quot;status&quot; : &quot;C&quot;, &quot;amount&quot; : 15.0 } ] ``` #### Matching arrays of arrays For the case where you have arrays of arrays (GeoJSON is an example), the following methods have been provided: | function | description | |----------|-------------| | `eachArrayLike` | Ensure that each item in the array is an array that matches the provided example | | `eachArrayWithMaxLike` | Ensure that each item in the array is an array that matches the provided example and the array is no bigger than the provided max | | `eachArrayWithMinLike` | Ensure that each item in the array is an array that matches the provided example and the array is no smaller than the provided min | For example (with GeoJSON structure): ```java new PactDslJsonBody() .stringType(&quot;type&quot;,&quot;FeatureCollection&quot;) .eachLike(&quot;features&quot;) .stringType(&quot;type&quot;,&quot;Feature&quot;) .object(&quot;geometry&quot;) .stringType(&quot;type&quot;,&quot;Point&quot;) .eachArrayLike(&quot;coordinates&quot;) // coordinates is an array of arrays .decimalType(-7.55717) .decimalType(49.766896) .closeArray() .closeArray() .closeObject() .object(&quot;properties&quot;) .stringType(&quot;prop0&quot;,&quot;value0&quot;) .closeObject() .closeObject() .closeArray() ``` This generated the following JSON: ```json { &quot;features&quot;: [ { &quot;geometry&quot;: { &quot;coordinates&quot;: [[-7.55717, 49.766896]], &quot;type&quot;: &quot;Point&quot; }, &quot;type&quot;: &quot;Feature&quot;, &quot;properties&quot;: { &quot;prop0&quot;: &quot;value0&quot; } } ], &quot;type&quot;: &quot;FeatureCollection&quot; } ``` and will be able to match all coordinates regardless of the number of coordinates. #### Matching any key in a map The DSL has been extended for cases where the keys in a map are IDs. For an example of this, see [#313](https://github.com/DiUS/pact-jvm/issues/313). In this case you can use the `eachKeyLike` method, which takes an example key as a parameter. For example: ```java DslPart body = new PactDslJsonBody() .object(&quot;one&quot;) .eachKeyLike(&quot;001&quot;, PactDslJsonRootValue.id(12345L)) // key like an id mapped to a matcher .closeObject() .object(&quot;two&quot;) .eachKeyLike(&quot;001-A&quot;) // key like an id where the value is matched by the following example .stringType(&quot;description&quot;, &quot;Some Description&quot;) .closeObject() .closeObject() .object(&quot;three&quot;) .eachKeyMappedToAnArrayLike(&quot;001&quot;) // key like an id mapped to an array where each item is matched by the following example .id(&quot;someId&quot;, 23456L) .closeObject() .closeArray() .closeObject(); ``` For an example, have a look at [WildcardKeysTest](../pact-jvm-consumer-junit/src/test/java/au/com/dius/pact/consumer/WildcardKeysTest.java). **NOTE:** The `eachKeyLike` method adds a `*` to the matching path, so the matching definition will be applied to all keys of the map if there is not a more specific matcher defined for a particular key. Having more than one `eachKeyLike` condition applied to a map will result in only one being applied when the pact is verified (probably the last). **Further Note: From version 3.5.22 onwards pacts with wildcards applied to map keys will require the Java system property &quot;pact.matching.wildcard&quot; set to value &quot;true&quot; when the pact file is verified.** ### Matching on paths You can use regular expressions to match incoming requests. The DSL has a `matchPath` method for this. You can provide a real path as a second value to use when generating requests, and if you leave it out it will generate a random one from the regular expression. For example: ```java .given(&quot;test state&quot;) .uponReceiving(&quot;a test interaction&quot;) .matchPath(&quot;/transaction/[0-9]+&quot;) // or .matchPath(&quot;/transaction/[0-9]+&quot;, &quot;/transaction/1234567890&quot;) .method(&quot;POST&quot;) .body(&quot;{\&quot;name\&quot;: \&quot;harry\&quot;}&quot;) .willRespondWith() .status(200) .body(&quot;{\&quot;hello\&quot;: \&quot;harry\&quot;}&quot;) ``` ### Matching on headers You can use regular expressions to match request and response headers. The DSL has a `matchHeader` method for this. You can provide an example header value to use when generating requests and responses, and if you leave it out it will generate a random one from the regular expression. For example: ```java .given(&quot;test state&quot;) .uponReceiving(&quot;a test interaction&quot;) .path(&quot;/hello&quot;) .method(&quot;POST&quot;) .matchHeader(&quot;testreqheader&quot;, &quot;test.*value&quot;) .body(&quot;{\&quot;name\&quot;: \&quot;harry\&quot;}&quot;) .willRespondWith() .status(200) .body(&quot;{\&quot;hello\&quot;: \&quot;harry\&quot;}&quot;) .matchHeader(&quot;Location&quot;, &quot;.*/hello/[0-9]+&quot;, &quot;/hello/1234&quot;) ``` ### Matching on query parameters You can use regular expressions to match request query parameters. The DSL has a `matchQuery` method for this. You can provide an example value to use when generating requests, and if you leave it out it will generate a random one from the regular expression. For example: ```java .given(&quot;test state&quot;) .uponReceiving(&quot;a test interaction&quot;) .path(&quot;/hello&quot;) .method(&quot;POST&quot;) .matchQuery(&quot;a&quot;, &quot;\\d+&quot;, &quot;100&quot;) .matchQuery(&quot;b&quot;, &quot;[A-Z]&quot;, &quot;X&quot;) .body(&quot;{\&quot;name\&quot;: \&quot;harry\&quot;}&quot;) .willRespondWith() .status(200) .body(&quot;{\&quot;hello\&quot;: \&quot;harry\&quot;}&quot;) ``` # Forcing pact files to be overwritten (3.6.5+) By default, when the pact file is written, it will be merged with any existing pact file. To force the file to be overwritten, set the Java system property `pact.writer.overwrite` to `true`. # Having values injected from provider state callbacks (3.6.11+) You can have values from the provider state callbacks be injected into most places (paths, query parameters, headers, bodies, etc.). This works by using the V3 spec generators with provider state callbacks that return values. One example of where this would be useful is API calls that require an ID which would be auto-generated by the database on the provider side, so there is no way to know what the ID would be beforehand. The following DSL methods allow you to set an expression that will be parsed with the values returned from the provider states: For JSON bodies, use `valueFromProviderState`.&lt;br/&gt; For headers, use `headerFromProviderState`.&lt;br/&gt; For query parameters, use `queryParameterFromProviderState`.&lt;br/&gt; For paths, use `pathFromProviderState`. For example, assume that an API call is made to get the details of a user by ID. A provider state can be defined that specifies that the user must be exist, but the ID will be created when the user is created. So we can then define an expression for the path where the ID will be replaced with the value returned from the provider state callback. ```java .pathFromProviderState(&quot;/api/users/${id}&quot;, &quot;/api/users/100&quot;) ``` You can also just use the key instead of an expression: ```java .valueFromProviderState(&apos;userId&apos;, &apos;userId&apos;, 100) // will look value using userId as the key ```

Group: au.com.dius Artifact: pact-jvm-consumer
Show all versions Show documentation Show source 
 

0 downloads
Artifact pact-jvm-consumer
Group au.com.dius
Version 4.0.10
Last update 18. April 2020
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 9
Dependencies diffutils, automaton, httpclient, json, netty-handler, httpmime, fluent-hc, pact-jvm-core-model, pact-jvm-core-matchers,
There are maybe transitive dependencies!



Page 456 from 458 (items total 4572)


© 2015 - 2024 Weber Informatics LLC | Privacy Policy