Fixed references to WireMock in the project so that it is correctly capitalized.

This commit is contained in:
Olga Maciaszek-Sharma
2015-06-25 16:18:49 +02:00
parent ff77ba19f5
commit 0eebda7439
22 changed files with 203 additions and 192 deletions

View File

@@ -23,7 +23,7 @@ class AccurestConfigProperties {
File generatedTestSourcesDir
/**
* Dir where the generated Wiremock stubs from Groovy DSL should be placed.
* Dir where the generated WireMock stubs from Groovy DSL should be placed.
* You can then mention them in your packaging task to create jar with stubs
*/
File stubsOutputDir

View File

@@ -13,7 +13,7 @@ import static io.codearte.accurest.util.ContentUtils.extractValue
import static io.codearte.accurest.util.JsonConverter.transformValues
@TypeChecked
abstract class BaseWiremockStubStrategy {
abstract class BaseWireMockStubStrategy {
private static Closure transform = {
it instanceof DslProperty ? transformValues(it.clientValue, transform) : it

View File

@@ -21,11 +21,11 @@ import static io.codearte.accurest.util.RegexpBuilders.buildJSONRegexpMatch
@TypeChecked
@PackageScope
class WiremockRequestStubStrategy extends BaseWiremockStubStrategy {
class WireMockRequestStubStrategy extends BaseWireMockStubStrategy {
private final Request request
WiremockRequestStubStrategy(GroovyDsl groovyDsl) {
WireMockRequestStubStrategy(GroovyDsl groovyDsl) {
this.request = groovyDsl.request
}

View File

@@ -11,12 +11,12 @@ import static io.codearte.accurest.util.ContentUtils.recognizeContentTypeFromHea
@TypeChecked
@PackageScope
class WiremockResponseStubStrategy extends BaseWiremockStubStrategy {
class WireMockResponseStubStrategy extends BaseWireMockStubStrategy {
private final Request request
private final Response response
WiremockResponseStubStrategy(GroovyDsl groovyDsl) {
WireMockResponseStubStrategy(GroovyDsl groovyDsl) {
this.response = groovyDsl.response
this.request = groovyDsl.request
}

View File

@@ -0,0 +1,21 @@
package io.codearte.accurest.dsl
import groovy.json.JsonOutput
import groovy.transform.CompileStatic
@CompileStatic
class WireMockStubStrategy {
private final WireMockRequestStubStrategy wireMockRequestStubStrategy
private final WireMockResponseStubStrategy wireMockResponseStubStrategy
WireMockStubStrategy(GroovyDsl groovyDsl) {
this.wireMockRequestStubStrategy = new WireMockRequestStubStrategy(groovyDsl)
this.wireMockResponseStubStrategy = new WireMockResponseStubStrategy(groovyDsl)
}
String toWireMockClientStub() {
return JsonOutput.prettyPrint(JsonOutput.toJson([request : wireMockRequestStubStrategy.buildClientRequestContent(),
response: wireMockResponseStubStrategy.buildClientResponseContent()]))
}
}

View File

@@ -1,21 +0,0 @@
package io.codearte.accurest.dsl
import groovy.json.JsonOutput
import groovy.transform.CompileStatic
@CompileStatic
class WiremockStubStrategy {
private final WiremockRequestStubStrategy wiremockRequestStubStrategy
private final WiremockResponseStubStrategy wiremockResponseStubStrategy
WiremockStubStrategy(GroovyDsl groovyDsl) {
this.wiremockRequestStubStrategy = new WiremockRequestStubStrategy(groovyDsl)
this.wiremockResponseStubStrategy = new WiremockResponseStubStrategy(groovyDsl)
}
String toWiremockClientStub() {
return JsonOutput.prettyPrint(JsonOutput.toJson([request : wiremockRequestStubStrategy.buildClientRequestContent(),
response: wiremockResponseStubStrategy.buildClientResponseContent()]))
}
}

View File

@@ -3,7 +3,7 @@ package io.codearte.accurest.dsl
import groovy.json.JsonSlurper
import spock.lang.Specification
class WiremockGroovyDslResponseSpec extends Specification {
class WireMockGroovyDslResponseSpec extends Specification {
def 'should generate response without body for client side'() {
given:
@@ -13,7 +13,7 @@ class WiremockGroovyDslResponseSpec extends Specification {
}
}
expect:
new WiremockResponseStubStrategy(dsl).buildClientResponseContent() == new JsonSlurper().parseText(expectedStub)
new WireMockResponseStubStrategy(dsl).buildClientResponseContent() == new JsonSlurper().parseText(expectedStub)
where:
expectedStub << ['''
{
@@ -39,7 +39,7 @@ class WiremockGroovyDslResponseSpec extends Specification {
}
}
expect:
new WiremockResponseStubStrategy(dsl).buildClientResponseContent() == new JsonSlurper().parseText('''
new WireMockResponseStubStrategy(dsl).buildClientResponseContent() == new JsonSlurper().parseText('''
{
"headers": {
"Content-Type": "text/xml"

View File

@@ -4,9 +4,9 @@ import groovy.json.JsonBuilder
import groovy.json.JsonSlurper
import spock.lang.Issue
class WiremockGroovyDslSpec extends WiremockSpec {
class WireMockGroovyDslSpec extends WireMockSpec {
def 'should convert groovy dsl stub to wiremock stub for the client side'() {
def 'should convert groovy dsl stub to wireMock stub for the client side'() {
given:
GroovyDsl groovyDsl = GroovyDsl.make {
request {
@@ -33,9 +33,9 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
}
when:
String wiremockStub = new WiremockStubStrategy(groovyDsl).toWiremockClientStub()
String wireMockStub = new WireMockStubStrategy(groovyDsl).toWireMockClientStub()
then:
new JsonSlurper().parseText(wiremockStub) == new JsonSlurper().parseText('''
new JsonSlurper().parseText(wireMockStub) == new JsonSlurper().parseText('''
{
"request": {
"method": "GET",
@@ -51,11 +51,11 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
''')
and:
stubMappingIsValidWiremockStub(wiremockStub)
stubMappingIsValidWireMockStub(wireMockStub)
}
@Issue("#79")
def 'should convert groovy dsl stub to wiremock stub for the client side with a body containing a map'() {
def 'should convert groovy dsl stub to wireMock stub for the client side with a body containing a map'() {
given:
GroovyDsl groovyDsl = GroovyDsl.make {
request {
@@ -78,9 +78,9 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
}
when:
String wiremockStub = new WiremockStubStrategy(groovyDsl).toWiremockClientStub()
String wireMockStub = new WireMockStubStrategy(groovyDsl).toWireMockClientStub()
then:
new JsonSlurper().parseText(wiremockStub) == new JsonSlurper().parseText('''
new JsonSlurper().parseText(wireMockStub) == new JsonSlurper().parseText('''
{
"request": {
"method": "GET",
@@ -98,7 +98,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
''')
and:
stubMappingIsValidWiremockStub(wiremockStub)
stubMappingIsValidWireMockStub(wireMockStub)
}
@Issue("#86")
@@ -122,9 +122,9 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
}
when:
String wiremockStub = new WiremockStubStrategy(groovyDsl).toWiremockClientStub()
String wireMockStub = new WireMockStubStrategy(groovyDsl).toWireMockClientStub()
then:
new JsonSlurper().parseText(wiremockStub) == new JsonSlurper().parseText('''
new JsonSlurper().parseText(wireMockStub) == new JsonSlurper().parseText('''
{
"request": {
"method": "POST",
@@ -147,10 +147,10 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
''')
and:
stubMappingIsValidWiremockStub(wiremockStub)
stubMappingIsValidWireMockStub(wireMockStub)
}
def 'should convert groovy dsl stub with Body as String to wiremock stub for the client side'() {
def 'should convert groovy dsl stub with Body as String to wireMock stub for the client side'() {
given:
GroovyDsl groovyDsl = GroovyDsl.make {
request {
@@ -174,9 +174,9 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
}
when:
String wiremockStub = new WiremockStubStrategy(groovyDsl).toWiremockClientStub()
String wireMockStub = new WireMockStubStrategy(groovyDsl).toWireMockClientStub()
then:
new JsonSlurper().parseText(wiremockStub) == new JsonSlurper().parseText('''
new JsonSlurper().parseText(wireMockStub) == new JsonSlurper().parseText('''
{
"request": {
"method": "GET",
@@ -192,10 +192,10 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
''')
and:
stubMappingIsValidWiremockStub(wiremockStub)
stubMappingIsValidWireMockStub(wireMockStub)
}
def 'should convert groovy dsl stub with simple Body as String to wiremock stub for the client side'() {
def 'should convert groovy dsl stub with simple Body as String to wireMock stub for the client side'() {
given:
GroovyDsl groovyDsl = GroovyDsl.make {
request {
@@ -221,9 +221,9 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
}
when:
String wiremockStub = new WiremockStubStrategy(groovyDsl).toWiremockClientStub()
String wireMockStub = new WireMockStubStrategy(groovyDsl).toWireMockClientStub()
then:
new JsonSlurper().parseText(wiremockStub) == new JsonSlurper().parseText('''
new JsonSlurper().parseText(wireMockStub) == new JsonSlurper().parseText('''
{
"request": {
"method": "GET",
@@ -244,7 +244,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
''')
and:
stubMappingIsValidWiremockStub(wiremockStub)
stubMappingIsValidWireMockStub(wireMockStub)
}
def 'should use equalToJson when body match is defined as map'() {
@@ -271,9 +271,9 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
}
when:
String wiremockStub = new WiremockStubStrategy(groovyDsl).toWiremockClientStub()
String wireMockStub = new WireMockStubStrategy(groovyDsl).toWireMockClientStub()
then:
new JsonSlurper().parseText(wiremockStub) == new JsonSlurper().parseText('''
new JsonSlurper().parseText(wireMockStub) == new JsonSlurper().parseText('''
{
"request": {
"method": "GET",
@@ -290,7 +290,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
''')
and:
stubMappingIsValidWiremockStub(wiremockStub)
stubMappingIsValidWireMockStub(wireMockStub)
}
def 'should use equalToJson when content type ends with json'() {
@@ -313,7 +313,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
}
when:
String json = toWiremockClientJsonStub(groovyDsl)
String json = toWireMockClientJsonStub(groovyDsl)
then:
parseJson(json) == parseJson('''
{
@@ -337,7 +337,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
''')
and:
stubMappingIsValidWiremockStub(json)
stubMappingIsValidWireMockStub(json)
}
def 'should use equalToXml when content type ends with xml'() {
@@ -356,7 +356,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
}
when:
String json = toWiremockClientJsonStub(groovyDsl)
String json = toWireMockClientJsonStub(groovyDsl)
then:
parseJson(json) == parseJson('''
{
@@ -380,7 +380,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
''')
and:
stubMappingIsValidWiremockStub(json)
stubMappingIsValidWireMockStub(json)
}
def 'should use equalToXml when content type is parsable xml'() {
@@ -396,7 +396,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
}
when:
String json = toWiremockClientJsonStub(groovyDsl)
String json = toWireMockClientJsonStub(groovyDsl)
then:
parseJson(json) == parseJson('''
{
@@ -415,7 +415,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
''')
and:
stubMappingIsValidWiremockStub(json)
stubMappingIsValidWireMockStub(json)
}
def 'should support xml as a response body'() {
@@ -431,7 +431,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
}
when:
String json = toWiremockClientJsonStub(groovyDsl)
String json = toWireMockClientJsonStub(groovyDsl)
then:
parseJson(json) == parseJson('''
{
@@ -446,7 +446,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
''')
and:
stubMappingIsValidWiremockStub(json)
stubMappingIsValidWireMockStub(json)
}
def 'should use equalToJson'() {
@@ -462,7 +462,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
}
when:
String json = toWiremockClientJsonStub(groovyDsl)
String json = toWireMockClientJsonStub(groovyDsl)
then:
parseJson(json) == parseJson('''
{
@@ -481,7 +481,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
''')
and:
stubMappingIsValidWiremockStub(json)
stubMappingIsValidWireMockStub(json)
}
def 'should use equalToXml'() {
@@ -497,7 +497,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
}
when:
String json = toWiremockClientJsonStub(groovyDsl)
String json = toWireMockClientJsonStub(groovyDsl)
then:
parseJson(json) == parseJson('''
{
@@ -516,10 +516,10 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
''')
and:
stubMappingIsValidWiremockStub(json)
stubMappingIsValidWireMockStub(json)
}
def 'should convert groovy dsl stub with regexp Body as String to wiremock stub for the client side'() {
def 'should convert groovy dsl stub with regexp Body as String to wireMock stub for the client side'() {
given:
GroovyDsl groovyDsl = GroovyDsl.make {
request {
@@ -545,9 +545,9 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
}
when:
String wiremockStub = new WiremockStubStrategy(groovyDsl).toWiremockClientStub()
String wireMockStub = new WireMockStubStrategy(groovyDsl).toWireMockClientStub()
then:
new JsonSlurper().parseText(wiremockStub) == new JsonSlurper().parseText('''
new JsonSlurper().parseText(wireMockStub) == new JsonSlurper().parseText('''
{
"request": {
"method": "GET",
@@ -566,7 +566,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
''')
and:
stubMappingIsValidWiremockStub(wiremockStub)
stubMappingIsValidWireMockStub(wireMockStub)
}
def 'should convert groovy dsl stub with a regexp and an integer in request body'() {
@@ -600,9 +600,9 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
when:
String wiremockStub = new WiremockStubStrategy(groovyDsl).toWiremockClientStub()
String wireMockStub = new WireMockStubStrategy(groovyDsl).toWireMockClientStub()
then:
new JsonSlurper().parseText(wiremockStub) == new JsonSlurper().parseText('''
new JsonSlurper().parseText(wireMockStub) == new JsonSlurper().parseText('''
{
"request": {
"method": "PUT",
@@ -626,7 +626,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
''')
and:
stubMappingIsValidWiremockStub(wiremockStub)
stubMappingIsValidWireMockStub(wireMockStub)
}
@@ -638,7 +638,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
}
expect:
new WiremockRequestStubStrategy(groovyDsl).buildClientRequestContent() == new JsonSlurper().parseText('''
new WireMockRequestStubStrategy(groovyDsl).buildClientRequestContent() == new JsonSlurper().parseText('''
{
"method":"GET"
}
@@ -654,7 +654,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
}
expect:
new WiremockRequestStubStrategy(groovyDsl).buildClientRequestContent() == new JsonSlurper().parseText('''
new WireMockRequestStubStrategy(groovyDsl).buildClientRequestContent() == new JsonSlurper().parseText('''
{
"method":"GET",
"url":"/sth"
@@ -673,7 +673,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
}
expect:
new WiremockRequestStubStrategy(groovyDsl).buildClientRequestContent() == new JsonSlurper().parseText('''
new WireMockRequestStubStrategy(groovyDsl).buildClientRequestContent() == new JsonSlurper().parseText('''
{
"urlPattern":"^/[0-9]{2}$"
}
@@ -703,7 +703,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
}
when:
def json = toWiremockClientJsonStub(groovyDsl)
def json = toWireMockClientJsonStub(groovyDsl)
then:
parseJson(json) == parseJson('''
{
@@ -743,7 +743,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
''')
and:
stubMappingIsValidWiremockStub(json)
stubMappingIsValidWireMockStub(json)
}
def "should generate request with urlPath for client side"() {
@@ -758,7 +758,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
}
when:
def json = toWiremockClientJsonStub(groovyDsl)
def json = toWireMockClientJsonStub(groovyDsl)
then:
parseJson(json) == parseJson('''
{
@@ -772,7 +772,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
''')
and:
stubMappingIsValidWiremockStub(json)
stubMappingIsValidWireMockStub(json)
}
def "should generate simple request with urlPath for client side"() {
@@ -787,7 +787,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
}
when:
def json = toWiremockClientJsonStub(groovyDsl)
def json = toWireMockClientJsonStub(groovyDsl)
then:
parseJson(json) == parseJson('''
{
@@ -801,7 +801,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
''')
and:
stubMappingIsValidWiremockStub(json)
stubMappingIsValidWireMockStub(json)
}
def "should not allow regexp in url for server value"() {
@@ -933,7 +933,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
}
when:
def json = toWiremockClientJsonStub(groovyDsl)
def json = toWireMockClientJsonStub(groovyDsl)
then:
parseJson(json) == parseJson('''
{
@@ -955,7 +955,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
''')
and:
stubMappingIsValidWiremockStub(json)
stubMappingIsValidWireMockStub(json)
}
def "should generate stub with some headers section for client side"() {
@@ -976,7 +976,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
}
expect:
new WiremockRequestStubStrategy(groovyDsl).buildClientRequestContent() == new JsonSlurper().parseText('''
new WireMockRequestStubStrategy(groovyDsl).buildClientRequestContent() == new JsonSlurper().parseText('''
{
"headers": {
"Content-Type": {
@@ -993,7 +993,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
''')
}
def 'should convert groovy dsl stub with rich tree Body as String to wiremock stub for the client side'() {
def 'should convert groovy dsl stub with rich tree Body as String to wireMock stub for the client side'() {
given:
GroovyDsl groovyDsl = GroovyDsl.make {
request {
@@ -1032,9 +1032,9 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
}
when:
String wiremockStub = new WiremockStubStrategy(groovyDsl).toWiremockClientStub()
String wireMockStub = new WireMockStubStrategy(groovyDsl).toWireMockClientStub()
then:
new JsonSlurper().parseText(wiremockStub) == new JsonSlurper().parseText('''
new JsonSlurper().parseText(wireMockStub) == new JsonSlurper().parseText('''
{
"request": {
"method": "GET",
@@ -1083,7 +1083,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
}
}
when:
def json = toWiremockClientJsonStub(groovyDsl)
def json = toWireMockClientJsonStub(groovyDsl)
then:
parseJson(json) == parseJson('''
{
@@ -1115,7 +1115,7 @@ class WiremockGroovyDslSpec extends WiremockSpec {
new JsonSlurper().parseText(json)
}
String toWiremockClientJsonStub(groovyDsl) {
new WiremockStubStrategy(groovyDsl).toWiremockClientStub()
String toWireMockClientJsonStub(groovyDsl) {
new WireMockStubStrategy(groovyDsl).toWireMockClientStub()
}
}

View File

@@ -5,9 +5,9 @@ import spock.lang.Specification
import java.util.regex.Pattern
abstract class WiremockSpec extends Specification {
abstract class WireMockSpec extends Specification {
void stubMappingIsValidWiremockStub(String mappingDefinition) {
void stubMappingIsValidWireMockStub(String mappingDefinition) {
StubMapping stubMapping = StubMapping.buildFrom(mappingDefinition)
stubMapping.request.bodyPatterns.findAll { it.matches }.every {
Pattern.compile(it.matches)