-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
159 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
pact-jvm-mockk-core/src/main/kotlin/io/github/ludorival/pactjvm/mockk/Matcher.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.github.ludorival.pactjvm.mockk | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty | ||
|
||
data class Matcher( | ||
val match: MatchEnum, | ||
val regex: String? = null, | ||
val max: Number? = null, | ||
val min: Number? = null, | ||
val value: String? = null, | ||
val format: String? = null | ||
) { | ||
enum class MatchEnum { | ||
@JsonProperty("regex") REGEX, | ||
@JsonProperty("type") TYPE, | ||
@JsonProperty("boolean") BOOLEAN, | ||
@JsonProperty("contentType") CONTENT_TYPE, | ||
@JsonProperty("date") DATE, | ||
@JsonProperty("datetime") DATETIME, | ||
@JsonProperty("decimal") DECIMAL, | ||
@JsonProperty("equality") EQUALITY, | ||
@JsonProperty("include") INCLUDE, | ||
@JsonProperty("integer") INTEGER, | ||
@JsonProperty("null") NULL, | ||
@JsonProperty("number") NUMBER, | ||
@JsonProperty("time") TIME, | ||
@JsonProperty("values") VALUES | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...-jvm-mockk-core/src/main/kotlin/io/github/ludorival/pactjvm/mockk/MatchingRulesBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.github.ludorival.pactjvm.mockk | ||
|
||
class MatchingRulesBuilder { | ||
private val body = mutableMapOf<String, Matcher>() | ||
private val header = mutableMapOf<String, Matcher>() | ||
private val path = mutableMapOf<String, Matcher>() | ||
private val query = mutableMapOf<String, Matcher>() | ||
|
||
fun body(path: String, matcher: Matcher ): MatchingRulesBuilder = apply { this.body[path] = matcher } | ||
fun header(path: String, matcher: Matcher ): MatchingRulesBuilder = apply { this.header[path] = matcher } | ||
fun path(path: String, matcher: Matcher ): MatchingRulesBuilder = apply { this.path[path] = matcher } | ||
fun query(path: String, matcher: Matcher ): MatchingRulesBuilder = apply { this.query[path] = matcher } | ||
|
||
fun build(): Pact.Interaction.MatchingRules? = | ||
Pact.Interaction.MatchingRules( | ||
body = body.toMap().ifEmpty { null }, | ||
header = header.toMap().ifEmpty { null }, | ||
path = path.toMap().ifEmpty { null }, | ||
query = query.toMap().ifEmpty { null } | ||
).takeIf { it.body != null || it.header != null || it.path != null || it.query != null } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.