Skip to content

Commit

Permalink
fix: com.michael-bull.kotlin-result was causing dependency issues #1639
Browse files Browse the repository at this point in the history
  • Loading branch information
rholshausen committed Nov 21, 2022
1 parent d9eff8f commit 3285203
Show file tree
Hide file tree
Showing 92 changed files with 842 additions and 858 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ dependencies {
implementation 'io.github.microutils:kotlin-logging:2.1.23'
implementation 'org.apache.httpcomponents.client5:httpclient5:5.1.1'
implementation 'org.apache.httpcomponents.client5:httpclient5-fluent:5.1.1'
implementation 'com.michael-bull.kotlin-result:kotlin-result:1.1.16'
implementation 'com.michael-bull.kotlin-result:kotlin-result-jvm:1.1.16'
implementation 'com.google.guava:guava:30.1.1-jre'
implementation 'org.slf4j:slf4j-api:1.7.32'
implementation 'io.ktor:ktor-http-jvm:1.6.8'
Expand Down
3 changes: 2 additions & 1 deletion consumer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ 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.1.7') {
implementation('io.pact.plugin.driver:core:0.1.8') {
exclude group: 'au.com.dius.pact.core'
}
implementation 'org.apache.commons:commons-lang3'
implementation 'com.github.mifmif:generex:1.0.2'
implementation 'org.apache.commons:commons-io:1.3.2'
implementation 'org.apache.commons:commons-text:1.9'
implementation 'com.michael-bull.kotlin-result:kotlin-result:1.1.14'

testImplementation 'org.hamcrest:hamcrest'
testImplementation 'org.spockframework:spock-core'
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.1.7') {
implementation('io.pact.plugin.driver:core:0.1.8') {
exclude group: 'au.com.dius.pact.core'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void evaluate() throws Throwable {
}

if (config.getPactVersion() == PactSpecVersion.V4) {
pact.get().asV4Pact().component1().getInteractions()
pact.get().asV4Pact().get().getInteractions()
.forEach(i -> i.getComments().put("testname", Json.toJson(description.getDisplayName())));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import au.com.dius.pact.core.support.MetricEvent
import au.com.dius.pact.core.support.Metrics
import au.com.dius.pact.core.support.expressions.DataType
import au.com.dius.pact.core.support.expressions.ExpressionParser
import com.github.michaelbull.result.unwrap
import mu.KLogging
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Nested
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ import au.com.dius.pact.core.model.Interaction
import au.com.dius.pact.core.model.InvalidPactException
import au.com.dius.pact.core.model.Pact
import au.com.dius.pact.core.model.PactSpecVersion
import au.com.dius.pact.core.model.RequestResponsePact
import au.com.dius.pact.core.model.messaging.Message
import au.com.dius.pact.core.model.messaging.MessagePact
import au.com.dius.pact.core.support.V4PactFeaturesException
import com.github.michaelbull.result.expect

interface PactTestRun<R> {
@Throws(Throwable::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import au.com.dius.pact.core.model.IResponse
import au.com.dius.pact.core.model.OptionalBody
import au.com.dius.pact.core.model.Pact
import au.com.dius.pact.core.model.Request
import au.com.dius.pact.core.model.RequestResponsePact
import au.com.dius.pact.core.model.Response
import com.github.michaelbull.result.Err
import com.github.michaelbull.result.Ok
import au.com.dius.pact.core.support.Result
import io.ktor.application.ApplicationCall
import io.ktor.application.ApplicationCallPipeline
import io.ktor.application.install
Expand Down Expand Up @@ -127,13 +125,13 @@ class KTorMockServer(
override fun updatePact(pact: Pact): Pact {
return if (pact.isV4Pact()) {
when (val p = pact.asV4Pact()) {
is Ok -> {
is Result.Ok -> {
for (interaction in p.value.interactions) {
interaction.asV4Interaction().transport = if (config is MockHttpsProviderConfig) "https" else "http"
}
p.value
}
is Err -> pact
is Result.Err -> pact
}
} else {
pact
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import au.com.dius.pact.core.model.Response
import au.com.dius.pact.core.model.V4Pact
import au.com.dius.pact.core.model.generators.GeneratorTestMode
import au.com.dius.pact.core.model.queryStringToMap
import au.com.dius.pact.core.support.Result
import au.com.dius.pact.core.support.unwrap
import com.github.michaelbull.result.Err
import com.github.michaelbull.result.Ok
Expand Down Expand Up @@ -354,13 +355,13 @@ open class MockHttpServer(pact: BasePact, config: MockProviderConfig) :
override fun updatePact(pact: Pact): Pact {
return if (pact.isV4Pact()) {
when (val p = pact.asV4Pact()) {
is Ok -> {
is Result.Ok -> {
for (interaction in p.value.interactions) {
interaction.asV4Interaction().transport = "https"
}
p.value
}
is Err -> pact
is Result.Err -> pact
}
} else {
pact
Expand All @@ -373,13 +374,13 @@ open class MockHttpsServer(pact: BasePact, config: MockProviderConfig) :
override fun updatePact(pact: Pact): Pact {
return if (pact.isV4Pact()) {
when (val p = pact.asV4Pact()) {
is Ok -> {
is Result.Ok -> {
for (interaction in p.value.interactions) {
interaction.asV4Interaction().transport = "https"
}
p.value
}
is Err -> pact
is Result.Err -> pact
}
} else {
pact
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import au.com.dius.pact.core.model.BasePact
import au.com.dius.pact.core.model.Pact
import au.com.dius.pact.core.support.contains
import au.com.dius.pact.core.support.isNotEmpty
import com.github.michaelbull.result.Err
import com.github.michaelbull.result.Ok
import au.com.dius.pact.core.support.Result
import io.pact.plugins.jvm.core.CatalogueEntry
import io.pact.plugins.jvm.core.CatalogueManager
import io.pact.plugins.jvm.core.DefaultPluginManager
Expand Down Expand Up @@ -67,13 +66,13 @@ class PluginMockServer(pact: BasePact, config: MockProviderConfig) : BaseMockSer
override fun updatePact(pact: Pact): Pact {
return if (pact.isV4Pact()) {
when (val p = pact.asV4Pact()) {
is Ok -> {
is Result.Ok -> {
for (interaction in p.value.interactions) {
interaction.asV4Interaction().transport = transportEntry.key
}
p.value
}
is Err -> pact
is Result.Err -> pact
}
} else {
pact
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import au.com.dius.pact.core.support.isNotEmpty
import au.com.dius.pact.core.support.json.JsonValue
import com.github.michaelbull.result.Err
import com.github.michaelbull.result.Ok
import au.com.dius.pact.core.support.Result
import io.pact.plugins.jvm.core.CatalogueEntry
import io.pact.plugins.jvm.core.CatalogueEntryProviderType
import io.pact.plugins.jvm.core.CatalogueEntryType
Expand Down Expand Up @@ -233,7 +234,7 @@ open class PactBuilder(
val contentMatcher = MatchingConfig.lookupContentMatcher(contentType)
if (contentMatcher != null) {
when (val result = contentMatcher.setupBodyFromConfig(bodyConfig)) {
is Ok -> {
is Result.Ok -> {
result.value.map {
val (partName, body, rules, generators, _, _, interactionMarkup, interactionMarkupType) = it
val matchingRules = MatchingRulesImpl()
Expand All @@ -244,7 +245,7 @@ open class PactBuilder(
InteractionMarkup(interactionMarkup, interactionMarkupType)
}
}
is Err -> throw InteractionConfigurationError("Failed to set the interaction: " + result.error)
is Result.Err -> throw InteractionConfigurationError("Failed to set the interaction: " + result.error)
}
} else {
listOf(
Expand Down Expand Up @@ -303,7 +304,7 @@ open class PactBuilder(
val contentMatcher = MatchingConfig.lookupContentMatcher(contentType)
if (contentMatcher != null) {
when (val result = contentMatcher.setupBodyFromConfig(bodyConfig)) {
is Ok -> {
is Result.Ok -> {
if (result.value.size > 1) {
logger.warn { "Plugin returned multiple contents, will only use the first" }
}
Expand All @@ -316,7 +317,7 @@ open class PactBuilder(
part.generators.addGenerators(generators)
}
}
is Err -> throw InteractionConfigurationError("Failed to set the interaction: " + result.error)
is Result.Err -> throw InteractionConfigurationError("Failed to set the interaction: " + result.error)
}
} else {
part.body = OptionalBody.body(toJson(bodyConfig).serialise().toByteArray(), ContentType(contentType))
Expand Down
3 changes: 2 additions & 1 deletion core/matchers/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ 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.1.7') {
implementation('io.pact.plugin.driver:core:0.1.8') {
exclude group: 'au.com.dius.pact.core'
}
implementation 'com.michael-bull.kotlin-result:kotlin-result:1.1.14'

testImplementation 'org.apache.groovy:groovy'
testImplementation 'org.apache.groovy:groovy-xml'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package au.com.dius.pact.core.matchers

import au.com.dius.pact.core.model.OptionalBody
import com.github.michaelbull.result.Result
import au.com.dius.pact.core.support.Result
import io.pact.plugins.jvm.core.InteractionContents

interface ContentMatcher {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ package au.com.dius.pact.core.matchers

import au.com.dius.pact.core.model.ContentType
import au.com.dius.pact.core.model.OptionalBody
import au.com.dius.pact.core.model.generators.Generators
import au.com.dius.pact.core.model.matchingrules.MatchingRuleCategory
import com.github.michaelbull.result.Ok
import com.github.michaelbull.result.Result
import au.com.dius.pact.core.support.Result
import io.pact.plugins.jvm.core.InteractionContents
import mu.KLogging
import org.apache.hc.core5.http.NameValuePair
Expand Down Expand Up @@ -36,7 +33,7 @@ class FormPostContentMatcher : ContentMatcher {
override fun setupBodyFromConfig(
bodyConfig: Map<String, Any?>
): Result<List<InteractionContents>, String> {
return Ok(listOf(InteractionContents("", OptionalBody.body(
return Result.Ok(listOf(InteractionContents("", OptionalBody.body(
bodyConfig["body"].toString().toByteArray(),
ContentType("application/x-www-form-urlencoded")
))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import au.com.dius.pact.core.model.ContentType
import au.com.dius.pact.core.model.OptionalBody
import au.com.dius.pact.core.model.constructPath
import au.com.dius.pact.core.support.Json.toJson
import au.com.dius.pact.core.support.Result
import au.com.dius.pact.core.support.json.JsonParser
import au.com.dius.pact.core.support.json.JsonValue
import com.github.michaelbull.result.Ok
import com.github.michaelbull.result.Result
import io.pact.plugins.jvm.core.InteractionContents
import mu.KLogging

Expand Down Expand Up @@ -43,7 +42,7 @@ object JsonContentMatcher : ContentMatcher, KLogging() {
override fun setupBodyFromConfig(
bodyConfig: Map<String, Any?>
): Result<List<InteractionContents>, String> {
return Ok(listOf(InteractionContents("",
return Result.Ok(listOf(InteractionContents("",
OptionalBody.body(
toJson(bodyConfig["body"]).serialise().toByteArray(),
ContentType("application/json")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ package au.com.dius.pact.core.matchers
import au.com.dius.pact.core.model.ContentType
import au.com.dius.pact.core.model.OptionalBody
import au.com.dius.pact.core.support.Json
import au.com.dius.pact.core.support.Result
import au.com.dius.pact.core.support.json.JsonException
import au.com.dius.pact.core.support.json.JsonParser
import au.com.dius.pact.core.support.json.KafkaSchemaRegistryWireFormatter
import com.github.michaelbull.result.Ok
import com.github.michaelbull.result.Result
import io.pact.plugins.jvm.core.InteractionContents
import mu.KLogging

Expand Down Expand Up @@ -57,7 +56,7 @@ class KafkaJsonSchemaContentMatcher : ContentMatcher {
override fun setupBodyFromConfig(
bodyConfig: Map<String, Any?>
): Result<List<InteractionContents>, String> {
return Ok(listOf(InteractionContents("",
return Result.Ok(listOf(InteractionContents("",
OptionalBody.body(
Json.toJson(bodyConfig["body"]).serialise().toByteArray(),
ContentType.KAFKA_SCHEMA_REGISTRY_JSON
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ package au.com.dius.pact.core.matchers

import au.com.dius.pact.core.model.ContentType
import au.com.dius.pact.core.model.OptionalBody
import au.com.dius.pact.core.model.generators.Generators
import au.com.dius.pact.core.model.matchingrules.MatchingRuleCategory
import com.github.michaelbull.result.Ok
import com.github.michaelbull.result.Result
import au.com.dius.pact.core.support.Result
import io.pact.plugins.jvm.core.InteractionContents
import mu.KLogging
import java.util.Enumeration
Expand Down Expand Up @@ -39,7 +36,7 @@ class MultipartMessageContentMatcher : ContentMatcher {
override fun setupBodyFromConfig(
bodyConfig: Map<String, Any?>
): Result<List<InteractionContents>, String> {
return Ok(listOf(InteractionContents("",
return Result.Ok(listOf(InteractionContents("",
OptionalBody.body(
bodyConfig["body"].toString().toByteArray(),
ContentType("multipart/form-data")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package au.com.dius.pact.core.matchers
import au.com.dius.pact.core.model.ContentType
import au.com.dius.pact.core.model.OptionalBody
import au.com.dius.pact.core.model.matchingrules.RegexMatcher
import com.github.michaelbull.result.Ok
import com.github.michaelbull.result.Result
import au.com.dius.pact.core.support.Result
import io.pact.plugins.jvm.core.InteractionContents
import mu.KLogging

Expand Down Expand Up @@ -56,7 +55,7 @@ class PlainTextContentMatcher : ContentMatcher {
override fun setupBodyFromConfig(
bodyConfig: Map<String, Any?>
): Result<List<InteractionContents>, String> {
return Ok(listOf(InteractionContents("",
return Result.Ok(listOf(InteractionContents("",
OptionalBody.body(
bodyConfig["body"].toString().toByteArray(),
ContentType("text/plain")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package au.com.dius.pact.core.matchers

import au.com.dius.pact.core.model.ContentType
import au.com.dius.pact.core.model.OptionalBody
import com.github.michaelbull.result.Result
import au.com.dius.pact.core.support.Result
import com.github.michaelbull.result.Err
import com.github.michaelbull.result.Ok
import io.pact.plugins.jvm.core.InteractionContents
import mu.KLogging

Expand All @@ -28,7 +30,10 @@ class PluginContentMatcher(
override fun setupBodyFromConfig(
bodyConfig: Map<String, Any?>
): Result<List<InteractionContents>, String> {
return contentMatcher.configureContent(contentType.toString(), bodyConfig)
return when (val result = contentMatcher.configureContent(contentType.toString(), bodyConfig)) {
is Ok -> Result.Ok(result.value)
is Err -> Result.Err(result.error)
}
}

companion object : KLogging()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ package au.com.dius.pact.core.matchers

import au.com.dius.pact.core.model.ContentType
import au.com.dius.pact.core.model.OptionalBody
import au.com.dius.pact.core.model.generators.Generators
import au.com.dius.pact.core.model.matchingrules.MatchingRuleCategory
import au.com.dius.pact.core.support.Result
import au.com.dius.pact.core.support.zipAll
import com.github.michaelbull.result.Ok
import com.github.michaelbull.result.Result
import io.pact.plugins.jvm.core.InteractionContents
import mu.KLogging
import org.apache.xerces.dom.TextImpl
Expand Down Expand Up @@ -46,7 +43,7 @@ object XmlContentMatcher : ContentMatcher, KLogging() {
override fun setupBodyFromConfig(
bodyConfig: Map<String, Any?>
): Result<List<InteractionContents>, String> {
return Ok(listOf(InteractionContents("",
return Result.Ok(listOf(InteractionContents("",
OptionalBody.body(
bodyConfig["body"].toString().toByteArray(),
ContentType("application/xml")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package au.com.dius.pact.core.model

import au.com.dius.pact.core.support.Json
import au.com.dius.pact.core.support.Result
import au.com.dius.pact.core.support.Utils
import au.com.dius.pact.core.support.json.JsonValue
import com.github.michaelbull.result.Err
import com.github.michaelbull.result.Ok
import com.github.michaelbull.result.Result
import mu.KLogging
import java.io.File
import java.util.Collections
Expand All @@ -30,11 +28,11 @@ abstract class BasePact @JvmOverloads constructor(

override fun compatibleTo(other: Pact): Result<Boolean, String> {
return if (provider != other.provider) {
Err("Provider names are different: '$provider' and '${other.provider}'")
Result.Err("Provider names are different: '$provider' and '${other.provider}'")
} else if (!this::class.java.isAssignableFrom(other::class.java)) {
Err("Pact types different: '${other::class.simpleName}' can not be assigned to '${this::class.simpleName}'")
Result.Err("Pact types different: '${other::class.simpleName}' can not be assigned to '${this::class.simpleName}'")
} else {
Ok(true)
Result.Ok(true)
}
}

Expand Down
Loading

0 comments on commit 3285203

Please sign in to comment.