Skip to content

Commit

Permalink
fix: small cleanup of interactionId #1033
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronald Holshausen committed May 18, 2020
1 parent 1fd0360 commit 314f4c8
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ class PactBrokerClientPactSpec extends Specification {
providerApplicationVersion '10.0.0'
buildUrl 'http://localhost:8080/build'
testResults eachLike {
interactionId string()
interactionId string('12345678')
success false
exceptions eachLike {
message string('Boom!')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ open class InteractionRunner<I>(
notifier.fireTestFailure(Failure(description, e))
}
testResult = VerificationResult.Failed(listOf(mapOf("message" to "Request to provider failed with an exception",
"exception" to e, "interactionId" to interaction.interactionId)),
"exception" to e)),
"Request to provider failed with an exception", description.displayName,
listOf(VerificationFailureType.ExceptionFailure(e)), pending, interaction.interactionId)
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ data class PactVerificationContext @JvmOverloads constructor(
verifier!!.projectHasProperty.apply(ProviderVerifier.PACT_SHOW_STACKTRACE))
}
listOf(VerificationResult.Failed(listOf(mapOf("message" to "Request to provider failed with an exception",
"exception" to e, "interactionId" to interaction.interactionId)),
"exception" to e)),
"Request to provider failed with an exception", interactionMessage,
listOf(VerificationFailureType.ExceptionFailure(e)), consumer.pending, interaction.interactionId))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ open class MvcProviderVerifier(private val debugRequestResponse: Boolean = false
it.requestFailed(provider, interaction, interactionMessage, e, projectHasProperty.apply(PACT_SHOW_STACKTRACE))
}
return VerificationResult.Failed(listOf(mapOf("message" to "Request to provider method failed with an exception",
"exception" to e, "interactionId" to interaction.interactionId)),
"exception" to e)),
"Request to provider method failed with an exception", interactionMessage,
listOf(VerificationFailureType.ExceptionFailure(e)), pending, interaction.interactionId)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ open class ProviderVerifier @JvmOverloads constructor (
failures[interactionMessage] = e
reporters.forEach { it.verificationFailed(interaction, e, projectHasProperty.apply(PACT_SHOW_STACKTRACE)) }
return VerificationResult.Failed(listOf(mapOf("message" to "Request to provider method failed with an exception",
"exception" to e, "interactionId" to interaction.interactionId)),
"exception" to e)),
"Request to provider method failed with an exception", interactionMessage,
listOf(VerificationFailureType.ExceptionFailure(e)), consumer.pending, interaction.interactionId)
}
Expand All @@ -351,15 +351,13 @@ open class ProviderVerifier @JvmOverloads constructor (
when (comparison) {
is Err -> {
failures["$comparisonDescription has a matching body"] = comparison.error.description()
VerificationResult.Failed(listOf(comparison.error.toMap() +
mapOf("interactionId" to interactionId, "type" to "body")),
VerificationResult.Failed(listOf(comparison.error.toMap() + ("type" to "body")),
"Body had differences", comparisonDescription,
listOf(VerificationFailureType.MismatchFailure(comparison.error)), pending, interactionId)
}
is Ok -> {
failures["$comparisonDescription has a matching body"] = comparison.value
VerificationResult.Failed(listOf(comparison.value.mismatches +
mapOf("interactionId" to interactionId, "type" to "body")),
VerificationResult.Failed(listOf(comparison.value.mismatches + ("type" to "body")),
"Body had differences", comparisonDescription, comparison.value.mismatches.values.flatten()
.map { VerificationFailureType.MismatchFailure(it) }, pending, interactionId)
}
Expand Down Expand Up @@ -437,7 +435,7 @@ open class ProviderVerifier @JvmOverloads constructor (
failures["$comparisonDescription includes metadata \"$key\" with value \"$expectedValue\""] =
metadataComparison
result = result.merge(VerificationResult.Failed(listOf(mapOf(key to metadataComparison,
"interactionId" to interactionId, "type" to "metadata")),
"type" to "metadata")),
verificationDescription = comparisonDescription,
failures = metadataComparison.map { VerificationFailureType.MismatchFailure(it) }, pending = pending,
interactionId = interactionId
Expand Down Expand Up @@ -503,8 +501,7 @@ open class ProviderVerifier @JvmOverloads constructor (
return result
} else {
return VerificationResult.Failed(listOf(mapOf("message" to "State change request failed",
"exception" to stateChangeResult.stateChangeResult.getError(),
"interactionId" to interaction.interactionId)), "State change request failed",
"exception" to stateChangeResult.stateChangeResult.getError())), "State change request failed",
stateChangeResult.message,
listOf(VerificationFailureType.StateChangeFailure(stateChangeResult)),
consumer.pending, interaction.interactionId
Expand Down Expand Up @@ -557,8 +554,8 @@ open class ProviderVerifier @JvmOverloads constructor (
} else {
reporters.forEach { it.statusComparisonFailed(status, mismatch.description()) }
failures["$comparisonDescription has status code $status"] = mismatch.description()
VerificationResult.Failed(listOf(mismatch.toMap() + mapOf("interactionId" to interactionId,
"type" to "status")), "Response status did not match", comparisonDescription,
VerificationResult.Failed(listOf(mismatch.toMap() + ("type" to "status")),
"Response status did not match", comparisonDescription,
listOf(VerificationFailureType.MismatchFailure(mismatch)), pending, interactionId)
}
}
Expand Down Expand Up @@ -625,7 +622,7 @@ open class ProviderVerifier @JvmOverloads constructor (
it.requestFailed(provider, interaction, interactionMessage, e, projectHasProperty.apply(PACT_SHOW_STACKTRACE))
}
VerificationResult.Failed(listOf(mapOf("message" to "Request to provider failed with an exception",
"exception" to e, "interactionId" to interaction.interactionId)),
"exception" to e)),
"Request to provider method failed with an exception", interactionMessage,
listOf(VerificationFailureType.ExceptionFailure(e)), pending, interaction.interactionId)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ sealed class VerificationResult {
interactionId ?: result.interactionId)
}

override fun toTestResult() = TestResult.Failed(results, description)
override fun toTestResult() =
TestResult.Failed(results.map { it + ("interactionId" to interactionId) }, description)
}

/**
Expand Down

0 comments on commit 314f4c8

Please sign in to comment.