-
-
Notifications
You must be signed in to change notification settings - Fork 481
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
19 changed files
with
350 additions
and
156 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
dependencies { | ||
api project(path: ":consumer:pact-jvm-consumer", configuration: 'default') | ||
|
||
testCompile "org.junit.jupiter:junit-jupiter-api:${project.junit5Version}" | ||
testRuntime "org.junit.vintage:junit-vintage-engine:${project.junit5Version}" | ||
testImplementation "org.junit.jupiter:junit-jupiter:${project.junit5Version}" | ||
testRuntime "ch.qos.logback:logback-classic:${project.logbackVersion}" | ||
testCompile "junit:junit:${project.junitVersion}" | ||
testCompile "org.codehaus.groovy:groovy:${project.groovyVersion}" | ||
testCompile('org.spockframework:spock-core:2.0-M2-groovy-3.0') { | ||
testImplementation "org.codehaus.groovy:groovy:${project.groovyVersion}" | ||
testImplementation('org.spockframework:spock-core:2.0-M2-groovy-3.0') { | ||
exclude group: 'org.codehaus.groovy' | ||
} | ||
} |
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
44 changes: 33 additions & 11 deletions
44
.../pact-jvm-consumer-java8/src/test/kotlin/io/pactfoundation/consumer/dsl/ExtensionsTest.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 |
---|---|---|
@@ -1,19 +1,41 @@ | ||
package io.pactfoundation.consumer.dsl | ||
|
||
import org.hamcrest.CoreMatchers.equalTo | ||
import org.junit.Assert.assertThat | ||
import org.junit.jupiter.api.Test | ||
|
||
class ExtensionsTest { | ||
@Test | ||
fun `can use LambdaDslJsonArray#newObject`() { | ||
newJsonArray { newObject { stringType("foo") } } | ||
} | ||
@Test | ||
fun `can use Kotlin DSL to create a Json Array`() { | ||
val expectedJson = """[ | ||
|{"key":"value"}, | ||
|{"key_1":"value_1"} | ||
|]""".trimMargin().replace("\n", "") | ||
|
||
@Test | ||
fun `can use LambdaDslObject#newObject`() { | ||
newJsonObject { | ||
newObject("object") { | ||
stringType("field") | ||
} | ||
val actualJson = newJsonArray { | ||
newObject { stringValue("key", "value") } | ||
newObject { stringValue("key_1", "value_1") } | ||
}.body.toString() | ||
|
||
assertThat(actualJson, equalTo(expectedJson)) | ||
} | ||
|
||
@Test | ||
fun `can use Kotlin DSL to create a Json`() { | ||
val expectedJson = """{ | ||
|"array":[{"key":"value"}], | ||
|"object":{"property":"value"} | ||
|}""".trimMargin().replace("\n", "") | ||
|
||
val actualJson = newJsonObject { | ||
newArray("array") { | ||
newObject { stringValue("key", "value") } | ||
} | ||
newObject("object") { | ||
stringValue("property", "value") | ||
} | ||
}.body.toString() | ||
|
||
assertThat(actualJson, equalTo(expectedJson)) | ||
} | ||
} | ||
} |
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.