diff --git a/accurest-converters/src/test/groovy/io/codearte/accurest/wiremock/DslToWireMockClientConverterSpec.groovy b/accurest-converters/src/test/groovy/io/codearte/accurest/wiremock/DslToWireMockClientConverterSpec.groovy index 22fc850efe..61c6b7c29b 100755 --- a/accurest-converters/src/test/groovy/io/codearte/accurest/wiremock/DslToWireMockClientConverterSpec.groovy +++ b/accurest-converters/src/test/groovy/io/codearte/accurest/wiremock/DslToWireMockClientConverterSpec.groovy @@ -10,15 +10,15 @@ class DslToWireMockClientConverterSpec extends Specification { def converter = new DslToWireMockClientConverter() and: String dslBody = """ - io.codearte.accurest.dsl.GroovyDsl.make { - request { - method('PUT') - url \$(client(~/\\/[0-9]{2}/), server('/12')) - } - response { - status 200 - } - } + io.codearte.accurest.dsl.GroovyDsl.make { + request { + method('PUT') + url \$(client(~/\\/[0-9]{2}/), server('/12')) + } + response { + status 200 + } + } """ when: String json = converter.convertContent(dslBody) @@ -34,7 +34,7 @@ class DslToWireMockClientConverterSpec extends Specification { def converter = new DslToWireMockClientConverter() and: String dslBody = """ - io.codearte.accurest.dsl.GroovyDsl.make { + io.codearte.accurest.dsl.GroovyDsl.make { request { method 'PUT' url '/api/12' @@ -84,57 +84,57 @@ class DslToWireMockClientConverterSpec extends Specification { JSONAssert.assertEquals(''' { "request" : { - "url" : "/api/12", - "method" : "PUT", - "bodyPatterns" : [ { - "matchesJsonPath" : "$[*].place.bounding_box.coordinates[*][*][?(@ == 38.995548)]" - }, { - "matchesJsonPath" : "$[*].place[?(@.country == 'United States')]" - }, { - "matchesJsonPath" : "$[*].place.bounding_box.coordinates[*][*][?(@ == -77.119759)]" - }, { - "matchesJsonPath" : "$[*].place[?(@.name == 'Washington')]" - }, { - "matchesJsonPath" : "$[*].place.bounding_box[?(@.type == 'Polygon')]" - }, { - "matchesJsonPath" : "$[*][?(@.id_str == '492967299297845248')]" - }, { - "matchesJsonPath" : "$[*].place[?(@.country_code == 'US')]" - }, { - "matchesJsonPath" : "$[*][?(@.id == 492967299297845248)]" - }, { - "matchesJsonPath" : "$[*].place.bounding_box.coordinates[*][*][?(@ == -76.909393)]" - }, { - "matchesJsonPath" : "$[*].place.bounding_box.coordinates[*][*][?(@ == 38.791645)]" - }, { - "matchesJsonPath" : "$[*].place[?(@.id == '01fbe706f872cb32')]" - }, { - "matchesJsonPath" : "$[*].place[?(@.url == 'http://api.twitter.com/1/geo/id/01fbe706f872cb32.json')]" - }, { - "matchesJsonPath" : "$[*].place.bounding_box.coordinates[*][*][?(@ == -77.119759)]" - }, { - "matchesJsonPath" : "$[*].place.bounding_box.coordinates[*][*][?(@ == -76.909393)]" - }, { - "matchesJsonPath" : "$[*].place.bounding_box.coordinates[*][*][?(@ == 38.995548)]" - }, { - "matchesJsonPath" : "$[*][?(@.text == 'Gonna see you at Warsaw')]" - }, { - "matchesJsonPath" : "$[*].place[?(@.place_type == 'city')]" - }, { - "matchesJsonPath" : "$[*][?(@.created_at == 'Sat Jul 26 09:38:57 +0000 2014')]" - }, { - "matchesJsonPath" : "$[*].place[?(@.full_name == 'Washington, DC')]" - }, { - "matchesJsonPath" : "$[*].place.bounding_box.coordinates[*][*][?(@ == 38.791645)]" - } ], - "headers" : { - "Content-Type" : { - "equalTo" : "application/vnd.com.ofg.twitter-places-analyzer.v1+json" - } - } + "url" : "/api/12", + "method" : "PUT", + "bodyPatterns" : [ { + "matchesJsonPath" : "$[*].place.bounding_box.coordinates[*][*][?(@ == 38.995548)]" + }, { + "matchesJsonPath" : "$[*].place[?(@.country == 'United States')]" + }, { + "matchesJsonPath" : "$[*].place.bounding_box.coordinates[*][*][?(@ == -77.119759)]" + }, { + "matchesJsonPath" : "$[*].place[?(@.name == 'Washington')]" + }, { + "matchesJsonPath" : "$[*].place.bounding_box[?(@.type == 'Polygon')]" + }, { + "matchesJsonPath" : "$[*][?(@.id_str == '492967299297845248')]" + }, { + "matchesJsonPath" : "$[*].place[?(@.country_code == 'US')]" + }, { + "matchesJsonPath" : "$[*][?(@.id == 492967299297845248)]" + }, { + "matchesJsonPath" : "$[*].place.bounding_box.coordinates[*][*][?(@ == -76.909393)]" + }, { + "matchesJsonPath" : "$[*].place.bounding_box.coordinates[*][*][?(@ == 38.791645)]" + }, { + "matchesJsonPath" : "$[*].place[?(@.id == '01fbe706f872cb32')]" + }, { + "matchesJsonPath" : "$[*].place[?(@.url == 'http://api.twitter.com/1/geo/id/01fbe706f872cb32.json')]" + }, { + "matchesJsonPath" : "$[*].place.bounding_box.coordinates[*][*][?(@ == -77.119759)]" + }, { + "matchesJsonPath" : "$[*].place.bounding_box.coordinates[*][*][?(@ == -76.909393)]" + }, { + "matchesJsonPath" : "$[*].place.bounding_box.coordinates[*][*][?(@ == 38.995548)]" + }, { + "matchesJsonPath" : "$[*][?(@.text == 'Gonna see you at Warsaw')]" + }, { + "matchesJsonPath" : "$[*].place[?(@.place_type == 'city')]" + }, { + "matchesJsonPath" : "$[*][?(@.created_at == 'Sat Jul 26 09:38:57 +0000 2014')]" + }, { + "matchesJsonPath" : "$[*].place[?(@.full_name == 'Washington, DC')]" + }, { + "matchesJsonPath" : "$[*].place.bounding_box.coordinates[*][*][?(@ == 38.791645)]" + } ], + "headers" : { + "Content-Type" : { + "equalTo" : "application/vnd.com.ofg.twitter-places-analyzer.v1+json" + } + } }, "response" : { - "status" : 200 + "status" : 200 } } ''', json, false) diff --git a/accurest-core/src/main/groovy/io/codearte/accurest/TestGenerator.groovy b/accurest-core/src/main/groovy/io/codearte/accurest/TestGenerator.groovy index fb612cebd1..63e2047217 100755 --- a/accurest-core/src/main/groovy/io/codearte/accurest/TestGenerator.groovy +++ b/accurest-core/src/main/groovy/io/codearte/accurest/TestGenerator.groovy @@ -68,8 +68,8 @@ class TestGenerator { } } } - - private String normalizePath(String path) { - return FilenameUtils.separatorsToUnix(path) - } + + private String normalizePath(String path) { + return FilenameUtils.separatorsToUnix(path) + } } \ No newline at end of file diff --git a/accurest-core/src/main/groovy/io/codearte/accurest/builder/JaxRsClientSpockMethodBodyBuilder.groovy b/accurest-core/src/main/groovy/io/codearte/accurest/builder/JaxRsClientSpockMethodBodyBuilder.groovy index d3e07d7942..91ba58e4f0 100644 --- a/accurest-core/src/main/groovy/io/codearte/accurest/builder/JaxRsClientSpockMethodBodyBuilder.groovy +++ b/accurest-core/src/main/groovy/io/codearte/accurest/builder/JaxRsClientSpockMethodBodyBuilder.groovy @@ -10,86 +10,86 @@ import io.codearte.accurest.dsl.internal.QueryParameter @TypeChecked class JaxRsClientSpockMethodBodyBuilder extends SpockMethodBodyBuilder { - JaxRsClientSpockMethodBodyBuilder(GroovyDsl stubDefinition) { - super(stubDefinition) - } + JaxRsClientSpockMethodBodyBuilder(GroovyDsl stubDefinition) { + super(stubDefinition) + } - @Override - protected void givenBlock(BlockBuilder bb) { - } + @Override + protected void givenBlock(BlockBuilder bb) { + } - @Override - protected void when(BlockBuilder bb) { - bb.addLine("def response = webTarget") - bb.indent() + @Override + protected void when(BlockBuilder bb) { + bb.addLine("def response = webTarget") + bb.indent() - appendUrlPathAndQueryParameters(bb) - appendRequestWithRequiredResponseContentType(bb) - appendHeaders(bb) - appendMethodAndBody(bb) + appendUrlPathAndQueryParameters(bb) + appendRequestWithRequiredResponseContentType(bb) + appendHeaders(bb) + appendMethodAndBody(bb) - bb.unindent() + bb.unindent() - bb.addEmptyLine() - bb.addLine("String responseAsString = response.readEntity(String)") - } + bb.addEmptyLine() + bb.addLine("String responseAsString = response.readEntity(String)") + } - protected void appendRequestWithRequiredResponseContentType(BlockBuilder bb) { - String acceptHeader = getHeader("Accept") - if (acceptHeader) { - bb.addLine(".request('$acceptHeader')") - } else { - bb.addLine(".request()") - } - } + protected void appendRequestWithRequiredResponseContentType(BlockBuilder bb) { + String acceptHeader = getHeader("Accept") + if (acceptHeader) { + bb.addLine(".request('$acceptHeader')") + } else { + bb.addLine(".request()") + } + } - protected void appendUrlPathAndQueryParameters(BlockBuilder bb) { - if (request.url) { - bb.addLine(".path('$request.url.serverValue')") - } else if (request.urlPath) { - bb.addLine(".path('$request.urlPath.serverValue')") - request.urlPath.queryParameters?.parameters.findAll(this.&allowedQueryParameter).each { QueryParameter param -> - bb.addLine(".queryParam('$param.name', '${resolveParamValue(param).toString()}')") - } - } - } + protected void appendUrlPathAndQueryParameters(BlockBuilder bb) { + if (request.url) { + bb.addLine(".path('$request.url.serverValue')") + } else if (request.urlPath) { + bb.addLine(".path('$request.urlPath.serverValue')") + request.urlPath.queryParameters?.parameters.findAll(this.&allowedQueryParameter).each { QueryParameter param -> + bb.addLine(".queryParam('$param.name', '${resolveParamValue(param).toString()}')") + } + } + } - protected void appendMethodAndBody(BlockBuilder bb) { - String method = request.method.serverValue.toString().toLowerCase() - if (request.body) { - String contentType = getHeader('Content-Type') ?: getRequestContentType().mimeType - bb.addLine(".method('$method', entity('$bodyAsString', '$contentType'))") - } else { - bb.addLine(".method('$method')") - } - } + protected void appendMethodAndBody(BlockBuilder bb) { + String method = request.method.serverValue.toString().toLowerCase() + if (request.body) { + String contentType = getHeader('Content-Type') ?: getRequestContentType().mimeType + bb.addLine(".method('$method', entity('$bodyAsString', '$contentType'))") + } else { + bb.addLine(".method('$method')") + } + } - protected appendHeaders(BlockBuilder bb) { - request.headers?.collect { Header header -> - if (header.name == 'Content-Type' || header.name == 'Accept') return // Particular headers are set via 'request' / 'entity' methods - bb.addLine(".header('${header.name}', '${header.serverValue}')") - } - } + protected appendHeaders(BlockBuilder bb) { + request.headers?.collect { Header header -> + if (header.name == 'Content-Type' || header.name == 'Accept') return // Particular headers are set via 'request' / 'entity' methods + bb.addLine(".header('${header.name}', '${header.serverValue}')") + } + } - protected String getHeader(String name) { - return request.headers?.entries.find { it.name == name }?.serverValue - } + protected String getHeader(String name) { + return request.headers?.entries.find { it.name == name }?.serverValue + } - @Override - protected void validateResponseCodeBlock(BlockBuilder bb) { - bb.addLine("response.status == $response.status.serverValue") - } + @Override + protected void validateResponseCodeBlock(BlockBuilder bb) { + bb.addLine("response.status == $response.status.serverValue") + } - @Override - protected void validateResponseHeadersBlock(BlockBuilder bb) { - response.headers?.collect { Header header -> - bb.addLine("response.getHeaderString('$header.name') == '$header.serverValue'") - } - } + @Override + protected void validateResponseHeadersBlock(BlockBuilder bb) { + response.headers?.collect { Header header -> + bb.addLine("response.getHeaderString('$header.name') == '$header.serverValue'") + } + } - @Override - protected String getResponseAsString() { - return 'responseAsString' - } + @Override + protected String getResponseAsString() { + return 'responseAsString' + } } diff --git a/accurest-core/src/main/groovy/io/codearte/accurest/builder/MockMvcSpockMethodBodyBuilder.groovy b/accurest-core/src/main/groovy/io/codearte/accurest/builder/MockMvcSpockMethodBodyBuilder.groovy index 1b2e9a9d24..fed69dc27b 100644 --- a/accurest-core/src/main/groovy/io/codearte/accurest/builder/MockMvcSpockMethodBodyBuilder.groovy +++ b/accurest-core/src/main/groovy/io/codearte/accurest/builder/MockMvcSpockMethodBodyBuilder.groovy @@ -14,73 +14,73 @@ import java.util.regex.Pattern @TypeChecked class MockMvcSpockMethodBodyBuilder extends SpockMethodBodyBuilder { - MockMvcSpockMethodBodyBuilder(GroovyDsl stubDefinition) { - super(stubDefinition) - } + MockMvcSpockMethodBodyBuilder(GroovyDsl stubDefinition) { + super(stubDefinition) + } - protected void given(BlockBuilder bb) { - bb.addLine('def request = given()') - bb.indent() - request.headers?.collect { Header header -> - bb.addLine(".header('${getTestSideValue(header.name)}', '${getTestSideValue(header.serverValue)}')") - } - if (request.body) { - bb.addLine(".body('$bodyAsString')") - } - bb.unindent() - } + protected void given(BlockBuilder bb) { + bb.addLine('def request = given()') + bb.indent() + request.headers?.collect { Header header -> + bb.addLine(".header('${getTestSideValue(header.name)}', '${getTestSideValue(header.serverValue)}')") + } + if (request.body) { + bb.addLine(".body('$bodyAsString')") + } + bb.unindent() + } - protected void when(BlockBuilder bb) { - bb.addLine('def response = given().spec(request)') - bb.indent() + protected void when(BlockBuilder bb) { + bb.addLine('def response = given().spec(request)') + bb.indent() - String url = buildUrl(request) - String method = request.method.serverValue.toString().toLowerCase() + String url = buildUrl(request) + String method = request.method.serverValue.toString().toLowerCase() - bb.addLine(/.${method}("$url")/) - bb.unindent() - } + bb.addLine(/.${method}("$url")/) + bb.unindent() + } - protected void validateResponseCodeBlock(BlockBuilder bb) { - bb.addLine("response.statusCode == $response.status.serverValue") - } + protected void validateResponseCodeBlock(BlockBuilder bb) { + bb.addLine("response.statusCode == $response.status.serverValue") + } - protected void validateResponseHeadersBlock(BlockBuilder bb) { - response.headers?.collect { Header header -> - bb.addLine("response.header('$header.name') ${convertHeaderComparison(header.serverValue)}") - } - } + protected void validateResponseHeadersBlock(BlockBuilder bb) { + response.headers?.collect { Header header -> + bb.addLine("response.header('$header.name') ${convertHeaderComparison(header.serverValue)}") + } + } - private String convertHeaderComparison(Object headerValue) { - return " == '$headerValue'" - } + private String convertHeaderComparison(Object headerValue) { + return " == '$headerValue'" + } - private String convertHeaderComparison(Pattern headerValue) { - return "==~ java.util.regex.Pattern.compile('$headerValue')" - } + private String convertHeaderComparison(Pattern headerValue) { + return "==~ java.util.regex.Pattern.compile('$headerValue')" + } - @Override - protected String getResponseAsString() { - return 'response.body.asString()' - } + @Override + protected String getResponseAsString() { + return 'response.body.asString()' + } - protected String buildUrl(Request request) { - if (request.url) - return getTestSideValue(request.url.serverValue) - if (request.urlPath) - return getTestSideValue(buildUrlFromUrlPath(request.urlPath)) - throw new IllegalStateException("URL is not set!") - } + protected String buildUrl(Request request) { + if (request.url) + return getTestSideValue(request.url.serverValue) + if (request.urlPath) + return getTestSideValue(buildUrlFromUrlPath(request.urlPath)) + throw new IllegalStateException("URL is not set!") + } - @TypeChecked(TypeCheckingMode.SKIP) - protected String buildUrlFromUrlPath(UrlPath urlPath) { - String params = urlPath.queryParameters.parameters - .findAll(this.&allowedQueryParameter) - .inject([] as List) { List result, QueryParameter param -> - result << "${param.name}=${resolveParamValue(param).toString()}" - } - .join('&') - return "$urlPath.serverValue?$params" - } + @TypeChecked(TypeCheckingMode.SKIP) + protected String buildUrlFromUrlPath(UrlPath urlPath) { + String params = urlPath.queryParameters.parameters + .findAll(this.&allowedQueryParameter) + .inject([] as List) { List result, QueryParameter param -> + result << "${param.name}=${resolveParamValue(param).toString()}" + } + .join('&') + return "$urlPath.serverValue?$params" + } } diff --git a/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/ExecutionProperty.groovy b/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/ExecutionProperty.groovy index ccc7037575..866afdc18c 100644 --- a/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/ExecutionProperty.groovy +++ b/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/ExecutionProperty.groovy @@ -5,15 +5,15 @@ import groovy.transform.CompileStatic @CompileStatic class ExecutionProperty { - private static final String PLACEHOLDER_VALUE = '\\$it' + private static final String PLACEHOLDER_VALUE = '\\$it' - final String executionCommand + final String executionCommand - ExecutionProperty(String executionCommand) { - this.executionCommand = executionCommand - } + ExecutionProperty(String executionCommand) { + this.executionCommand = executionCommand + } - String insertValue(String valueToInsert) { - return executionCommand.replaceAll(PLACEHOLDER_VALUE, valueToInsert) - } + String insertValue(String valueToInsert) { + return executionCommand.replaceAll(PLACEHOLDER_VALUE, valueToInsert) + } } diff --git a/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/Header.groovy b/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/Header.groovy index a7eefa180a..b72037cd03 100644 --- a/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/Header.groovy +++ b/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/Header.groovy @@ -8,16 +8,16 @@ import groovy.transform.ToString @CompileStatic class Header extends DslProperty { - String name + String name - Header(String name, DslProperty dslProperty) { - super(dslProperty.clientValue, dslProperty.serverValue) - this.name = name - } + Header(String name, DslProperty dslProperty) { + super(dslProperty.clientValue, dslProperty.serverValue) + this.name = name + } - Header(String name, Object value) { - super(value) - this.name = name - } + Header(String name, Object value) { + super(value) + this.name = name + } } diff --git a/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/QueryParameter.groovy b/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/QueryParameter.groovy index 042da081f2..153fa6f297 100644 --- a/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/QueryParameter.groovy +++ b/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/QueryParameter.groovy @@ -11,24 +11,24 @@ import static io.codearte.accurest.util.ValidateUtils.validateServerValueIsAvail @CompileStatic class QueryParameter extends DslProperty { - String name + String name - QueryParameter(String name, DslProperty dslProperty) { - super(dslProperty.clientValue, dslProperty.serverValue) - validateServerValueIsAvailable(dslProperty.serverValue, "Query parameter '$name'") - this.name = name - } + QueryParameter(String name, DslProperty dslProperty) { + super(dslProperty.clientValue, dslProperty.serverValue) + validateServerValueIsAvailable(dslProperty.serverValue, "Query parameter '$name'") + this.name = name + } - QueryParameter(String name, MatchingStrategy matchingStrategy) { - super(matchingStrategy) - validateServerValueIsAvailable(matchingStrategy, "Query parameter '$name'") - this.name = name - } + QueryParameter(String name, MatchingStrategy matchingStrategy) { + super(matchingStrategy) + validateServerValueIsAvailable(matchingStrategy, "Query parameter '$name'") + this.name = name + } - QueryParameter(String name, Object value) { - super(value) - validateServerValueIsAvailable(value, "Query parameter '$name'") - this.name = name - } + QueryParameter(String name, Object value) { + super(value) + validateServerValueIsAvailable(value, "Query parameter '$name'") + this.name = name + } } diff --git a/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/QueryParameters.groovy b/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/QueryParameters.groovy index 0a5d6233f2..b4cc1d74c4 100644 --- a/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/QueryParameters.groovy +++ b/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/QueryParameters.groovy @@ -9,15 +9,15 @@ import groovy.transform.TypeChecked @TypeChecked class QueryParameters { - List parameters = [] + List parameters = [] - void parameter(Map singleParameter) { - Map.Entry first = singleParameter.entrySet().first() - parameters << new QueryParameter(first?.key, first?.value) - } + void parameter(Map singleParameter) { + Map.Entry first = singleParameter.entrySet().first() + parameters << new QueryParameter(first?.key, first?.value) + } - void parameter(String parameterName, Object parameterValue) { - parameters << new QueryParameter(parameterName, parameterValue) - } + void parameter(String parameterName, Object parameterValue) { + parameters << new QueryParameter(parameterName, parameterValue) + } } diff --git a/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/UrlPath.groovy b/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/UrlPath.groovy index ee1d3eed98..68d9bc0f7d 100644 --- a/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/UrlPath.groovy +++ b/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/UrlPath.groovy @@ -9,12 +9,12 @@ import groovy.transform.ToString; @CompileStatic class UrlPath extends Url { - UrlPath(String path) { - super(path) - } + UrlPath(String path) { + super(path) + } - UrlPath(DslProperty path) { - super(path) - } + UrlPath(DslProperty path) { + super(path) + } } diff --git a/accurest-core/src/main/groovy/io/codearte/accurest/util/ContentType.groovy b/accurest-core/src/main/groovy/io/codearte/accurest/util/ContentType.groovy index 7b9e402985..a9243058af 100644 --- a/accurest-core/src/main/groovy/io/codearte/accurest/util/ContentType.groovy +++ b/accurest-core/src/main/groovy/io/codearte/accurest/util/ContentType.groovy @@ -2,14 +2,14 @@ package io.codearte.accurest.util enum ContentType { - JSON("application/json"), - XML("application/xml"), - UNKNOWN("application/octet-stream") + JSON("application/json"), + XML("application/xml"), + UNKNOWN("application/octet-stream") - final String mimeType + final String mimeType - ContentType(String mimeType) { - this.mimeType = mimeType - } + ContentType(String mimeType) { + this.mimeType = mimeType + } } \ No newline at end of file diff --git a/accurest-core/src/main/groovy/io/codearte/accurest/util/ValidateUtils.groovy b/accurest-core/src/main/groovy/io/codearte/accurest/util/ValidateUtils.groovy index 7cb6e0f0ef..46e9706cfe 100644 --- a/accurest-core/src/main/groovy/io/codearte/accurest/util/ValidateUtils.groovy +++ b/accurest-core/src/main/groovy/io/codearte/accurest/util/ValidateUtils.groovy @@ -12,35 +12,35 @@ import static io.codearte.accurest.dsl.internal.MatchingStrategy.Type.EQUAL_TO @TypeChecked class ValidateUtils { - static Object validateServerValueIsAvailable(Object value) { - validateServerValueIsAvailable(value, "Server value") - return value - } + static Object validateServerValueIsAvailable(Object value) { + validateServerValueIsAvailable(value, "Server value") + return value + } - static Object validateServerValueIsAvailable(Object value, String msg) { - validateServerValue(value, msg) - return value - } + static Object validateServerValueIsAvailable(Object value, String msg) { + validateServerValue(value, msg) + return value + } - static void validateServerValue(Pattern pattern, String msg) { - throw new IllegalStateException("$msg can't be a pattern for the server side") - } + static void validateServerValue(Pattern pattern, String msg) { + throw new IllegalStateException("$msg can't be a pattern for the server side") + } - static List ALLOWED_MATCHING_TYPES_ON_SERVER_SIDE = [EQUAL_TO, ABSENT] + static List ALLOWED_MATCHING_TYPES_ON_SERVER_SIDE = [EQUAL_TO, ABSENT] - static void validateServerValue(MatchingStrategy matchingStrategy, String msg) { - if (!ALLOWED_MATCHING_TYPES_ON_SERVER_SIDE.contains(matchingStrategy.type)) { - throw new IllegalStateException("$msg can't be of a matching type: $matchingStrategy.type for the server side") - } - validateServerValue(matchingStrategy.serverValue, msg) - } + static void validateServerValue(MatchingStrategy matchingStrategy, String msg) { + if (!ALLOWED_MATCHING_TYPES_ON_SERVER_SIDE.contains(matchingStrategy.type)) { + throw new IllegalStateException("$msg can't be of a matching type: $matchingStrategy.type for the server side") + } + validateServerValue(matchingStrategy.serverValue, msg) + } - static void validateServerValue(DslProperty value, String msg) { - validateServerValue(value.serverValue, msg) - } + static void validateServerValue(DslProperty value, String msg) { + validateServerValue(value.serverValue, msg) + } - static void validateServerValue(Object value, String msg) { - // OK - } + static void validateServerValue(Object value, String msg) { + // OK + } } diff --git a/accurest-core/src/test/groovy/io/codearte/accurest/builder/JaxRsClientSpockMethodBuilderSpec.groovy b/accurest-core/src/test/groovy/io/codearte/accurest/builder/JaxRsClientSpockMethodBuilderSpec.groovy index f2ae54c6cf..aa5a26cb5d 100644 --- a/accurest-core/src/test/groovy/io/codearte/accurest/builder/JaxRsClientSpockMethodBuilderSpec.groovy +++ b/accurest-core/src/test/groovy/io/codearte/accurest/builder/JaxRsClientSpockMethodBuilderSpec.groovy @@ -18,8 +18,8 @@ class JaxRsClientSpockMethodBuilderSpec extends Specification implements WireMoc response { status 200 body """{ - "property1": "a", - "property2": "b" + "property1": "a", + "property2": "b" }""" } } @@ -126,10 +126,10 @@ class JaxRsClientSpockMethodBuilderSpec extends Specification implements WireMoc status 200 body """[ { - "property1": "a" + "property1": "a" }, { - "property2": "b" + "property2": "b" }]""" } } @@ -154,10 +154,10 @@ class JaxRsClientSpockMethodBuilderSpec extends Specification implements WireMoc response { status 200 body """{ - "property1": [ - { "property2": "test1"}, - { "property3": "test2"} - ] + "property1": [ + { "property2": "test1"}, + { "property3": "test2"} + ] }""" } } @@ -183,8 +183,8 @@ class JaxRsClientSpockMethodBuilderSpec extends Specification implements WireMoc status 200 body '''\ { - "property1": "a", - "property2": {"property3": "b"} + "property1": "a", + "property2": {"property3": "b"} } ''' } diff --git a/accurest-core/src/test/groovy/io/codearte/accurest/builder/MockMvcSpockMethodBuilderSpec.groovy b/accurest-core/src/test/groovy/io/codearte/accurest/builder/MockMvcSpockMethodBuilderSpec.groovy index a56df6014b..e3e4120e0d 100644 --- a/accurest-core/src/test/groovy/io/codearte/accurest/builder/MockMvcSpockMethodBuilderSpec.groovy +++ b/accurest-core/src/test/groovy/io/codearte/accurest/builder/MockMvcSpockMethodBuilderSpec.groovy @@ -21,8 +21,8 @@ class MockMvcSpockMethodBuilderSpec extends Specification implements WireMockStu response { status 200 body """{ - "property1": "a", - "property2": "b" + "property1": "a", + "property2": "b" }""" } } @@ -129,10 +129,10 @@ class MockMvcSpockMethodBuilderSpec extends Specification implements WireMockStu status 200 body """[ { - "property1": "a" + "property1": "a" }, { - "property2": "b" + "property2": "b" }]""" } } @@ -157,10 +157,10 @@ class MockMvcSpockMethodBuilderSpec extends Specification implements WireMockStu response { status 200 body """{ - "property1": [ - { "property2": "test1"}, - { "property3": "test2"} - ] + "property1": [ + { "property2": "test1"}, + { "property3": "test2"} + ] }""" } } @@ -186,8 +186,8 @@ class MockMvcSpockMethodBuilderSpec extends Specification implements WireMockStu status 200 body '''\ { - "property1": "a", - "property2": {"property3": "b"} + "property1": "a", + "property2": {"property3": "b"} } ''' } diff --git a/accurest-core/src/test/groovy/io/codearte/accurest/dsl/WireMockGroovyDslSpec.groovy b/accurest-core/src/test/groovy/io/codearte/accurest/dsl/WireMockGroovyDslSpec.groovy index 2188321374..053d33217b 100755 --- a/accurest-core/src/test/groovy/io/codearte/accurest/dsl/WireMockGroovyDslSpec.groovy +++ b/accurest-core/src/test/groovy/io/codearte/accurest/dsl/WireMockGroovyDslSpec.groovy @@ -85,17 +85,17 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie AssertionUtil.assertThatJsonsAreEqual(''' { "request" : { - "url" : "/ingredients", - "method" : "GET", - "headers" : { - "Content-Type" : { - "equalTo" : "application/vnd.pl.devoxx.aggregatr.v1+json" - } - } + "url" : "/ingredients", + "method" : "GET", + "headers" : { + "Content-Type" : { + "equalTo" : "application/vnd.pl.devoxx.aggregatr.v1+json" + } + } }, "response" : { - "status" : 200, - "body" : "{\\"ingredients\\":[{\\"type\\":\\"MALT\\",\\"quantity\\":100},{\\"type\\":\\"WATER\\",\\"quantity\\":200},{\\"type\\":\\"HOP\\",\\"quantity\\":300},{\\"type\\":\\"YIEST\\",\\"quantity\\":400}]}" + "status" : 200, + "body" : "{\\"ingredients\\":[{\\"type\\":\\"MALT\\",\\"quantity\\":100},{\\"type\\":\\"WATER\\",\\"quantity\\":200},{\\"type\\":\\"HOP\\",\\"quantity\\":300},{\\"type\\":\\"YIEST\\",\\"quantity\\":400}]}" } } ''', wireMockStub) @@ -132,24 +132,24 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie then: AssertionUtil.assertThatJsonsAreEqual(''' { - "request": { - "method": "POST", - "headers": { - "Content-Type": { - "equalTo": "application/x-www-form-urlencoded" - } - }, - "url": "/ws/payments", - "bodyPatterns": [ - { - "matches": "paymentType=INCOMING&transferType=BANK&amount=[0-9]{3}\\\\.[0-9]{2}&bookingDate=[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])" - } - ] - }, - "response": { - "status": 204, - "body": "{\\"paymentId\\":\\"4\\",\\"foundExistingPayment\\":false}" - } + "request": { + "method": "POST", + "headers": { + "Content-Type": { + "equalTo": "application/x-www-form-urlencoded" + } + }, + "url": "/ws/payments", + "bodyPatterns": [ + { + "matches": "paymentType=INCOMING&transferType=BANK&amount=[0-9]{3}\\\\.[0-9]{2}&bookingDate=[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])" + } + ] + }, + "response": { + "status": 204, + "body": "{\\"paymentId\\":\\"4\\",\\"foundExistingPayment\\":false}" + } } ''', wireMockStub) and: @@ -166,13 +166,13 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie response { status 200 body("""\ - { - "id": "${value(client('123'), server('321'))}", - "surname": "${value(client('Kowalsky'), server('Lewandowski'))}", - "name": "Jan", - "created" : "${$(client('2014-02-02 12:23:43'), server('2999-09-09 01:23:45'))}" - } - """ + { + "id": "${value(client('123'), server('321'))}", + "surname": "${value(client('Kowalsky'), server('Lewandowski'))}", + "name": "Jan", + "created" : "${$(client('2014-02-02 12:23:43'), server('2999-09-09 01:23:45'))}" + } + """ ) headers { header 'Content-Type': 'text/plain' @@ -185,15 +185,15 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie AssertionUtil.assertThatJsonsAreEqual((''' { "request" : { - "urlPattern" : "/[0-9]{2}", - "method" : "GET" + "urlPattern" : "/[0-9]{2}", + "method" : "GET" }, "response" : { - "status" : 200, - "body" : "{\\"created\\":\\"2014-02-02 12:23:43\\",\\"id\\":\\"123\\",\\"name\\":\\"Jan\\",\\"surname\\":\\"Kowalsky\\"}", - "headers" : { - "Content-Type" : "text/plain" - } + "status" : 200, + "body" : "{\\"created\\":\\"2014-02-02 12:23:43\\",\\"id\\":\\"123\\",\\"name\\":\\"Jan\\",\\"surname\\":\\"Kowalsky\\"}", + "headers" : { + "Content-Type" : "text/plain" + } } } '''), wireMockStub) @@ -216,10 +216,10 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie response { status 200 body("""\ - { - "name": "Jan" - } - """ + { + "name": "Jan" + } + """ ) headers { header 'Content-Type': 'text/plain' @@ -232,18 +232,18 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie AssertionUtil.assertThatJsonsAreEqual(''' { "request" : { - "urlPattern" : "/[0-9]{2}", - "method" : "GET", - "bodyPatterns" : [ { - "matchesJsonPath" : "$[?(@.name == 'Jan')]" - } ] + "urlPattern" : "/[0-9]{2}", + "method" : "GET", + "bodyPatterns" : [ { + "matchesJsonPath" : "$[?(@.name == 'Jan')]" + } ] }, "response" : { - "status" : 200, - "body" : "{\\"name\\":\\"Jan\\"}", - "headers" : { - "Content-Type" : "text/plain" - } + "status" : 200, + "body" : "{\\"name\\":\\"Jan\\"}", + "headers" : { + "Content-Type" : "text/plain" + } } } ''', wireMockStub) @@ -280,20 +280,20 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie AssertionUtil.assertThatJsonsAreEqual((''' { "request" : { - "urlPattern" : "/[0-9]{2}", - "method" : "GET", - "bodyPatterns" : [ { - "matchesJsonPath" : "$[?(@.created == '2014-02-02 12:23:43')]" - }, { - "matchesJsonPath" : "$[?(@.surname == 'Kowalsky')]" - }, { - "matchesJsonPath" : "$[?(@.name == 'Jan')]" - }, { - "matchesJsonPath" : "$[?(@.id == '123')]" - } ] + "urlPattern" : "/[0-9]{2}", + "method" : "GET", + "bodyPatterns" : [ { + "matchesJsonPath" : "$[?(@.created == '2014-02-02 12:23:43')]" + }, { + "matchesJsonPath" : "$[?(@.surname == 'Kowalsky')]" + }, { + "matchesJsonPath" : "$[?(@.name == 'Jan')]" + }, { + "matchesJsonPath" : "$[?(@.id == '123')]" + } ] }, "response" : { - "status" : 200 + "status" : 200 } } '''), wireMockStub) @@ -326,19 +326,19 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie AssertionUtil.assertThatJsonsAreEqual((''' { "request" : { - "url" : "/users", - "method" : "GET", - "bodyPatterns" : [ { - "matchesJsonPath" : "$[?(@.name == 'Jan')]" - } ], - "headers" : { - "Content-Type" : { - "equalTo" : "customtype/json" - } - } + "url" : "/users", + "method" : "GET", + "bodyPatterns" : [ { + "matchesJsonPath" : "$[?(@.name == 'Jan')]" + } ], + "headers" : { + "Content-Type" : { + "equalTo" : "customtype/json" + } + } }, "response" : { - "status" : 200 + "status" : 200 } } '''), json) @@ -548,10 +548,10 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie response { status 200 body("""\ - { - "name": "Jan" - } - """ + { + "name": "Jan" + } + """ ) headers { header 'Content-Type': 'text/plain' @@ -564,18 +564,18 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie AssertionUtil.assertThatJsonsAreEqual((''' { "request" : { - "urlPattern" : "/[0-9]{2}", - "method" : "GET", - "bodyPatterns" : [ { - "matchesJsonPath" : "$[?(@.personalId =~ /^[0-9]{11}$/)]" - } ] + "urlPattern" : "/[0-9]{2}", + "method" : "GET", + "bodyPatterns" : [ { + "matchesJsonPath" : "$[?(@.personalId =~ /^[0-9]{11}$/)]" + } ] }, "response" : { - "status" : 200, - "body" : "{\\"name\\":\\"Jan\\"}", - "headers" : { - "Content-Type" : "text/plain" - } + "status" : 200, + "body" : "{\\"name\\":\\"Jan\\"}", + "headers" : { + "Content-Type" : "text/plain" + } } } '''), wireMockStub) @@ -590,11 +590,11 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie method 'PUT' url '/fraudcheck' body(""" - { - "clientPesel":"${value(client(regex('[0-9]{10}')), server('1234567890'))}", - "loanAmount":123.123 - } - """ + { + "clientPesel":"${value(client(regex('[0-9]{10}')), server('1234567890'))}", + "loanAmount":123.123 + } + """ ) headers { header('Content-Type', 'application/vnd.fraud.v1+json') @@ -619,25 +619,25 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie AssertionUtil.assertThatJsonsAreEqual((''' { "request" : { - "url" : "/fraudcheck", - "method" : "PUT", - "bodyPatterns" : [ { - "matchesJsonPath" : "$[?(@.loanAmount == 123.123)]" - }, { - "matchesJsonPath" : "$[?(@.clientPesel =~ /[0-9]{10}/)]" - } ], - "headers" : { - "Content-Type" : { - "equalTo" : "application/vnd.fraud.v1+json" - } - } + "url" : "/fraudcheck", + "method" : "PUT", + "bodyPatterns" : [ { + "matchesJsonPath" : "$[?(@.loanAmount == 123.123)]" + }, { + "matchesJsonPath" : "$[?(@.clientPesel =~ /[0-9]{10}/)]" + } ], + "headers" : { + "Content-Type" : { + "equalTo" : "application/vnd.fraud.v1+json" + } + } }, "response" : { - "status" : 200, - "body" : "{\\"fraudCheckStatus\\":\\"OK\\",\\"rejectionReason\\":null}", - "headers" : { - "Content-Type" : "application/vnd.fraud.v1+json" - } + "status" : 200, + "body" : "{\\"fraudCheckStatus\\":\\"OK\\",\\"rejectionReason\\":null}", + "headers" : { + "Content-Type" : "application/vnd.fraud.v1+json" + } } } '''), wireMockStub) @@ -686,20 +686,20 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie "equalTo": "email" }, "sort": { - "matches": "^[0-9]{10}$" - }, - "search": { - "doesNotMatch": "^/[0-9]{2}$" - }, - "age": { - "doesNotMatch": "^\\\\w*$" - }, - "name": { - "matches": "Denis.*" - }, - "credit": { - "absent": true - } + "matches": "^[0-9]{10}$" + }, + "search": { + "doesNotMatch": "^/[0-9]{2}$" + }, + "age": { + "doesNotMatch": "^\\\\w*$" + }, + "name": { + "matches": "Denis.*" + }, + "credit": { + "absent": true + } } }, "response": { @@ -967,32 +967,32 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie AssertionUtil.assertThatJsonsAreEqual((''' { "request" : { - "urlPattern" : "/[0-9]{2}", - "method" : "GET", - "bodyPatterns" : [ { - "matchesJsonPath" : "$.errors[*][?(@.propertyName =~ /[0-9]{2}/)]" - }, { - "matchesJsonPath" : "$.errors[*][?(@.providerValue == 'Test')]" - }, { - "matchesJsonPath" : "$.errors[*][?(@.providerValue == 'Test')]" - }, { - "matchesJsonPath" : "$[?(@.lastName =~ /.*/)]" - }, { - "matchesJsonPath" : "$.errors[*][?(@.propertyName =~ /[0-9]{2}/)]" - }, { - "matchesJsonPath" : "$[?(@.birthDate =~ /[0-9]{4}-[0-9]{2}-[0-9]{2}/)]" - }, { - "matchesJsonPath" : "$[?(@.personalId =~ /[0-9]{11}/)]" - }, { - "matchesJsonPath" : "$[?(@.firstName =~ /.*/)]" - } ] + "urlPattern" : "/[0-9]{2}", + "method" : "GET", + "bodyPatterns" : [ { + "matchesJsonPath" : "$.errors[*][?(@.propertyName =~ /[0-9]{2}/)]" + }, { + "matchesJsonPath" : "$.errors[*][?(@.providerValue == 'Test')]" + }, { + "matchesJsonPath" : "$.errors[*][?(@.providerValue == 'Test')]" + }, { + "matchesJsonPath" : "$[?(@.lastName =~ /.*/)]" + }, { + "matchesJsonPath" : "$.errors[*][?(@.propertyName =~ /[0-9]{2}/)]" + }, { + "matchesJsonPath" : "$[?(@.birthDate =~ /[0-9]{4}-[0-9]{2}-[0-9]{2}/)]" + }, { + "matchesJsonPath" : "$[?(@.personalId =~ /[0-9]{11}/)]" + }, { + "matchesJsonPath" : "$[?(@.firstName =~ /.*/)]" + } ] }, "response" : { - "status" : 200, - "body" : "{\\"name\\":\\"Jan\\"}", - "headers" : { - "Content-Type" : "text/plain" - } + "status" : 200, + "body" : "{\\"name\\":\\"Jan\\"}", + "headers" : { + "Content-Type" : "text/plain" + } } } '''), wireMockStub) @@ -1031,28 +1031,28 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie AssertionUtil.assertThatJsonsAreEqual((''' { "request" : { - "url" : "/reissue-payment-order", - "method" : "POST", - "bodyPatterns" : [ { - "matchesJsonPath" : "$[?(@.loanNumber == '999997001')]" - }, { - "matchesJsonPath" : "$[?(@.username =~ /.*/)]" - }, { - "matchesJsonPath" : "$[?(@.amount =~ /[0-9.]+/)]" - }, { - "matchesJsonPath" : "$[?(@.cardId == 1)]" - }, { - "matchesJsonPath" : "$[?(@.currency == 'DKK')]" - }, { - "matchesJsonPath" : "$[?(@.applicationName =~ /.*/)]" - } ] + "url" : "/reissue-payment-order", + "method" : "POST", + "bodyPatterns" : [ { + "matchesJsonPath" : "$[?(@.loanNumber == '999997001')]" + }, { + "matchesJsonPath" : "$[?(@.username =~ /.*/)]" + }, { + "matchesJsonPath" : "$[?(@.amount =~ /[0-9.]+/)]" + }, { + "matchesJsonPath" : "$[?(@.cardId == 1)]" + }, { + "matchesJsonPath" : "$[?(@.currency == 'DKK')]" + }, { + "matchesJsonPath" : "$[?(@.applicationName =~ /.*/)]" + } ] }, "response" : { - "status" : 200, - "body" : "{\\"status\\":\\"OK\\"}", - "headers" : { - "Content-Type" : "application/json" - } + "status" : 200, + "body" : "{\\"status\\":\\"OK\\"}", + "headers" : { + "Content-Type" : "application/json" + } } } '''), json) @@ -1075,50 +1075,50 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie then: AssertionUtil.assertThatJsonsAreEqual((''' { - "request": { - "method": "POST", - "url": "test", - "bodyPatterns": [ - { - "equalTo": "" - } - ] - }, - "response": { - "status": 406 - } + "request": { + "method": "POST", + "url": "test", + "bodyPatterns": [ + { + "equalTo": "" + } + ] + }, + "response": { + "status": 406 + } } '''), json) } - def "should generate stub with priority"() { - given: - GroovyDsl groovyDsl = GroovyDsl.make { - priority 9 - request { - method('POST') - url("test") - } - response { - status 406 - } - } - when: - def json = toWireMockClientJsonStub(groovyDsl) - then: + def "should generate stub with priority"() { + given: + GroovyDsl groovyDsl = GroovyDsl.make { + priority 9 + request { + method('POST') + url("test") + } + response { + status 406 + } + } + when: + def json = toWireMockClientJsonStub(groovyDsl) + then: AssertionUtil.assertThatJsonsAreEqual((''' - { - "priority": 9, - "request": { - "method": "POST", - "url": "test" - }, - "response": { - "status": 406 - } - } - '''), json) - } + { + "priority": 9, + "request": { + "method": "POST", + "url": "test" + }, + "response": { + "status": 406 + } + } + '''), json) + } @Issue("#127") def 'should use "test" as an alias for "server"'() { @@ -1140,16 +1140,16 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie AssertionUtil.assertThatJsonsAreEqual((''' { "request" : { - "method" : "POST", - "bodyPatterns" : [ { - "matchesJsonPath" : "$[?(@.property == 'value')]" - } ] + "method" : "POST", + "bodyPatterns" : [ { + "matchesJsonPath" : "$[?(@.property == 'value')]" + } ] }, "response" : { - "status" : 200 + "status" : 200 } } - '''), wireMockStub) + '''), wireMockStub) and: stubMappingIsValidWireMockStub(wireMockStub) } diff --git a/accurest-core/src/test/groovy/io/codearte/accurest/dsl/WireMockStubVerifier.groovy b/accurest-core/src/test/groovy/io/codearte/accurest/dsl/WireMockStubVerifier.groovy index a970434c05..241380062f 100644 --- a/accurest-core/src/test/groovy/io/codearte/accurest/dsl/WireMockStubVerifier.groovy +++ b/accurest-core/src/test/groovy/io/codearte/accurest/dsl/WireMockStubVerifier.groovy @@ -5,12 +5,12 @@ import java.util.regex.Pattern trait WireMockStubVerifier { - void stubMappingIsValidWireMockStub(String mappingDefinition) { - StubMapping stubMapping = StubMapping.buildFrom(mappingDefinition) - stubMapping.request.bodyPatterns.findAll { it.matches }.every { - Pattern.compile(it.matches) - } - assert !mappingDefinition.contains('DslProperty') - } + void stubMappingIsValidWireMockStub(String mappingDefinition) { + StubMapping stubMapping = StubMapping.buildFrom(mappingDefinition) + stubMapping.request.bodyPatterns.findAll { it.matches }.every { + Pattern.compile(it.matches) + } + assert !mappingDefinition.contains('DslProperty') + } } diff --git a/accurest-core/src/test/groovy/io/codearte/accurest/dsl/internal/ExecutionPropertySpec.groovy b/accurest-core/src/test/groovy/io/codearte/accurest/dsl/internal/ExecutionPropertySpec.groovy index d8660a8433..35e0fbe83a 100644 --- a/accurest-core/src/test/groovy/io/codearte/accurest/dsl/internal/ExecutionPropertySpec.groovy +++ b/accurest-core/src/test/groovy/io/codearte/accurest/dsl/internal/ExecutionPropertySpec.groovy @@ -4,16 +4,16 @@ import spock.lang.Specification class ExecutionPropertySpec extends Specification { - def 'should insert passed value in place of $it placeholder'() { - given: - String commandToExecute = 'commandToExecute($it)' - ExecutionProperty executionProperty = new ExecutionProperty(commandToExecute) - and: - String valueToInsert = 'someObject.itsValue' - when: - String commandWithInsertedValue = executionProperty.insertValue(valueToInsert) - then: - 'commandToExecute(someObject.itsValue)' == commandWithInsertedValue - } + def 'should insert passed value in place of $it placeholder'() { + given: + String commandToExecute = 'commandToExecute($it)' + ExecutionProperty executionProperty = new ExecutionProperty(commandToExecute) + and: + String valueToInsert = 'someObject.itsValue' + when: + String commandWithInsertedValue = executionProperty.insertValue(valueToInsert) + then: + 'commandToExecute(someObject.itsValue)' == commandWithInsertedValue + } } diff --git a/accurest-core/src/test/resources/dsl/basic/sampleDsl.groovy b/accurest-core/src/test/resources/dsl/basic/sampleDsl.groovy index 95d19e6b87..4405a9920e 100644 --- a/accurest-core/src/test/resources/dsl/basic/sampleDsl.groovy +++ b/accurest-core/src/test/resources/dsl/basic/sampleDsl.groovy @@ -5,23 +5,23 @@ io.codearte.accurest.dsl.GroovyDsl.make { header 'Content-Type': 'application/json' } body("""\ - { - "name": "Jan", - "id": "${value(client('abc'), server('def'))}", - } - """ + { + "name": "Jan", + "id": "${value(client('abc'), server('def'))}", + } + """ ) url $(client('/[0-9]{2}'), server('/12')) } response { status 200 body("""\ - { - "name": "Jan", - "id": "${value(client('123'), server('321'))}", + { + "name": "Jan", + "id": "${value(client('123'), server('321'))}", "surname": "${value(client('Kowalsky'), server('$checkIfSurnameValid($value)'))}" - } - """ + } + """ ) headers { header 'Content-Type': 'text/plain' diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/build.gradle b/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/build.gradle index 48929c705b..52e2415869 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/build.gradle +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/build.gradle @@ -1,71 +1,71 @@ buildscript { - repositories { - mavenCentral() - } + repositories { + mavenCentral() + } } apply plugin: 'groovy' apply plugin: 'accurest' ext { - contractsDir = file("${project.rootDir}/repository/mappings/com/ofg/twitter-places-analyzer") - wireMockStubsOutputDirRoot = file("${project.buildDir}/production/${project.name}-stubs/") - wireMockStubsOutputDir = new File(wireMockStubsOutputDirRoot, 'repository/mappings/') + contractsDir = file("${project.rootDir}/repository/mappings/com/ofg/twitter-places-analyzer") + wireMockStubsOutputDirRoot = file("${project.buildDir}/production/${project.name}-stubs/") + wireMockStubsOutputDir = new File(wireMockStubsOutputDirRoot, 'repository/mappings/') } configurations { - all { - resolutionStrategy { - eachDependency { DependencyResolveDetails details -> - // To prevent an accidental usage of groovy-all.jar and groovy.jar in different versions - // all modularized Groovy jars are replaced with groovy-all.jar by default. - if (details.requested.group == 'org.codehaus.groovy' && details.requested.name != "groovy-all") { - details.useTarget("org.codehaus.groovy:groovy-all:${details.requested.version}") - } - } - } - } + all { + resolutionStrategy { + eachDependency { DependencyResolveDetails details -> + // To prevent an accidental usage of groovy-all.jar and groovy.jar in different versions + // all modularized Groovy jars are replaced with groovy-all.jar by default. + if (details.requested.group == 'org.codehaus.groovy' && details.requested.name != "groovy-all") { + details.useTarget("org.codehaus.groovy:groovy-all:${details.requested.version}") + } + } + } + } } repositories { - mavenCentral() + mavenCentral() } dependencies { - compile "org.springframework:spring-web:$springVersion" - compile "org.springframework:spring-context-support:$springVersion" - compile "org.codehaus.groovy:groovy-all:2.4.1" - compile 'com.fasterxml.jackson.core:jackson-databind:2.4.4' - compile "org.codehaus.jackson:jackson-mapper-asl:$jacksonMapper" - compile "org.codehaus.jackson:jackson-core-asl:$jacksonMapper" - compile 'com.jayway.jsonpath:json-path-assert:1.2.0' + compile "org.springframework:spring-web:$springVersion" + compile "org.springframework:spring-context-support:$springVersion" + compile "org.codehaus.groovy:groovy-all:2.4.1" + compile 'com.fasterxml.jackson.core:jackson-databind:2.4.4' + compile "org.codehaus.jackson:jackson-mapper-asl:$jacksonMapper" + compile "org.codehaus.jackson:jackson-core-asl:$jacksonMapper" + compile 'com.jayway.jsonpath:json-path-assert:1.2.0' - testCompile('com.github.tomakehurst:wiremock:1.53') { - exclude group: 'org.mortbay.jetty', module: 'servlet-api' - } - testCompile "org.spockframework:spock-spring:0.7-groovy-2.0" - testCompile "com.jayway.restassured:rest-assured:$restAssuredVersion" - testCompile "com.jayway.restassured:spring-mock-mvc:$restAssuredVersion" - testCompile "javax.servlet:javax.servlet-api:3.0.1" //provided - testCompile "ch.qos.logback:logback-classic:1.1.2" + testCompile('com.github.tomakehurst:wiremock:1.53') { + exclude group: 'org.mortbay.jetty', module: 'servlet-api' + } + testCompile "org.spockframework:spock-spring:0.7-groovy-2.0" + testCompile "com.jayway.restassured:rest-assured:$restAssuredVersion" + testCompile "com.jayway.restassured:spring-mock-mvc:$restAssuredVersion" + testCompile "javax.servlet:javax.servlet-api:3.0.1" //provided + testCompile "ch.qos.logback:logback-classic:1.1.2" } accurest { - baseClassForTests = 'com.ofg.twitter.places.BaseMockMvcSpec' - basePackageForTests = 'accurest' - contractsDslDir = contractsDir -// generatedTestSourcesDir = file("${project.rootDir}/src/test/groovy/") - stubsOutputDir = wireMockStubsOutputDir + baseClassForTests = 'com.ofg.twitter.places.BaseMockMvcSpec' + basePackageForTests = 'accurest' + contractsDslDir = contractsDir +// generatedTestSourcesDir = file("${project.rootDir}/src/test/groovy/") + stubsOutputDir = wireMockStubsOutputDir } //TODO: Put it into the plugin task createWireMockStubsOutputDir << { - wireMockStubsOutputDir.mkdirs() + wireMockStubsOutputDir.mkdirs() } generateWireMockClientStubs.dependsOn { createWireMockStubsOutputDir } generateAccurest.dependsOn generateWireMockClientStubs wrapper { - gradleVersion '2.2.1' + gradleVersion '2.2.1' } diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/repository/mappings/com/ofg/twitter-places-analyzer/pairId/colleratePlacesFromTweet.groovy b/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/repository/mappings/com/ofg/twitter-places-analyzer/pairId/colleratePlacesFromTweet.groovy index 6fe36c6a89..826f71b791 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/repository/mappings/com/ofg/twitter-places-analyzer/pairId/colleratePlacesFromTweet.groovy +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/repository/mappings/com/ofg/twitter-places-analyzer/pairId/colleratePlacesFromTweet.groovy @@ -1,18 +1,18 @@ io.codearte.accurest.dsl.GroovyDsl.make { priority 2 - request { - method 'PUT' - url '/api/12' - headers { - header 'Content-Type': 'application/json' - } - body '''\ - [{ - "text": "Gonna see you at Warsaw" - }] + request { + method 'PUT' + url '/api/12' + headers { + header 'Content-Type': 'application/json' + } + body '''\ + [{ + "text": "Gonna see you at Warsaw" + }] ''' - } - response { - status 200 - } + } + response { + status 200 + } } \ No newline at end of file diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/repository/mappings/com/ofg/twitter-places-analyzer/pairId/moreComplexVersion.groovy b/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/repository/mappings/com/ofg/twitter-places-analyzer/pairId/moreComplexVersion.groovy index fdeb658215..943fbc23b9 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/repository/mappings/com/ofg/twitter-places-analyzer/pairId/moreComplexVersion.groovy +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/repository/mappings/com/ofg/twitter-places-analyzer/pairId/moreComplexVersion.groovy @@ -1,21 +1,21 @@ io.codearte.accurest.dsl.GroovyDsl.make { - request { - method 'PUT' - url $(client(regex('^/api/[0-9]{2}$')), server('/api/12')) - headers { - header 'Content-Type': 'application/json' - } - body '''\ - [{ - "text": "Gonna see you at Warsaw" - }] + request { + method 'PUT' + url $(client(regex('^/api/[0-9]{2}$')), server('/api/12')) + headers { + header 'Content-Type': 'application/json' + } + body '''\ + [{ + "text": "Gonna see you at Warsaw" + }] ''' - } - response { - body ( - path: $(client('/api/12'), server(regex('^/api/[0-9]{2}$'))), - correlationId: $(client('1223456'), server(execute('isProperCorrelationId($it)'))) - ) - status 200 - } + } + response { + body ( + path: $(client('/api/12'), server(regex('^/api/[0-9]{2}$'))), + correlationId: $(client('1223456'), server(execute('isProperCorrelationId($it)'))) + ) + status 200 + } } \ No newline at end of file diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/src/main/groovy/com/ofg/twitter/place/PairIdController.groovy b/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/src/main/groovy/com/ofg/twitter/place/PairIdController.groovy index 4f49f1ed3b..3a7671793c 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/src/main/groovy/com/ofg/twitter/place/PairIdController.groovy +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/src/main/groovy/com/ofg/twitter/place/PairIdController.groovy @@ -16,21 +16,21 @@ import static org.springframework.web.bind.annotation.RequestMethod.PUT @TypeChecked class PairIdController { - @RequestMapping( - value = '{pairId}', - method = PUT, - consumes = MediaType.APPLICATION_JSON_VALUE, - produces = MediaType.APPLICATION_JSON_VALUE) - String getPlacesFromTweets(@PathVariable long pairId, @RequestBody List tweets) { - log.info("Inside PairIdController, doing very important logic") - if (tweets?.text != ["Gonna see you at Warsaw"]) { - throw new IllegalArgumentException("Wrong text in tweet: ${tweets?.text}") - } - return """ - { - "path" : "/api/$pairId", - "correlationId" : 123456 - } - """ - } + @RequestMapping( + value = '{pairId}', + method = PUT, + consumes = MediaType.APPLICATION_JSON_VALUE, + produces = MediaType.APPLICATION_JSON_VALUE) + String getPlacesFromTweets(@PathVariable long pairId, @RequestBody List tweets) { + log.info("Inside PairIdController, doing very important logic") + if (tweets?.text != ["Gonna see you at Warsaw"]) { + throw new IllegalArgumentException("Wrong text in tweet: ${tweets?.text}") + } + return """ + { + "path" : "/api/$pairId", + "correlationId" : 123456 + } + """ + } } diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/src/main/groovy/com/ofg/twitter/place/Tweet.java b/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/src/main/groovy/com/ofg/twitter/place/Tweet.java index 96fdd52262..5d1e9c2835 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/src/main/groovy/com/ofg/twitter/place/Tweet.java +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/src/main/groovy/com/ofg/twitter/place/Tweet.java @@ -1,13 +1,13 @@ package com.ofg.twitter.place; public class Tweet { - private String text; + private String text; - public String getText() { - return text; - } + public String getText() { + return text; + } - public void setText(String text) { - this.text = text; - } + public void setText(String text) { + this.text = text; + } } diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/src/test/groovy/com/ofg/twitter/places/AcceptanceSpec.groovy b/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/src/test/groovy/com/ofg/twitter/places/AcceptanceSpec.groovy index 6a3bef53d7..458e275daf 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/src/test/groovy/com/ofg/twitter/places/AcceptanceSpec.groovy +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/src/test/groovy/com/ofg/twitter/places/AcceptanceSpec.groovy @@ -11,13 +11,13 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. class AcceptanceSpec extends Specification { - def "should have controller up and running"() { - given: - MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new PairIdController()).build() - expect: - mockMvc.perform(put("/api/${1}"). - contentType(MediaType.APPLICATION_JSON). - content("""[{"text":"Gonna see you at Warsaw"}]""")). - andExpect(status().isOk()) - } + def "should have controller up and running"() { + given: + MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new PairIdController()).build() + expect: + mockMvc.perform(put("/api/${1}"). + contentType(MediaType.APPLICATION_JSON). + content("""[{"text":"Gonna see you at Warsaw"}]""")). + andExpect(status().isOk()) + } } diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/src/test/groovy/com/ofg/twitter/places/BaseMockMvcSpec.groovy b/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/src/test/groovy/com/ofg/twitter/places/BaseMockMvcSpec.groovy index cade991eaa..6b8e7e630e 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/src/test/groovy/com/ofg/twitter/places/BaseMockMvcSpec.groovy +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/src/test/groovy/com/ofg/twitter/places/BaseMockMvcSpec.groovy @@ -6,11 +6,11 @@ import spock.lang.Specification abstract class BaseMockMvcSpec extends Specification { - def setup() { - RestAssuredMockMvc.standaloneSetup(new PairIdController()) - } + def setup() { + RestAssuredMockMvc.standaloneSetup(new PairIdController()) + } - void isProperCorrelationId(Integer correlationId) { - assert correlationId == 123456 - } + void isProperCorrelationId(Integer correlationId) { + assert correlationId == 123456 + } } diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsFraud.groovy b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsFraud.groovy index a47dff32e4..44b1c08604 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsFraud.groovy +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsFraud.groovy @@ -1,27 +1,27 @@ io.codearte.accurest.dsl.GroovyDsl.make { - request { - method """PUT""" - url """/fraudcheck""" - body(""" - { - "clientPesel":"${value(client(regex('[0-9]{10}')), server('1234567890'))}", - "loanAmount":99999} - """ - ) - headers { - header("""Content-Type""", """application/vnd.fraud.v1+json""") - } - - } - response { - status 200 - body( """{ - "fraudCheckStatus": "${value(client('FRAUD'), server(regex('[A-Z]{5}')))}", - "rejectionReason": "Amount too high" + request { + method """PUT""" + url """/fraudcheck""" + body(""" + { + "clientPesel":"${value(client(regex('[0-9]{10}')), server('1234567890'))}", + "loanAmount":99999} + """ + ) + headers { + header("""Content-Type""", """application/vnd.fraud.v1+json""") + } + + } + response { + status 200 + body( """{ + "fraudCheckStatus": "${value(client('FRAUD'), server(regex('[A-Z]{5}')))}", + "rejectionReason": "Amount too high" }""") - headers { - header('Content-Type': 'application/vnd.fraud.v1+json') - } - } - + headers { + header('Content-Type': 'application/vnd.fraud.v1+json') + } + } + } diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.groovy b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.groovy index fa8cd88ade..7bc64d0dac 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.groovy +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.groovy @@ -1,28 +1,28 @@ io.codearte.accurest.dsl.GroovyDsl.make { - request { - method 'PUT' - url '/fraudcheck' - body(""" - { - "clientPesel":"${value(client(regex('[0-9]{10}')), server('1234567890'))}", - "loanAmount":123.123 - } - """ - ) - headers { - header('Content-Type', 'application/vnd.fraud.v1+json') - } - - } - response { - status 200 - body( - fraudCheckStatus: "OK", - rejectionReason: $(client(null), server(execute('assertThatRejectionReasonIsNull($it)'))) - ) - headers { - header('Content-Type': 'application/vnd.fraud.v1+json') - } - } - + request { + method 'PUT' + url '/fraudcheck' + body(""" + { + "clientPesel":"${value(client(regex('[0-9]{10}')), server('1234567890'))}", + "loanAmount":123.123 + } + """ + ) + headers { + header('Content-Type', 'application/vnd.fraud.v1+json') + } + + } + response { + status 200 + body( + fraudCheckStatus: "OK", + rejectionReason: $(client(null), server(execute('assertThatRejectionReasonIsNull($it)'))) + ) + headers { + header('Content-Type': 'application/vnd.fraud.v1+json') + } + } + } diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/main/java/com/blogspot/toomuchcoding/frauddetection/FraudRestApplication.java b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/main/java/com/blogspot/toomuchcoding/frauddetection/FraudRestApplication.java index ce70aa1050..83e15edc59 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/main/java/com/blogspot/toomuchcoding/frauddetection/FraudRestApplication.java +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/main/java/com/blogspot/toomuchcoding/frauddetection/FraudRestApplication.java @@ -5,9 +5,9 @@ import java.util.Set; public class FraudRestApplication extends javax.ws.rs.core.Application { - @Override - public Set> getClasses() { - return Collections.>singleton(FraudDetectionController.class); - } + @Override + public Set> getClasses() { + return Collections.>singleton(FraudDetectionController.class); + } } \ No newline at end of file diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsFraud.json b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsFraud.json index 90383f2ce1..7229872299 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsFraud.json +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsFraud.json @@ -1,23 +1,23 @@ { - "request": { - "method": "PUT", - "headers": { - "Content-Type": { - "equalTo": "application/vnd.fraud.v1+json" - } - }, - "url": "/fraudcheck", - "bodyPatterns": [ - { - "matches": "\\s*\\{\\s*\"clientPesel\"\\s*:\\s*\"?[0-9]{10}\"?\\s*,\\s*\"loanAmount\"\\s*:\\s*\"?99999\"?\\s*\\}\\s*" - } - ] - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/vnd.fraud.v1+json" - }, - "body": "{\"fraudCheckStatus\":\"FRAUD\",\"rejectionReason\":\"Amount too high\"}" - } + "request": { + "method": "PUT", + "headers": { + "Content-Type": { + "equalTo": "application/vnd.fraud.v1+json" + } + }, + "url": "/fraudcheck", + "bodyPatterns": [ + { + "matches": "\\s*\\{\\s*\"clientPesel\"\\s*:\\s*\"?[0-9]{10}\"?\\s*,\\s*\"loanAmount\"\\s*:\\s*\"?99999\"?\\s*\\}\\s*" + } + ] + }, + "response": { + "status": 200, + "headers": { + "Content-Type": "application/vnd.fraud.v1+json" + }, + "body": "{\"fraudCheckStatus\":\"FRAUD\",\"rejectionReason\":\"Amount too high\"}" + } } \ No newline at end of file diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.json b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.json index 2f47855910..5a251171c7 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.json +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.json @@ -1,23 +1,23 @@ { - "request": { - "method": "PUT", - "headers": { - "Content-Type": { - "equalTo": "application/vnd.fraud.v1+json" - } - }, - "url": "/fraudcheck", - "bodyPatterns": [ - { - "matches": "\\s*\\{\\s*\"clientPesel\"\\s*:\\s*\"?[0-9]{10}\"?\\s*,\\s*\"loanAmount\"\\s*:\\s*\"?123.123\"?\\s*\\}\\s*" - } - ] - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/vnd.fraud.v1+json" - }, - "body": "{\"fraudCheckStatus\":\"OK\",\"rejectionReason\":null}" - } + "request": { + "method": "PUT", + "headers": { + "Content-Type": { + "equalTo": "application/vnd.fraud.v1+json" + } + }, + "url": "/fraudcheck", + "bodyPatterns": [ + { + "matches": "\\s*\\{\\s*\"clientPesel\"\\s*:\\s*\"?[0-9]{10}\"?\\s*,\\s*\"loanAmount\"\\s*:\\s*\"?123.123\"?\\s*\\}\\s*" + } + ] + }, + "response": { + "status": 200, + "headers": { + "Content-Type": "application/vnd.fraud.v1+json" + }, + "body": "{\"fraudCheckStatus\":\"OK\",\"rejectionReason\":null}" + } } \ No newline at end of file diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsFraud.groovy b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsFraud.groovy index a47dff32e4..44b1c08604 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsFraud.groovy +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsFraud.groovy @@ -1,27 +1,27 @@ io.codearte.accurest.dsl.GroovyDsl.make { - request { - method """PUT""" - url """/fraudcheck""" - body(""" - { - "clientPesel":"${value(client(regex('[0-9]{10}')), server('1234567890'))}", - "loanAmount":99999} - """ - ) - headers { - header("""Content-Type""", """application/vnd.fraud.v1+json""") - } - - } - response { - status 200 - body( """{ - "fraudCheckStatus": "${value(client('FRAUD'), server(regex('[A-Z]{5}')))}", - "rejectionReason": "Amount too high" + request { + method """PUT""" + url """/fraudcheck""" + body(""" + { + "clientPesel":"${value(client(regex('[0-9]{10}')), server('1234567890'))}", + "loanAmount":99999} + """ + ) + headers { + header("""Content-Type""", """application/vnd.fraud.v1+json""") + } + + } + response { + status 200 + body( """{ + "fraudCheckStatus": "${value(client('FRAUD'), server(regex('[A-Z]{5}')))}", + "rejectionReason": "Amount too high" }""") - headers { - header('Content-Type': 'application/vnd.fraud.v1+json') - } - } - + headers { + header('Content-Type': 'application/vnd.fraud.v1+json') + } + } + } diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.groovy b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.groovy index fa8cd88ade..7bc64d0dac 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.groovy +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.groovy @@ -1,28 +1,28 @@ io.codearte.accurest.dsl.GroovyDsl.make { - request { - method 'PUT' - url '/fraudcheck' - body(""" - { - "clientPesel":"${value(client(regex('[0-9]{10}')), server('1234567890'))}", - "loanAmount":123.123 - } - """ - ) - headers { - header('Content-Type', 'application/vnd.fraud.v1+json') - } - - } - response { - status 200 - body( - fraudCheckStatus: "OK", - rejectionReason: $(client(null), server(execute('assertThatRejectionReasonIsNull($it)'))) - ) - headers { - header('Content-Type': 'application/vnd.fraud.v1+json') - } - } - + request { + method 'PUT' + url '/fraudcheck' + body(""" + { + "clientPesel":"${value(client(regex('[0-9]{10}')), server('1234567890'))}", + "loanAmount":123.123 + } + """ + ) + headers { + header('Content-Type', 'application/vnd.fraud.v1+json') + } + + } + response { + status 200 + body( + fraudCheckStatus: "OK", + rejectionReason: $(client(null), server(execute('assertThatRejectionReasonIsNull($it)'))) + ) + headers { + header('Content-Type': 'application/vnd.fraud.v1+json') + } + } + } diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsFraud.json b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsFraud.json index 610b4ae1b1..157726ca2e 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsFraud.json +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsFraud.json @@ -1,23 +1,23 @@ { - "request": { - "method": "PUT", - "headers": { - "Content-Type": { - "equalTo": "application/vnd.fraud.v1+json" - } - }, - "url": "/fraudcheck", - "bodyPatterns": [ - { - "matches": "{\"clientPesel\":\"[0-9]{10}\",\"loanAmount\":\"99999\"}" - } - ] - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/vnd.fraud.v1+json" - }, - "body": "{\"fraudCheckStatus\":\"FRAUD\",\"rejectionReason\":\"Amount too high\"}" - } + "request": { + "method": "PUT", + "headers": { + "Content-Type": { + "equalTo": "application/vnd.fraud.v1+json" + } + }, + "url": "/fraudcheck", + "bodyPatterns": [ + { + "matches": "{\"clientPesel\":\"[0-9]{10}\",\"loanAmount\":\"99999\"}" + } + ] + }, + "response": { + "status": 200, + "headers": { + "Content-Type": "application/vnd.fraud.v1+json" + }, + "body": "{\"fraudCheckStatus\":\"FRAUD\",\"rejectionReason\":\"Amount too high\"}" + } } \ No newline at end of file diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.json b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.json index af5792092c..afa27159d9 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.json +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.json @@ -1,23 +1,23 @@ { - "request": { - "method": "PUT", - "headers": { - "Content-Type": { - "equalTo": "application/vnd.fraud.v1+json" - } - }, - "url": "/fraudcheck", - "bodyPatterns": [ - { - "matches": "{\"clientPesel\":\"[0-9]{10}\",\"loanAmount\":\"123.123\"}" - } - ] - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/vnd.fraud.v1+json" - }, - "body": "{\"fraudCheckStatus\":\"OK\",\"rejectionReason\":null}" - } + "request": { + "method": "PUT", + "headers": { + "Content-Type": { + "equalTo": "application/vnd.fraud.v1+json" + } + }, + "url": "/fraudcheck", + "bodyPatterns": [ + { + "matches": "{\"clientPesel\":\"[0-9]{10}\",\"loanAmount\":\"123.123\"}" + } + ] + }, + "response": { + "status": 200, + "headers": { + "Content-Type": "application/vnd.fraud.v1+json" + }, + "body": "{\"fraudCheckStatus\":\"OK\",\"rejectionReason\":null}" + } } \ No newline at end of file diff --git a/build.gradle b/build.gradle index c1739aa58c..7f78c6ad8a 100644 --- a/build.gradle +++ b/build.gradle @@ -24,8 +24,7 @@ scmVersion { } allprojects { - //project.version = scmVersion.version - project.version = '0.9.1-SNAPSHOT' + project.version = scmVersion.version } apply plugin: 'io.codearte.nexus-staging'