From e71eb4d39158a27c25aec4d81c3ec1917e9d6ec0 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Mon, 6 Feb 2023 15:12:13 +1100 Subject: [PATCH] feat: Upgrade plugin driver to 0.3.0 (supports message metadata) --- ...dius.pact.kotlin-common-conventions.gradle | 1 + consumer/build.gradle | 2 +- consumer/groovy/build.gradle | 2 +- .../com/dius/pact/consumer/dsl/PactBuilder.kt | 33 ++++++++++++++++--- core/matchers/build.gradle | 2 +- pact-specification-test/build.gradle | 2 +- provider/build.gradle | 2 +- provider/junit5/build.gradle | 2 +- 8 files changed, 36 insertions(+), 10 deletions(-) diff --git a/buildSrc/src/main/groovy/au.com.dius.pact.kotlin-common-conventions.gradle b/buildSrc/src/main/groovy/au.com.dius.pact.kotlin-common-conventions.gradle index 29ff48517..77da95fbc 100644 --- a/buildSrc/src/main/groovy/au.com.dius.pact.kotlin-common-conventions.gradle +++ b/buildSrc/src/main/groovy/au.com.dius.pact.kotlin-common-conventions.gradle @@ -45,6 +45,7 @@ dependencies { implementation 'io.netty:netty-handler:4.1.84.Final' implementation 'org.apache.groovy:groovy:4.0.6' implementation 'org.apache.groovy:groovy-json:4.0.6' + implementation 'io.pact.plugin.driver:core:0.3.0' testImplementation 'org.apache.groovy:groovy:4.0.6' testImplementation 'org.apache.groovy:groovy-json:4.0.6' diff --git a/consumer/build.gradle b/consumer/build.gradle index bedb6c85b..524415f95 100644 --- a/consumer/build.gradle +++ b/consumer/build.gradle @@ -19,7 +19,7 @@ dependencies { implementation 'org.slf4j:slf4j-api' implementation 'io.ktor:ktor-server-netty' implementation 'io.ktor:ktor-network-tls-certificates' - implementation('io.pact.plugin.driver:core:0.2.1') { + implementation('io.pact.plugin.driver:core') { exclude group: 'au.com.dius.pact.core' } implementation 'org.apache.commons:commons-lang3' diff --git a/consumer/groovy/build.gradle b/consumer/groovy/build.gradle index 5bf5c9c97..65ff41499 100644 --- a/consumer/groovy/build.gradle +++ b/consumer/groovy/build.gradle @@ -14,7 +14,7 @@ dependencies { implementation 'com.github.mifmif:generex:1.0.2' implementation 'org.apache.commons:commons-lang3' implementation 'org.apache.commons:commons-collections4' - implementation('io.pact.plugin.driver:core:0.2.1') { + implementation('io.pact.plugin.driver:core') { exclude group: 'au.com.dius.pact.core' } diff --git a/consumer/src/main/kotlin/au/com/dius/pact/consumer/dsl/PactBuilder.kt b/consumer/src/main/kotlin/au/com/dius/pact/consumer/dsl/PactBuilder.kt index 16e8ea585..4ad1804a6 100644 --- a/consumer/src/main/kotlin/au/com/dius/pact/consumer/dsl/PactBuilder.kt +++ b/consumer/src/main/kotlin/au/com/dius/pact/consumer/dsl/PactBuilder.kt @@ -311,11 +311,23 @@ open class PactBuilder( when (val result = contentMatcher.setupBodyFromConfig(bodyConfig)) { is Ok -> { result.value.map { - val (partName, body, rules, generators, _, _, interactionMarkup, interactionMarkupType) = it + val ( + partName, + body, + rules, + generators, + _, _, + interactionMarkup, + interactionMarkupType, + metadataRules + ) = it val matchingRules = MatchingRulesImpl() if (rules != null) { matchingRules.addCategory(rules) } + if (metadataRules != null) { + matchingRules.addCategory(metadataRules) + } MessageContents(body, mapOf(), matchingRules, generators ?: Generators(), partName) to InteractionMarkup(interactionMarkup, interactionMarkupType) } @@ -333,11 +345,24 @@ open class PactBuilder( when (val result = matcher.configureContent(contentType, bodyConfig)) { is Ok -> { result.value.map { - val (partName, body, rules, generators, metadata, config, interactionMarkup, interactionMarkupType) = it + val ( + partName, + body, + rules, + generators, + metadata, + config, + interactionMarkup, + interactionMarkupType, + metadataRules + ) = it val matchingRules = MatchingRulesImpl() if (rules != null) { matchingRules.addCategory(rules) } + if (metadataRules != null) { + matchingRules.addCategory(metadataRules) + } if (config.interactionConfiguration.isNotEmpty()) { interaction.addPluginConfiguration(matcher.pluginName, config.interactionConfiguration) } @@ -384,7 +409,7 @@ open class PactBuilder( if (result.value.size > 1) { logger.warn { "Plugin returned multiple contents, will only use the first" } } - val (_, body, rules, generators, _, _, _, _) = result.value.first() + val (_, body, rules, generators, _, _, _, _, _) = result.value.first() part.body = body if (rules != null) { part.matchingRules.addCategory(rules) @@ -421,7 +446,7 @@ open class PactBuilder( if (result.value.size > 1) { logger.warn { "Plugin returned multiple contents, will only use the first" } } - val (_, body, rules, generators, _, config, interactionMarkup, interactionMarkupType) = result.value.first() + val (_, body, rules, generators, _, config, interactionMarkup, interactionMarkupType, _) = result.value.first() part.body = body if (!part.hasHeader("content-type")) { part.headers["content-type"] = listOf(body.contentType.toString()) diff --git a/core/matchers/build.gradle b/core/matchers/build.gradle index 3e6ffccc3..f7f7e1fe7 100644 --- a/core/matchers/build.gradle +++ b/core/matchers/build.gradle @@ -20,7 +20,7 @@ dependencies { implementation 'org.atteo:evo-inflector:1.3' implementation 'com.github.ajalt:mordant:1.2.1' implementation 'com.github.zafarkhaja:java-semver:0.9.0' - implementation('io.pact.plugin.driver:core:0.2.1') { + implementation('io.pact.plugin.driver:core') { exclude group: 'au.com.dius.pact.core' } diff --git a/pact-specification-test/build.gradle b/pact-specification-test/build.gradle index 5bdfbd31b..67fa4def6 100644 --- a/pact-specification-test/build.gradle +++ b/pact-specification-test/build.gradle @@ -12,7 +12,7 @@ dependencies { testImplementation 'org.apache.groovy:groovy' testImplementation 'org.apache.groovy:groovy-json' testImplementation 'org.apache.tika:tika-core' - testImplementation('io.pact.plugin.driver:core:0.2.1') { + testImplementation('io.pact.plugin.driver:core') { exclude group: 'au.com.dius.pact.core' } testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0' diff --git a/provider/build.gradle b/provider/build.gradle index ba62e8db4..d82340421 100644 --- a/provider/build.gradle +++ b/provider/build.gradle @@ -15,7 +15,7 @@ dependencies { implementation 'commons-io:commons-io:2.11.0' implementation 'org.slf4j:slf4j-api' - implementation('io.pact.plugin.driver:core:0.2.1') { + implementation('io.pact.plugin.driver:core') { exclude group: 'au.com.dius.pact.core' } implementation 'org.apache.commons:commons-lang3' diff --git a/provider/junit5/build.gradle b/provider/junit5/build.gradle index b99d777af..9a97c9d30 100644 --- a/provider/junit5/build.gradle +++ b/provider/junit5/build.gradle @@ -13,7 +13,7 @@ dependencies { api 'org.junit.jupiter:junit-jupiter-api:5.9.2' implementation 'org.slf4j:slf4j-api' - implementation('io.pact.plugin.driver:core:0.2.1') { + implementation('io.pact.plugin.driver:core') { exclude group: 'au.com.dius.pact.core' } implementation 'com.michael-bull.kotlin-result:kotlin-result:1.1.14'