Skip to content

Commit f8997d7

Browse files
authoredMar 21, 2020
Merge branch 'master' into fix-1049
2 parents 7d6a507 + 049ac1f commit f8997d7

File tree

19 files changed

+350
-156
lines changed

19 files changed

+350
-156
lines changed
 

Diff for: ‎build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ buildscript {
1010
}
1111

1212
plugins {
13-
id 'nebula.kotlin' version '1.3.60'
13+
id 'nebula.kotlin' version '1.3.70'
1414
id 'org.jmailen.kotlinter' version '1.26.0'
1515
id 'io.gitlab.arturbosch.detekt' version '1.0.0-RC14'
1616
id 'org.jetbrains.dokka' version '0.10.0'

Diff for: ‎consumer/pact-jvm-consumer-groovy/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ overwritten, set the Java system property `pact.writer.overwrite` to `true`.
530530

531531
# Publishing your pact files to a pact broker
532532

533-
If you use Gradle, you can use the [pact Gradle plugin](https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-gradle#publishing-pact-files-to-a-pact-broker) to publish your pact files.
533+
If you use Gradle, you can use the [pact Gradle plugin](https://github.com/DiUS/pact-jvm/tree/master/provider/pact-jvm-provider-gradle#publishing-pact-files-to-a-pact-broker) to publish your pact files.
534534

535535
# Pact Specification V3
536536

Diff for: ‎consumer/pact-jvm-consumer-java8/build.gradle

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
dependencies {
22
api project(path: ":consumer:pact-jvm-consumer", configuration: 'default')
33

4-
testCompile "org.junit.jupiter:junit-jupiter-api:${project.junit5Version}"
5-
testRuntime "org.junit.vintage:junit-vintage-engine:${project.junit5Version}"
4+
testImplementation "org.junit.jupiter:junit-jupiter:${project.junit5Version}"
65
testRuntime "ch.qos.logback:logback-classic:${project.logbackVersion}"
7-
testCompile "junit:junit:${project.junitVersion}"
8-
testCompile "org.codehaus.groovy:groovy:${project.groovyVersion}"
9-
testCompile('org.spockframework:spock-core:2.0-M2-groovy-3.0') {
6+
testImplementation "org.codehaus.groovy:groovy:${project.groovyVersion}"
7+
testImplementation('org.spockframework:spock-core:2.0-M2-groovy-3.0') {
108
exclude group: 'org.codehaus.groovy'
119
}
1210
}

Diff for: ‎consumer/pact-jvm-consumer-java8/src/main/kotlin/io/pactfoundation/consumer/dsl/Extensions.kt

+8-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ fun LambdaDslObject.newObject(name: String, nestedObject: LambdaDslObject.() ->
2323
return `object`(name) { it.nestedObject() }
2424
}
2525

26+
/**
27+
* Extension function to make [LambdaDslObject.array] Kotlin friendly.
28+
*/
29+
fun LambdaDslObject.newArray(name: String, body: LambdaDslJsonArray.() -> (Unit)): LambdaDslObject {
30+
return array(name) { it.body() }
31+
}
32+
2633
/**
2734
* Extension function to make [LambdaDslJsonArray.array] Kotlin friendly.
2835
*/
@@ -35,4 +42,4 @@ fun LambdaDslJsonArray.newArray(body: LambdaDslJsonArray.() -> (Unit)): LambdaDs
3542
*/
3643
fun LambdaDslJsonArray.newObject(body: LambdaDslObject.() -> (Unit)): LambdaDslJsonArray {
3744
return `object` { it.body() }
38-
}
45+
}
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,41 @@
11
package io.pactfoundation.consumer.dsl
22

3+
import org.hamcrest.CoreMatchers.equalTo
4+
import org.junit.Assert.assertThat
35
import org.junit.jupiter.api.Test
46

57
class ExtensionsTest {
6-
@Test
7-
fun `can use LambdaDslJsonArray#newObject`() {
8-
newJsonArray { newObject { stringType("foo") } }
9-
}
8+
@Test
9+
fun `can use Kotlin DSL to create a Json Array`() {
10+
val expectedJson = """[
11+
|{"key":"value"},
12+
|{"key_1":"value_1"}
13+
|]""".trimMargin().replace("\n", "")
1014

11-
@Test
12-
fun `can use LambdaDslObject#newObject`() {
13-
newJsonObject {
14-
newObject("object") {
15-
stringType("field")
16-
}
15+
val actualJson = newJsonArray {
16+
newObject { stringValue("key", "value") }
17+
newObject { stringValue("key_1", "value_1") }
18+
}.body.toString()
19+
20+
assertThat(actualJson, equalTo(expectedJson))
21+
}
22+
23+
@Test
24+
fun `can use Kotlin DSL to create a Json`() {
25+
val expectedJson = """{
26+
|"array":[{"key":"value"}],
27+
|"object":{"property":"value"}
28+
|}""".trimMargin().replace("\n", "")
29+
30+
val actualJson = newJsonObject {
31+
newArray("array") {
32+
newObject { stringValue("key", "value") }
33+
}
34+
newObject("object") {
35+
stringValue("property", "value")
36+
}
37+
}.body.toString()
38+
39+
assertThat(actualJson, equalTo(expectedJson))
1740
}
18-
}
1941
}

Diff for: ‎consumer/pact-jvm-consumer-junit5/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ dependencies {
1111
testCompile "org.codehaus.groovy:groovy-xml:${project.groovyVersion}"
1212
testCompile 'org.apache.commons:commons-io:1.3.2'
1313
testRuntime "org.junit.vintage:junit-vintage-engine:${project.junit5Version}"
14+
testRuntime "org.junit.jupiter:junit-jupiter-engine:${project.junit5Version}"
1415
testCompile project(path: ":consumer:pact-jvm-consumer-java8", configuration: 'default')
1516
testCompile 'org.hamcrest:hamcrest:2.1'
1617
testCompile('org.spockframework:spock-core:2.0-M2-groovy-3.0') {

0 commit comments

Comments
 (0)
Please sign in to comment.