Skip to content

Commit

Permalink
feat: Upgrade plugin driver to 0.3.0 (supports message metadata)
Browse files Browse the repository at this point in the history
  • Loading branch information
rholshausen committed Feb 6, 2023
1 parent 1a7ae68 commit e71eb4d
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion consumer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion consumer/groovy/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion core/matchers/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}

Expand Down
2 changes: 1 addition & 1 deletion pact-specification-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion provider/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion provider/junit5/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit e71eb4d

Please sign in to comment.