Merge remote-tracking branch 'origin/master'

# Conflicts:
#	spring-cloud-contract-verifier/src/main/groovy/org/springframework/cloud/contract/verifier/util/ContentUtils.groovy
#	spring-cloud-contract-verifier/src/test/groovy/org/springframework/cloud/contract/verifier/util/ContentUtilsSpec.groovy
This commit is contained in:
Olga Maciaszek-Sharma
2019-02-13 13:27:55 +01:00
1272 changed files with 31933 additions and 20845 deletions

View File

@@ -17,6 +17,7 @@
package org.springframework.cloud.contract.verifier.converter
import groovy.transform.CompileStatic
import org.springframework.cloud.contract.spec.ContractVerifierException
/**

View File

@@ -1,17 +1,17 @@
/*
* Copyright 2013-2016 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.contract.verifier.converter
@@ -32,6 +32,7 @@ import org.springframework.cloud.contract.verifier.file.ContractFileScannerBuild
import org.springframework.cloud.contract.verifier.file.ContractMetadata
import org.springframework.cloud.contract.verifier.util.NamesUtil
import org.springframework.cloud.contract.verifier.wiremock.DslToWireMockClientConverter
/**
* Recursively converts contracts into their stub representations
*
@@ -58,11 +59,12 @@ class RecursiveFilesConverter {
}
void processFiles() {
ContractFileScanner scanner = new ContractFileScannerBuilder().baseDir(props.contractsDslDir)
.excluded(props.excludedFiles as Set)
.ignored([] as Set).included([] as Set)
.includeMatcher(props.includedContracts)
.build()
ContractFileScanner scanner = new ContractFileScannerBuilder().
baseDir(props.contractsDslDir)
.excluded(props.excludedFiles as Set)
.ignored([] as Set).included([] as Set)
.includeMatcher(props.includedContracts)
.build()
ListMultimap<Path, ContractMetadata> contracts = scanner.findContracts()
if (log.isDebugEnabled()) {
log.debug("Found the following contracts $contracts")
@@ -73,11 +75,14 @@ class RecursiveFilesConverter {
log.debug("Will create a stub for contract [${contract}]")
}
File sourceFile = contract.path.toFile()
Collection<StubGenerator> stubGenerators = contract.convertedContract ? holder.allOrDefault(new DslToWireMockClientConverter()) :
Collection<StubGenerator> stubGenerators = contract.convertedContract ? holder.
allOrDefault(new DslToWireMockClientConverter()) :
holder.converterForName(sourceFile.name)
try {
String path = sourceFile.path
if (props.isExcludeBuildFolders() && (matchesPath(path, "target") || matchesPath(path, "build"))) {
if (props.isExcludeBuildFolders()
&& (
matchesPath(path, "target") || matchesPath(path, "build"))) {
if (log.isDebugEnabled()) {
log.debug("Exclude build folder is set. Path [${path}] contains [target] or [build] in its path")
}
@@ -92,22 +97,28 @@ class RecursiveFilesConverter {
log.debug("Stub Generators [${stubGenerators}] will convert contents of [${entryKey}]")
}
stubGenerators.each { StubGenerator stubGenerator ->
Map<Contract, String> convertedContent = stubGenerator.convertContents(entryKey.last().toString(), contract)
Map<Contract, String> convertedContent = stubGenerator.
convertContents(entryKey.last().toString(), contract)
if (!convertedContent) {
return
}
convertedContent.entrySet().eachWithIndex { Map.Entry<Contract, String> content, int index ->
Contract dsl = content.key
String converted = content.value
if (converted) {
Path absoluteTargetPath = createAndReturnTargetDirectory(sourceFile)
File newJsonFile = createTargetFileWithProperName(stubGenerator, absoluteTargetPath,
sourceFile, contractsSize, index, dsl)
newJsonFile.setText(converted, StandardCharsets.UTF_8.toString())
}
}
convertedContent.entrySet().
eachWithIndex { Map.Entry<Contract, String> content, int index ->
Contract dsl = content.key
String converted = content.value
if (converted) {
Path absoluteTargetPath =
createAndReturnTargetDirectory(sourceFile)
File newJsonFile =
createTargetFileWithProperName(stubGenerator, absoluteTargetPath,
sourceFile, contractsSize, index, dsl)
newJsonFile.setText(converted, StandardCharsets.UTF_8.
toString())
}
}
}
} catch (Exception e) {
}
catch (Exception e) {
throw new ConversionContractVerifierException("Unable to make conversion of ${sourceFile.name}", e)
}
}
@@ -119,14 +130,15 @@ class RecursiveFilesConverter {
}
private Path createAndReturnTargetDirectory(File sourceFile) {
Path relativePath = Paths.get(props.contractsDslDir.toURI()).relativize(sourceFile.parentFile.toPath())
Path relativePath = Paths.get(props.contractsDslDir.toURI()).
relativize(sourceFile.parentFile.toPath())
Path absoluteTargetPath = outMappingsDir.toPath().resolve(relativePath)
Files.createDirectories(absoluteTargetPath)
return absoluteTargetPath
}
private File createTargetFileWithProperName(StubGenerator stubGenerator, Path absoluteTargetPath,
File sourceFile, int contractsSize, int index, Contract dsl) {
File sourceFile, int contractsSize, int index, Contract dsl) {
String name = generateName(dsl, contractsSize, stubGenerator, sourceFile, index)
File newJsonFile = new File(absoluteTargetPath.toFile(), name)
log.info("Creating new stub [$newJsonFile.path]")
@@ -134,13 +146,14 @@ class RecursiveFilesConverter {
}
private String generateName(Contract dsl, int contractsSize, StubGenerator converter,
File sourceFile, int index) {
File sourceFile, int index) {
String generatedName = converter.generateOutputFileNameForInput(sourceFile.name)
boolean hasDot = NamesUtil.hasDot(generatedName)
String extension = hasDot ? NamesUtil.afterLastDot(generatedName) : ""
if (dsl.name && extension) {
return "${dsl.name}.${extension}"
} else if (contractsSize == 1) {
}
else if (contractsSize == 1) {
return generatedName
}
return "${index}_${generatedName}"

View File

@@ -1,22 +1,23 @@
/*
* Copyright 2013-2016 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.contract.verifier.converter
import groovy.transform.CompileStatic
import org.springframework.cloud.contract.spec.Contract
import org.springframework.cloud.contract.verifier.file.ContractMetadata
@@ -29,18 +30,18 @@ import org.springframework.cloud.contract.verifier.file.ContractMetadata
interface StubGenerator {
/**
* Returns {@code true} if the converter can handle the file to convert it into a stub.
* @return {@code true} if the converter can handle the file to convert it into a stub.
*/
boolean canHandleFileName(String fileName)
/**
* Returns the collection of converted contracts into stubs. One contract can
* @return the collection of converted contracts into stubs. One contract can
* result in multiple stubs.
*/
Map<Contract, String> convertContents(String rootName, ContractMetadata content)
/**
* Returns the name of the converted stub file. If you have multiple contracts
* @return the name of the converted stub file. If you have multiple contracts
* in a single file then a prefix will be added to the generated file. If you
* provide the {@link Contract#name} field then that field will override the
* generated file name.
@@ -50,4 +51,4 @@ interface StubGenerator {
* converter will create two files {@code 0_foo.json} and {@code 1_foo.json}
*/
String generateOutputFileNameForInput(String inputFileName)
}
}

View File

@@ -1,17 +1,34 @@
/*
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.contract.verifier.converter
import groovy.transform.CompileStatic
import org.springframework.core.io.support.SpringFactoriesLoader
/**
* Retrieves file converters from the class path and operates on them.
*
*
* @author Marcin Grzejszczak
* @since 1.1.0
*/
@CompileStatic
class StubGeneratorProvider {
private final List<StubGenerator> converters = []
StubGeneratorProvider() {

View File

@@ -1,29 +1,28 @@
/*
* Copyright 2013-2019 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.contract.verifier.wiremock
import groovy.transform.CompileStatic
import org.springframework.cloud.contract.spec.Contract
import org.springframework.cloud.contract.verifier.dsl.wiremock.WireMockStubStrategy
import org.springframework.cloud.contract.verifier.file.ContractMetadata
import org.springframework.cloud.contract.verifier.util.NamesUtil
import java.nio.charset.StandardCharsets
/**
* Converts DSLs to WireMock stubs
*
@@ -42,13 +41,17 @@ class DslToWireMockClientConverter extends DslToWireMockConverter {
return [:]
}
if (contract.convertedContract.size() == 1) {
return [(contract.convertedContract.first()): convertASingleContract(rootName, contract, contract.convertedContract.first())]
return [(contract.convertedContract.first()):
convertASingleContract(rootName, contract, contract.convertedContract.
first())]
}
Map<Contract, String> convertedContracts = [:]
contract.convertedContract.findAll { it.request }.eachWithIndex { Contract dsl, int index ->
String name = dsl.name ? NamesUtil.convertIllegalPackageChars(dsl.name) : "${rootName}_${index}"
convertedContracts << [(dsl) : convertASingleContract(name, contract, dsl)]
}
contract.convertedContract.findAll { it.request }.
eachWithIndex { Contract dsl, int index ->
String name = dsl.name ? NamesUtil.
convertIllegalPackageChars(dsl.name) : "${rootName}_${index}"
convertedContracts << [(dsl): convertASingleContract(name, contract, dsl)]
}
return convertedContracts
}

View File

@@ -1,17 +1,17 @@
/*
* Copyright 2013-2019 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.contract.verifier.wiremock
@@ -19,6 +19,7 @@ package org.springframework.cloud.contract.verifier.wiremock
import groovy.transform.CompileStatic
import org.springframework.cloud.contract.verifier.converter.StubGenerator
/**
* WireMock implementation of the {@link StubGenerator}
*

View File

@@ -1,32 +1,33 @@
/*
* Copyright 2013-2019 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.contract.verifier.wiremock
import java.nio.charset.StandardCharsets
import groovy.io.FileType
import groovy.json.JsonOutput
import groovy.json.JsonParserType
import groovy.json.JsonSlurper
import groovy.transform.CompileDynamic
import groovy.xml.XmlUtil
import org.springframework.cloud.contract.spec.Contract
import repackaged.nl.flotsam.xeger.Xeger
import org.springframework.cloud.contract.verifier.util.ContentUtils
import java.nio.charset.StandardCharsets
import org.springframework.cloud.contract.spec.Contract
import static org.apache.commons.text.StringEscapeUtils.escapeJava
@@ -40,7 +41,7 @@ import static org.apache.commons.text.StringEscapeUtils.escapeJava
class WireMockToDslConverter {
/**
* Returns the string content of the contract
* @return the string content of the contract
*
* @param wireMockStringStub - string content of the WireMock JSON stub
*/
@@ -61,32 +62,50 @@ class WireMockToDslConverter {
request {
${request.method ? "method \"\"\"$request.method\"\"\"" : ""}
${request.url ? "url \"\"\"$request.url\"\"\"" : ""}
${urlPattern ? "url \$(consumer(regex('${escapeJava(urlPattern)}')), producer('${new Xeger(escapeJava(urlPattern)).generate()}'))" : ""}
${urlPathPattern ? "urlPath \$(consumer(regex('${escapeJava(urlPattern)}')), producer('${new Xeger(escapeJava(urlPattern)).generate()}'))" : ""}
${
urlPattern ? "url \$(consumer(regex('${escapeJava(urlPattern)}')), producer('${new Xeger(escapeJava(urlPattern)).generate()}'))" : ""
}
${
urlPathPattern ? "urlPath \$(consumer(regex('${escapeJava(urlPattern)}')), producer('${new Xeger(escapeJava(urlPattern)).generate()}'))" : ""
}
${request.urlPath ? "url \"\"\"$request.urlPath\"\"\"" : ""}
${
request.headers ? """headers {
request.headers ? """headers {
${
request.headers.collect {
def assertion = it.value
String headerName = it.key as String
def entry = assertion.entrySet().first()
"""header(\"\"\"$headerName\"\"\", ${buildHeader(entry.key, entry.value)})\n"""
}.join('')
}
request.headers.collect {
def assertion = it.value
String headerName = it.key as String
def entry = assertion.entrySet().first()
"""header(\"\"\"$headerName\"\"\", ${
buildHeader(entry.key, entry.value)
})\n"""
}.join('')
}
}
""" : ""
}
${bodyPatterns?.equalTo?.every { it } ? "body('''${bodyPatterns.equalTo[0]}''')" : ''}
${bodyPatterns?.equalToJson?.every { it } ? "body('''${bodyPatterns.equalToJson[0]}''')" : ''}
${bodyPatterns?.matches?.every { it } ? "body \$(consumer(regex('${escapeJava(bodyPatterns.matches[0])}')), producer('${new Xeger(escapeJava(bodyPatterns.matches[0])).generate()}'))" : ""}
}
${
bodyPatterns?.equalTo?.
every { it } ? "body('''${bodyPatterns.equalTo[0]}''')" : ''
}
${
bodyPatterns?.equalToJson?.
every { it } ? "body('''${bodyPatterns.equalToJson[0]}''')" : ''
}
${
bodyPatterns?.matches?.every {
it
} ? "body \$(consumer(regex('${escapeJava(bodyPatterns.matches[0])}')), producer('${new Xeger(escapeJava(bodyPatterns.matches[0])).generate()}'))" : ""
}
}
response {
${response.status ? "status $response.status" : ""}
${response.body ? "body( ${buildBody(response.body)})" : ""}
${
response.headers ? """headers {
${response.headers.collect { "header('$it.key': '${it.value}')\n" }.join('')}
${
response.headers.collect { "header('$it.key': '${it.value}')\n" }.join('')
}
}
""" : ""
}
@@ -100,19 +119,21 @@ class WireMockToDslConverter {
private String buildHeader(String method, Object value) {
switch (method) {
case 'equalTo':
return wrapWithMultilineGString(value)
default:
return "regex(${wrapWithMultilineGString(escapeJava(value as String))})"
case 'equalTo':
return wrapWithMultilineGString(value)
default:
return "regex(${wrapWithMultilineGString(escapeJava(value as String))})"
}
}
private Object buildBody(Map responseBody) {
return responseBody.entrySet().collectAll(withQuotedMapStringElements()).inject([:], appendToIterable())
return responseBody.entrySet().collectAll(withQuotedMapStringElements()).
inject([:], appendToIterable())
}
private Object buildBody(List responseBody) {
return responseBody.collectAll(withQuotedStringElements()).inject([], appendToIterable())
return responseBody.collectAll(withQuotedStringElements()).
inject([], appendToIterable())
}
private Object buildBody(Integer responseBody) {
@@ -123,11 +144,13 @@ class WireMockToDslConverter {
try {
def json = new JsonSlurper().parseText(responseBody)
return wrapWithMultilineGString(JsonOutput.prettyPrint(responseBody))
} catch (Exception jsonException) {
}
catch (Exception jsonException) {
try {
def xml = ContentUtils.getXmlSlurperWithDefaultErrorHandler().parseText(responseBody)
return wrapWithMultilineGString(XmlUtil.serialize(responseBody))
} catch (Exception xmlException) {
}
catch (Exception xmlException) {
return wrapWithMultilineGString(responseBody)
}
}
@@ -189,12 +212,17 @@ class WireMockToDslConverter {
if (!it.name.endsWith('json')) {
return
}
String dslFromWireMockStub = fromWireMockStub(it.getText(StandardCharsets.UTF_8.toString()))
String dslWrappedWithFactoryMethod = wrapWithFactoryMethod(dslFromWireMockStub)
File newGroovyFile = new File(it.parent, it.name.replaceAll('json', 'groovy'))
String dslFromWireMockStub =
fromWireMockStub(it.getText(StandardCharsets.UTF_8.toString()))
String dslWrappedWithFactoryMethod =
wrapWithFactoryMethod(dslFromWireMockStub)
File newGroovyFile = new File(it.parent, it.name.
replaceAll('json', 'groovy'))
println("Creating new groovy file [$newGroovyFile.path]")
newGroovyFile.setText(dslWrappedWithFactoryMethod, StandardCharsets.UTF_8.toString())
} catch (Exception e) {
newGroovyFile.setText(dslWrappedWithFactoryMethod, StandardCharsets.UTF_8.
toString())
}
catch (Exception e) {
System.err.println(e)
}

View File

@@ -1,3 +1,3 @@
# Stub converters
org.springframework.cloud.contract.verifier.converter.StubGenerator=\
org.springframework.cloud.contract.verifier.wiremock.DslToWireMockClientConverter
org.springframework.cloud.contract.verifier.wiremock.DslToWireMockClientConverter

View File

@@ -1,17 +1,17 @@
/*
* Copyright 2013-2019 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.contract.verifier.converter
@@ -52,7 +52,7 @@ class RecursiveFilesConverterSpec extends Specification {
given:
ContractVerifierConfigProperties properties = new ContractVerifierConfigProperties()
File originalSourceRootDirectory = new File(this.getClass()
.getResource("/converter/source").toURI())
.getResource("/converter/source").toURI())
properties.contractsDslDir = tmpFolder.newFolder("source")
properties.stubsOutputDir = tmpFolder.newFolder("target")
FileSystemUtils
@@ -76,7 +76,7 @@ class RecursiveFilesConverterSpec extends Specification {
given:
ContractVerifierConfigProperties properties = new ContractVerifierConfigProperties()
File originalSourceRootDirectory = new File(this.getClass()
.getResource("/converter/source").toURI())
.getResource("/converter/source").toURI())
properties.contractsDslDir = tmpFolder.newFolder("source")
properties.stubsOutputDir = tmpFolder.newFolder("target")
properties.excludedFiles = ["dir1/**"]

View File

@@ -1,17 +1,17 @@
/*
* Copyright 2013-2018 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.contract.verifier.wiremock
@@ -43,8 +43,10 @@ import org.springframework.util.SocketUtils
class DslToWireMockClientConverterSpec extends Specification {
int port = SocketUtils.findAvailableTcpPort()
@Rule public WireMockRule wireMockRule = new WireMockRule(port)
@Rule public TemporaryFolder tmpFolder = new TemporaryFolder()
@Rule
public WireMockRule wireMockRule = new WireMockRule(port)
@Rule
public TemporaryFolder tmpFolder = new TemporaryFolder()
TestRestTemplate restTemplate = new TestRestTemplate()
String url
@@ -70,9 +72,9 @@ class DslToWireMockClientConverterSpec extends Specification {
""")
when:
String json = converter.convertContents("Test", new ContractMetadata(file.toPath(), false, 0, null,
ContractVerifierDslConverter.convertAsCollection(new File("/"),file))).values().first()
ContractVerifierDslConverter.convertAsCollection(new File("/"), file))).values().first()
then:
JSONAssert.assertEquals('''
JSONAssert.assertEquals('''
{"request":{"method":"PUT","urlPattern":"/[0-9]{2}"},"response":{"status":200}}
''', json, false)
and:
@@ -114,9 +116,9 @@ class DslToWireMockClientConverterSpec extends Specification {
""")
when:
String json = converter.convertContents("Test", new ContractMetadata(file.toPath(), false, 0, null,
ContractVerifierDslConverter.convertAsCollection(new File("/"),file))).values().first()
ContractVerifierDslConverter.convertAsCollection(new File("/"), file))).values().first()
then:
JSONAssert.assertEquals('''
JSONAssert.assertEquals('''
{"request":{"url":"/multipart","method":"POST","headers":{"Content-Type":{"matches":"multipart/form-data.*"}},"bodyPatterns":[{"matches" : ".*--(.*)\\r\\nContent-Disposition: form-data; name=\\"file\\"; filename=\\".+\\"\\r\\n(Content-Type: .*\\r\\n)?(Content-Transfer-Encoding: .*\\r\\n)?(Content-Length: \\\\d+\\r\\n)?\\r\\n.+\\r\\n--\\\\1.*"}]},"response":{"status":200,"body":"hello","transformers":["response-template"]}}
''', json, false)
and:
@@ -127,7 +129,7 @@ class DslToWireMockClientConverterSpec extends Specification {
MultiValueMap<String, Object> parameters = new LinkedMultiValueMap<String, Object>()
parameters.add("file", new ByteArrayResource([100, 117, 100, 97] as byte[]) {
@Override
String getFilename(){
String getFilename() {
return "file"
}
})
@@ -164,7 +166,7 @@ class DslToWireMockClientConverterSpec extends Specification {
''')
when:
Map<Contract, String> convertedContents = converter.convertContents("Test", new ContractMetadata(file.toPath(), false, 0, null,
ContractVerifierDslConverter.convertAsCollection(new File("/"),file)))
ContractVerifierDslConverter.convertAsCollection(new File("/"), file)))
then:
convertedContents.size() == 2
JSONAssert.assertEquals(jsonResponse(1), convertedContents.values().first(), false)
@@ -177,11 +179,11 @@ class DslToWireMockClientConverterSpec extends Specification {
wireMockRule.addStubMapping(mapping2)
and:
restTemplate.exchange(RequestEntity.put("${url}/1".toURI())
.header('Content-Type', 'application/json')
.body(""), String)
.header('Content-Type', 'application/json')
.body(""), String)
restTemplate.exchange(RequestEntity.put("${url}/2".toURI())
.header('Content-Type', 'application/json')
.body(""), String)
.header('Content-Type', 'application/json')
.body(""), String)
}
private String jsonResponse(int index) {
@@ -205,7 +207,7 @@ class DslToWireMockClientConverterSpec extends Specification {
when:
Map<Contract, String> convertedContents = converter.convertContents("Test",
new ContractMetadata(file.toPath(), false, 0, null,
ContractVerifierDslConverter.convertAsCollection(new File("/"),file)))
ContractVerifierDslConverter.convertAsCollection(new File("/"), file)))
then:
convertedContents.isEmpty()
}
@@ -230,7 +232,7 @@ class DslToWireMockClientConverterSpec extends Specification {
""")
when:
String json = converter.convertContents("test", new ContractMetadata(file.toPath(), false, 0, null,
ContractVerifierDslConverter.convertAsCollection(new File("/"),file))).values().first()
ContractVerifierDslConverter.convertAsCollection(new File("/"), file))).values().first()
then:
JSONAssert.assertEquals('''
{"request":{
@@ -299,9 +301,9 @@ class DslToWireMockClientConverterSpec extends Specification {
""")
when:
String json = converter.convertContents("Test", new ContractMetadata(file.toPath(), false, 0, null,
ContractVerifierDslConverter.convertAsCollection(new File("/"),file))).values().first()
ContractVerifierDslConverter.convertAsCollection(new File("/"), file))).values().first()
then:
JSONAssert.assertEquals('''
JSONAssert.assertEquals('''
{
"request" : {
"url" : "/api/12",
@@ -356,8 +358,8 @@ class DslToWireMockClientConverterSpec extends Specification {
wireMockRule.addStubMapping(mapping)
and:
restTemplate.exchange(RequestEntity.put("${url}/api/12".toURI())
.header('Content-Type', 'application/vnd.org.springframework.cloud.contract.verifier.twitter-places-analyzer.v1+json')
.body('''
.header('Content-Type', 'application/vnd.org.springframework.cloud.contract.verifier.twitter-places-analyzer.v1+json')
.body('''
[{
"created_at": "Sat Jul 26 09:38:57 +0000 2014",
"id": 492967299297845248,
@@ -417,7 +419,7 @@ class DslToWireMockClientConverterSpec extends Specification {
""")
when:
String json = converter.convertContents("test", new ContractMetadata(file.toPath(), false, 0, null,
ContractVerifierDslConverter.convertAsCollection(new File("/"),file))).values().first()
ContractVerifierDslConverter.convertAsCollection(new File("/"), file))).values().first()
then:
JSONAssert.assertEquals('''
{"request":{"urlPath":"/foos","method":"GET"},"response":{"body":"[{\\"id\\":\\"123\\"},{\\"id\\":\\"567\\"}]"}}
@@ -456,7 +458,7 @@ class DslToWireMockClientConverterSpec extends Specification {
""")
when:
String json = converter.convertContents("test", new ContractMetadata(file.toPath(), false, 0, null,
ContractVerifierDslConverter.convertAsCollection(new File("/"),file))).values().first()
ContractVerifierDslConverter.convertAsCollection(new File("/"), file))).values().first()
then:
noExceptionThrown()
and:
@@ -503,10 +505,10 @@ class DslToWireMockClientConverterSpec extends Specification {
''')
when:
String json = converter.convertContents("Test", new ContractMetadata(file.toPath(), false, 0, null,
ContractVerifierDslConverter.convertAsCollection(new File("/"),file))).values().first()
ContractVerifierDslConverter.convertAsCollection(new File("/"), file))).values().first()
then:
JSONAssert.assertEquals( // tag::wiremock[]
'''
'''
{
"request" : {
"url" : "/users/password",
@@ -533,15 +535,15 @@ class DslToWireMockClientConverterSpec extends Specification {
}
'''
// end::wiremock[]
, json, false)
, json, false)
and:
StubMapping mapping = stubMappingIsValidWireMockStub(json)
and:
wireMockRule.addStubMapping(mapping)
and:
def response = restTemplate.exchange(RequestEntity.post("${url}/users/password".toURI())
.header("Content-Type", "application/json")
.body('''{"email":"abc@abc.com", "callback_url":"http://partners.com"}''')
.header("Content-Type", "application/json")
.body('''{"email":"abc@abc.com", "callback_url":"http://partners.com"}''')
, String)
response.headers.get('Content-Type') == ['application/json']
response.statusCodeValue == 404
@@ -691,10 +693,10 @@ class DslToWireMockClientConverterSpec extends Specification {
''')
when:
String json = converter.convertContents("Test", new ContractMetadata(file.toPath(), false, 0, null,
ContractVerifierDslConverter.convertAsCollection(new File("/"),file))).values().first()
ContractVerifierDslConverter.convertAsCollection(new File("/"), file))).values().first()
then:
JSONAssert.assertEquals(//tag::matchers[]
'''
'''
{
"request" : {
"urlPath" : "/get",
@@ -755,75 +757,75 @@ class DslToWireMockClientConverterSpec extends Specification {
}
'''
//end::matchers[]
, json, false)
, json, false)
and:
StubMapping mapping = stubMappingIsValidWireMockStub(json)
and:
wireMockRule.addStubMapping(mapping)
and:
def response = restTemplate.exchange(RequestEntity.post("${url}/get".toURI())
.header("Content-Type", "application/json")
.body(JsonOutput.toJson([
duck: 123,
alpha: "abc",
number: 123,
aBoolean: true,
date: "2017-01-01",
dateTime: "2017-01-01T01:23:45",
time: "01:02:34",
valueWithoutAMatcher: "foo",
valueWithTypeMatch: "string",
list: [
some: [
nested: [
json: "with value",
anothervalue: 4
]
],
someother: [
nested: [
json: "with value",
anothervalue: 4
]
]
],
valueWithMin: [
1,2,3
],
valueWithMax: [
1,2,3
],
valueWithMinMax: [
1,2,3
],
valueWithOccurrence: [
1,2,3,4
]
]))
.header("Content-Type", "application/json")
.body(JsonOutput.toJson([
duck : 123,
alpha : "abc",
number : 123,
aBoolean : true,
date : "2017-01-01",
dateTime : "2017-01-01T01:23:45",
time : "01:02:34",
valueWithoutAMatcher: "foo",
valueWithTypeMatch : "string",
list : [
some : [
nested: [
json : "with value",
anothervalue: 4
]
],
someother: [
nested: [
json : "with value",
anothervalue: 4
]
]
],
valueWithMin : [
1, 2, 3
],
valueWithMax : [
1, 2, 3
],
valueWithMinMax : [
1, 2, 3
],
valueWithOccurrence : [
1, 2, 3, 4
]
]))
, String)
response.headers.get('Content-Type') == ['application/json']
response.statusCodeValue == 200
JSONAssert.assertEquals(JsonOutput.toJson([
duck: 123,
alpha: "abc",
number: 123,
aBoolean: true,
date: "2017-01-01",
dateTime: "2017-01-01T01:23:45",
time: "01:02:34",
duck : 123,
alpha : "abc",
number : 123,
aBoolean : true,
date : "2017-01-01",
dateTime : "2017-01-01T01:23:45",
time : "01:02:34",
valueWithoutAMatcher: "foo",
valueWithTypeMatch: "string",
valueWithMin: [
1,2,3
valueWithTypeMatch : "string",
valueWithMin : [
1, 2, 3
],
valueWithMax: [
1,2,3
valueWithMax : [
1, 2, 3
],
valueWithMinMax: [
1,2,3
valueWithMinMax : [
1, 2, 3
],
valueWithOccurrence: [
1,2,3,4
valueWithOccurrence : [
1, 2, 3, 4
],
]), response.body, false)
}
@@ -869,7 +871,7 @@ class DslToWireMockClientConverterSpec extends Specification {
''')
when:
String json = converter.convertContents("Test", new ContractMetadata(file.toPath(), false, 0, null,
ContractVerifierDslConverter.convertAsCollection(new File("/"),file))).values().first()
ContractVerifierDslConverter.convertAsCollection(new File("/"), file))).values().first()
then:
JSONAssert.assertEquals(
'''
@@ -898,15 +900,15 @@ class DslToWireMockClientConverterSpec extends Specification {
"priority" : 1
}
'''
, json, false)
, json, false)
and:
StubMapping mapping = stubMappingIsValidWireMockStub(json)
and:
wireMockRule.addStubMapping(mapping)
and:
def response = restTemplate.exchange(RequestEntity.post("${url}/users/password2".toURI())
.header("Content-Type", "application/json")
.body('''{"email":"abc@abc.com", "callback_url":"http://partners.com"}''')
.header("Content-Type", "application/json")
.body('''{"email":"abc@abc.com", "callback_url":"http://partners.com"}''')
, String)
response.headers.get('Content-Type') == ['application/json']
response.statusCodeValue == 404
@@ -964,7 +966,7 @@ class DslToWireMockClientConverterSpec extends Specification {
''')
when:
String json = converter.convertContents("Test", new ContractMetadata(file.toPath(), false, 0, null,
ContractVerifierDslConverter.convertAsCollection(new File("/"),file))).values().first()
ContractVerifierDslConverter.convertAsCollection(new File("/"), file))).values().first()
then:
JSONAssert.assertEquals(
'''
@@ -996,15 +998,15 @@ class DslToWireMockClientConverterSpec extends Specification {
}
}
'''
, json, false)
, json, false)
and:
StubMapping mapping = stubMappingIsValidWireMockStub(json)
and:
wireMockRule.addStubMapping(mapping)
and:
def response = restTemplate.exchange(RequestEntity.post("${url}/users/password2".toURI())
.header("Content-Type", "application/json")
.body('''{"email":"abc@abc.com", "callback_url":"http://partners.com"}''')
.header("Content-Type", "application/json")
.body('''{"email":"abc@abc.com", "callback_url":"http://partners.com"}''')
, String)
response.headers.get('Content-Type') == ['application/json;charset=UTF-8']
response.statusCodeValue == 400
@@ -1039,7 +1041,7 @@ class DslToWireMockClientConverterSpec extends Specification {
''')
when:
String json = converter.convertContents("Test", new ContractMetadata(file.toPath(), false, 0, null,
ContractVerifierDslConverter.convertAsCollection(new File("/"),file))).values().first()
ContractVerifierDslConverter.convertAsCollection(new File("/"), file))).values().first()
then:
JSONAssert.assertEquals(
'''
@@ -1058,7 +1060,7 @@ class DslToWireMockClientConverterSpec extends Specification {
}
}
'''
, json, false)
, json, false)
and:
StubMapping mapping = stubMappingIsValidWireMockStub(json)
and:

View File

@@ -1,17 +1,17 @@
/*
* Copyright 2013-2019 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.contract.verifier.wiremock
@@ -134,7 +134,7 @@ class WireMockToDslConverterSpec extends Specification {
}
response {
status OK()
body( """{
body("""{
"status": "OK"
}""")
headers {
@@ -239,7 +239,7 @@ class WireMockToDslConverterSpec extends Specification {
}
response {
status OK()
body( """[
body("""[
{
"a": 1,
"c": "3"
@@ -349,7 +349,7 @@ class WireMockToDslConverterSpec extends Specification {
request {
method 'POST'
url '/test'
body ('''{"property1":"abc", "property2":"2017-01", "property3":"666", "property4":1428566412}''')
body('''{"property1":"abc", "property2":"2017-01", "property3":"666", "property4":1428566412}''')
}
response {
status OK()

View File

@@ -1,28 +1,29 @@
/*
* Copyright 2013-2019 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.contract.verifier.wiremock
import org.springframework.cloud.contract.verifier.file.ContractMetadata
import org.springframework.cloud.contract.verifier.util.ContractVerifierDslConverter
import spock.lang.Specification
import java.nio.file.Path
import java.nio.file.Paths
import spock.lang.Specification
import org.springframework.cloud.contract.verifier.file.ContractMetadata
import org.springframework.cloud.contract.verifier.util.ContractVerifierDslConverter
class WiremockScenarioConverterSpec extends Specification {
def "should generate first scenario step"() {

View File

@@ -1,21 +1,21 @@
import org.springframework.cloud.contract.spec.Contract
/*
* Copyright 2013-2019 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.springframework.cloud.contract.spec.Contract
Contract.make {
request {
method('POST')

View File

@@ -1,21 +1,21 @@
import org.springframework.cloud.contract.spec.Contract
/*
* Copyright 2013-2019 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.springframework.cloud.contract.spec.Contract
Contract.make {
request {
method('GET')

View File

@@ -1,21 +1,21 @@
import org.springframework.cloud.contract.spec.Contract
/*
* Copyright 2013-2019 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.springframework.cloud.contract.spec.Contract
Contract.make {
request {
method('POST')

View File

@@ -1,18 +1,17 @@
/*
* Copyright 2013-2018 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import org.springframework.cloud.contract.spec.Contract

View File

@@ -1,21 +1,21 @@
import org.springframework.cloud.contract.spec.Contract
/*
* Copyright 2013-2019 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.springframework.cloud.contract.spec.Contract
Contract.make {
request {
method('PUT')

View File

@@ -1,21 +1,21 @@
import org.springframework.cloud.contract.spec.Contract
/*
* Copyright 2013-2019 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.springframework.cloud.contract.spec.Contract
Contract.make {
request {
method('PUT')

View File

@@ -1,21 +1,21 @@
import org.springframework.cloud.contract.spec.Contract
/*
* Copyright 2013-2016 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.springframework.cloud.contract.spec.Contract
(1..2).collect { int index ->
Contract.make {
request {
@@ -29,4 +29,4 @@ import org.springframework.cloud.contract.spec.Contract
status OK()
}
}
}
}

View File

@@ -1,21 +1,21 @@
import org.springframework.cloud.contract.spec.Contract
/*
* Copyright 2013-2016 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.springframework.cloud.contract.spec.Contract
(1..2).collect { int index ->
Contract.make {
name("shouldHaveIndex${index}")
@@ -30,4 +30,4 @@ import org.springframework.cloud.contract.spec.Contract
status OK()
}
}
}
}

View File

@@ -1,21 +1,21 @@
import org.springframework.cloud.contract.spec.Contract
/*
* Copyright 2013-2019 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.springframework.cloud.contract.spec.Contract
Contract.make {
request {
method('PUT')

View File

@@ -1,47 +1,47 @@
import org.springframework.cloud.contract.spec.Contract
/*
* Copyright 2013-2018 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import org.springframework.cloud.contract.spec.Contract
[
Contract.make {
name("1_scenario_multiple")
request {
method('PUT')
headers {
header 'Content-Type': 'application/json'
}
url $(consumer('/[0-9]{2}'), producer('/12'))
}
response {
status OK()
}
},
Contract.make {
name("2_scenario_multiple")
request {
method('PUT')
headers {
header 'Content-Type': 'application/json'
}
url $(consumer('/[0-9]{2}'), producer('/12'))
}
response {
status OK()
Contract.make {
name("1_scenario_multiple")
request {
method('PUT')
headers {
header 'Content-Type': 'application/json'
}
url $(consumer('/[0-9]{2}'), producer('/12'))
}
response {
status OK()
}
},
Contract.make {
name("2_scenario_multiple")
request {
method('PUT')
headers {
header 'Content-Type': 'application/json'
}
url $(consumer('/[0-9]{2}'), producer('/12'))
}
response {
status OK()
}
}
]

View File

@@ -1,21 +1,21 @@
import org.springframework.cloud.contract.spec.Contract
/*
* Copyright 2013-2019 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.springframework.cloud.contract.spec.Contract
Contract.make {
request {
method('PUT')

View File

@@ -1,21 +1,21 @@
import org.springframework.cloud.contract.spec.Contract
/*
* Copyright 2013-2019 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.springframework.cloud.contract.spec.Contract
Contract.make {
request {
method('PUT')