Merge pull request #192 from Codearte/issues/182-scenarios
Provide support for scenarios. Fix #182
This commit is contained in:
@@ -2,12 +2,16 @@ package io.codearte.accurest.wiremock
|
||||
|
||||
import groovy.transform.CompileStatic
|
||||
import io.codearte.accurest.dsl.WireMockStubStrategy
|
||||
import io.codearte.accurest.file.Contract
|
||||
|
||||
import java.nio.charset.StandardCharsets
|
||||
|
||||
@CompileStatic
|
||||
class DslToWireMockClientConverter extends DslToWireMockConverter {
|
||||
|
||||
@Override
|
||||
String convertContent(String dslBody) {
|
||||
return new WireMockStubStrategy(createGroovyDSLfromStringContent(dslBody)).toWireMockClientStub()
|
||||
String convertContent(String rootName, Contract contract) {
|
||||
String dslContent = contract.path.getText(StandardCharsets.UTF_8.toString())
|
||||
return new WireMockStubStrategy(rootName, contract, createGroovyDSLfromStringContent(dslContent)).toWireMockClientStub()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.codearte.accurest.wiremock
|
||||
|
||||
import com.google.common.collect.Multimap
|
||||
import groovy.io.FileType
|
||||
import com.google.common.collect.ListMultimap
|
||||
import groovy.transform.CompileStatic
|
||||
import groovy.util.logging.Slf4j
|
||||
import io.codearte.accurest.config.AccurestConfigProperties
|
||||
@@ -27,19 +26,21 @@ class RecursiveFilesConverter {
|
||||
|
||||
void processFiles() {
|
||||
ContractFileScanner scanner = new ContractFileScanner(properties.contractsDslDir, properties.excludedFiles as Set, [] as Set)
|
||||
Multimap<Path, Contract> contracts = scanner.findContracts()
|
||||
contracts.values().each { Contract contract ->
|
||||
File sourceFile = contract.path.toFile()
|
||||
try {
|
||||
if (!singleFileConverter.canHandleFileName(sourceFile.name)) {
|
||||
return
|
||||
ListMultimap<Path, Contract> contracts = scanner.findContracts()
|
||||
contracts.asMap().entrySet().each { entry ->
|
||||
entry.value.each { Contract contract ->
|
||||
File sourceFile = contract.path.toFile()
|
||||
try {
|
||||
if (!singleFileConverter.canHandleFileName(sourceFile.name)) {
|
||||
return
|
||||
}
|
||||
String convertedContent = singleFileConverter.convertContent(entry.key.last().toString(), contract)
|
||||
Path absoluteTargetPath = createAndReturnTargetDirectory(sourceFile)
|
||||
File newGroovyFile = createTargetFileWithProperName(absoluteTargetPath, sourceFile)
|
||||
newGroovyFile.setText(convertedContent, StandardCharsets.UTF_8.toString())
|
||||
} catch (Exception e) {
|
||||
throw new ConversionAccurestException("Unable to make convertion of ${sourceFile.name}", e)
|
||||
}
|
||||
String convertedContent = singleFileConverter.convertContent(sourceFile.getText(StandardCharsets.UTF_8.toString()))
|
||||
Path absoluteTargetPath = createAndReturnTargetDirectory(sourceFile)
|
||||
File newGroovyFile = createTargetFileWithProperName(absoluteTargetPath, sourceFile)
|
||||
newGroovyFile.setText(convertedContent, StandardCharsets.UTF_8.toString())
|
||||
} catch (Exception e) {
|
||||
throw new ConversionAccurestException("Unable to make convertion of ${sourceFile.name}", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
package io.codearte.accurest.wiremock
|
||||
|
||||
import groovy.transform.CompileStatic
|
||||
import io.codearte.accurest.file.Contract
|
||||
|
||||
@CompileStatic
|
||||
interface SingleFileConverter {
|
||||
|
||||
boolean canHandleFileName(String fileName)
|
||||
|
||||
String convertContent(String content)
|
||||
String convertContent(String rootName, Contract content)
|
||||
|
||||
String generateOutputFileNameForInput(String inputFileName)
|
||||
}
|
||||
@@ -1,15 +1,22 @@
|
||||
package io.codearte.accurest.wiremock
|
||||
|
||||
import io.codearte.accurest.file.Contract
|
||||
import org.junit.Rule
|
||||
import org.junit.rules.TemporaryFolder
|
||||
import org.skyscreamer.jsonassert.JSONAssert
|
||||
import spock.lang.Specification
|
||||
|
||||
class DslToWireMockClientConverterSpec extends Specification {
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder tmpFolder = new TemporaryFolder();
|
||||
|
||||
def "should convert DSL file to WireMock JSON"() {
|
||||
given:
|
||||
def converter = new DslToWireMockClientConverter()
|
||||
and:
|
||||
String dslBody = """
|
||||
File file = tmpFolder.newFile("dsl1.groovy")
|
||||
file.write("""
|
||||
io.codearte.accurest.dsl.GroovyDsl.make {
|
||||
request {
|
||||
method('PUT')
|
||||
@@ -19,9 +26,9 @@ class DslToWireMockClientConverterSpec extends Specification {
|
||||
status 200
|
||||
}
|
||||
}
|
||||
"""
|
||||
""")
|
||||
when:
|
||||
String json = converter.convertContent(dslBody)
|
||||
String json = converter.convertContent("Test", new Contract(file.toPath(), false, 0, null))
|
||||
then:
|
||||
JSONAssert.assertEquals('''
|
||||
{"request":{"method":"PUT","urlPattern":"/[0-9]{2}"},"response":{"status":200}}
|
||||
@@ -33,7 +40,8 @@ class DslToWireMockClientConverterSpec extends Specification {
|
||||
given:
|
||||
def converter = new DslToWireMockClientConverter()
|
||||
and:
|
||||
String dslBody = """
|
||||
File file = tmpFolder.newFile("dsl2.groovy")
|
||||
file.write("""
|
||||
io.codearte.accurest.dsl.GroovyDsl.make {
|
||||
request {
|
||||
method 'PUT'
|
||||
@@ -77,9 +85,9 @@ class DslToWireMockClientConverterSpec extends Specification {
|
||||
status 200
|
||||
}
|
||||
}
|
||||
"""
|
||||
""")
|
||||
when:
|
||||
String json = converter.convertContent(dslBody)
|
||||
String json = converter.convertContent("Test", new Contract(file.toPath(), false, 0, null))
|
||||
then:
|
||||
JSONAssert.assertEquals('''
|
||||
{
|
||||
|
||||
@@ -73,7 +73,7 @@ class RecursiveFilesConverterSpec extends Specification {
|
||||
and:
|
||||
def singleFileConverterStub = Stub(SingleFileConverter)
|
||||
singleFileConverterStub.canHandleFileName(_) >> { true }
|
||||
singleFileConverterStub.convertContent(_) >> { throw new NullPointerException("Test conversion error") }
|
||||
singleFileConverterStub.convertContent(_, _) >> { throw new NullPointerException("Test conversion error") }
|
||||
singleFileConverterStub.generateOutputFileNameForInput(_) >> { String inputFileName -> "${inputFileName}2" }
|
||||
AccurestConfigProperties properties = new AccurestConfigProperties()
|
||||
properties.contractsDslDir = tmpFolder.root
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package io.codearte.accurest.wiremock
|
||||
|
||||
import io.codearte.accurest.file.Contract
|
||||
import spock.lang.Specification
|
||||
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
|
||||
class WiremockScenarioConverterSpec extends Specification {
|
||||
|
||||
def "should generate first scenario step"() {
|
||||
given:
|
||||
DslToWireMockClientConverter converter = new DslToWireMockClientConverter()
|
||||
Path dsl = Paths.get(this.getClass().getResource("/converter/scenario/main_scenario/01_login.groovy").toURI())
|
||||
when:
|
||||
String content = converter.convertContent("Test", new Contract(dsl, false, 3, 0))
|
||||
then:
|
||||
content.contains('"requiredScenarioState" : "Started"')
|
||||
content.contains('"newScenarioState" : "Step1"')
|
||||
content.contains('"scenarioName" : "Scenario_Test"')
|
||||
}
|
||||
|
||||
def "should generate mid scenario step"() {
|
||||
given:
|
||||
DslToWireMockClientConverter converter = new DslToWireMockClientConverter()
|
||||
Path dsl = Paths.get(this.getClass().getResource("/converter/scenario/main_scenario/02_showCart.groovy").toURI())
|
||||
when:
|
||||
String content = converter.convertContent("Test", new Contract(dsl, false, 3, 1))
|
||||
then:
|
||||
content.contains('"requiredScenarioState" : "Step1"')
|
||||
content.contains('"newScenarioState" : "Step2"')
|
||||
content.contains('"scenarioName" : "Scenario_Test"')
|
||||
}
|
||||
|
||||
def "should generate last scenario step"() {
|
||||
given:
|
||||
DslToWireMockClientConverter converter = new DslToWireMockClientConverter()
|
||||
Path dsl = Paths.get(this.getClass().getResource("/converter/scenario/main_scenario/03_logout.groovy").toURI())
|
||||
when:
|
||||
String content = converter.convertContent("Test", new Contract(dsl, false, 3, 2))
|
||||
then:
|
||||
content.contains('"requiredScenarioState" : "Step2"')
|
||||
!content.contains('"newScenarioState"')
|
||||
content.contains('"scenarioName" : "Scenario_Test"')
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
io.codearte.accurest.dsl.GroovyDsl.make {
|
||||
request {
|
||||
method('POST')
|
||||
url '/login'
|
||||
}
|
||||
response {
|
||||
status 200
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
io.codearte.accurest.dsl.GroovyDsl.make {
|
||||
request {
|
||||
method('GET')
|
||||
url '/cart'
|
||||
}
|
||||
response {
|
||||
status 200
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
io.codearte.accurest.dsl.GroovyDsl.make {
|
||||
request {
|
||||
method('POST')
|
||||
url '/logout'
|
||||
}
|
||||
response {
|
||||
status 200
|
||||
}
|
||||
}
|
||||
@@ -21,8 +21,7 @@ class SingleTestGenerator {
|
||||
|
||||
@PackageScope
|
||||
String buildClass(Collection<Contract> listOfFiles, String className, String classPackage) {
|
||||
ClassBuilder clazz = createClass(capitalize(className), classPackage,
|
||||
configProperties)
|
||||
ClassBuilder clazz = createClass(capitalize(className), classPackage, configProperties)
|
||||
|
||||
if (configProperties.imports) {
|
||||
configProperties.imports.each {
|
||||
@@ -30,8 +29,8 @@ class SingleTestGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
if (listOfFiles.ignored.find {it}) {
|
||||
clazz.addImport("org.junit.Ignore")
|
||||
if (listOfFiles.ignored.find { it }) {
|
||||
clazz.addImport(configProperties.targetFramework.getIgnoreClass())
|
||||
}
|
||||
|
||||
if (configProperties.staticImports) {
|
||||
@@ -40,6 +39,11 @@ class SingleTestGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
if (isScenarioClass(listOfFiles)) {
|
||||
clazz.addImport(configProperties.targetFramework.getOrderAnnotationImport())
|
||||
clazz.addClassLevelAnnotation(configProperties.targetFramework.getOrderAnnotation())
|
||||
}
|
||||
|
||||
if (configProperties.testMode == TestMode.JAXRSCLIENT) {
|
||||
clazz.addStaticImport('javax.ws.rs.client.Entity.*')
|
||||
} else if (configProperties.testMode == TestMode.MOCKMVC) {
|
||||
@@ -66,10 +70,14 @@ class SingleTestGenerator {
|
||||
return clazz.build()
|
||||
}
|
||||
|
||||
private boolean isScenarioClass(Collection<Contract> listOfFiles) {
|
||||
listOfFiles.find({ it.order != null }) != null
|
||||
}
|
||||
|
||||
private ClassBuilder addJsonPathRelatedImports(ClassBuilder clazz) {
|
||||
clazz.addImport(['com.jayway.jsonpath.DocumentContext',
|
||||
'com.jayway.jsonpath.JsonPath',
|
||||
'net.minidev.json.JSONArray'])
|
||||
'com.jayway.jsonpath.JsonPath',
|
||||
'net.minidev.json.JSONArray'])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package io.codearte.accurest
|
||||
|
||||
import com.google.common.collect.Multimap
|
||||
import com.google.common.collect.ListMultimap
|
||||
import groovy.transform.PackageScope
|
||||
import io.codearte.accurest.config.AccurestConfigProperties
|
||||
import io.codearte.accurest.file.Contract
|
||||
@@ -53,7 +53,7 @@ class TestGenerator {
|
||||
|
||||
@PackageScope
|
||||
void generateTestClasses(final String basePackageName) {
|
||||
Multimap<Path, Contract> contracts = contractFileScanner.findContracts()
|
||||
ListMultimap<Path, Contract> contracts = contractFileScanner.findContracts()
|
||||
contracts.asMap().entrySet().each {
|
||||
Map.Entry<Path, Collection<Contract>> entry -> processIncludedDirectory(relativizeContractPath(entry), entry.getValue(), basePackageName)
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ class ClassBuilder {
|
||||
private final List<String> staticImports = []
|
||||
private final List<String> rules = []
|
||||
private final List<MethodBuilder> methods = []
|
||||
private final List<String> classLevelAnnotations = []
|
||||
private final TestFramework lang
|
||||
|
||||
private ClassBuilder(String className, String packageName, String baseClass, TestFramework lang) {
|
||||
@@ -83,6 +84,10 @@ class ClassBuilder {
|
||||
clazz.addEmptyLine()
|
||||
}
|
||||
|
||||
classLevelAnnotations.sort().each {
|
||||
clazz.addLine(it)
|
||||
}
|
||||
|
||||
def classLine = "${lang.classModifier}class $className"
|
||||
if (baseClass) {
|
||||
classLine += " extends $baseClass"
|
||||
@@ -107,4 +112,8 @@ class ClassBuilder {
|
||||
clazz.addLine('}')
|
||||
clazz.toString()
|
||||
}
|
||||
|
||||
void addClassLevelAnnotation(String annotation) {
|
||||
classLevelAnnotations << annotation
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class MethodBuilder {
|
||||
if (ignored) {
|
||||
blockBuilder.addLine('@Ignore')
|
||||
}
|
||||
blockBuilder.addLine(configProperties.targetFramework.methodModifier + "$methodName() {")
|
||||
blockBuilder.addLine(configProperties.targetFramework.methodModifier + "validate_$methodName() {")
|
||||
getMethodBodyBuilder().appendTo(blockBuilder)
|
||||
blockBuilder.addLine('}')
|
||||
}
|
||||
|
||||
@@ -4,21 +4,28 @@ package io.codearte.accurest.config
|
||||
* @author Jakub Kubrynski
|
||||
*/
|
||||
enum TestFramework {
|
||||
JUNIT("public ", "public void ", ";", ".java", "Test"),
|
||||
SPOCK("", "def ", "", ".groovy", "Spec")
|
||||
JUNIT("public ", "public void ", ";", ".java", "Test", "org.junit.Ignore", "org.junit.FixMethodOrder", "@FixMethodOrder(MethodSorters.NAME_ASCENDING)"),
|
||||
SPOCK("", "def ", "", ".groovy", "Spec", "spock.lang.Ignore", "spock.lang.Stepwise", "@Stepwise")
|
||||
|
||||
private final String classModifier
|
||||
private final String methodModifier
|
||||
private final String lineSuffix
|
||||
private final String classExtension;
|
||||
private final String classNameSuffix;
|
||||
private final String ignoreClass
|
||||
private final String orderAnnotationImport
|
||||
private final String orderAnnotation
|
||||
|
||||
TestFramework(String classModifier, String methodModifier, String lineSuffix, String classExtension, String classNameSuffix) {
|
||||
TestFramework(String classModifier, String methodModifier, String lineSuffix, String classExtension, String classNameSuffix,
|
||||
String ignoreClass, String orderAnnotationImport, String orderAnnotation) {
|
||||
this.classModifier = classModifier
|
||||
this.lineSuffix = lineSuffix
|
||||
this.methodModifier = methodModifier
|
||||
this.classExtension = classExtension
|
||||
this.classNameSuffix = classNameSuffix
|
||||
this.ignoreClass = ignoreClass
|
||||
this.orderAnnotationImport = orderAnnotationImport
|
||||
this.orderAnnotation = orderAnnotation
|
||||
}
|
||||
|
||||
String getClassModifier() {
|
||||
@@ -40,4 +47,16 @@ enum TestFramework {
|
||||
String getClassNameSuffix() {
|
||||
return classNameSuffix
|
||||
}
|
||||
|
||||
String getIgnoreClass() {
|
||||
return ignoreClass
|
||||
}
|
||||
|
||||
String getOrderAnnotationImport() {
|
||||
return orderAnnotationImport
|
||||
}
|
||||
|
||||
String getOrderAnnotation() {
|
||||
return orderAnnotation
|
||||
}
|
||||
}
|
||||
@@ -5,15 +5,22 @@ import com.github.tomakehurst.wiremock.matching.RequestPattern
|
||||
import com.github.tomakehurst.wiremock.stubbing.StubMapping
|
||||
import groovy.transform.CompileDynamic
|
||||
import groovy.transform.CompileStatic
|
||||
import io.codearte.accurest.file.Contract
|
||||
|
||||
@CompileStatic
|
||||
class WireMockStubStrategy {
|
||||
|
||||
private static final String STEP_START = "Started"
|
||||
private static final String STEP_PREFIX = "Step"
|
||||
private final WireMockRequestStubStrategy wireMockRequestStubStrategy
|
||||
private final WireMockResponseStubStrategy wireMockResponseStubStrategy
|
||||
private final Integer priority
|
||||
private final Contract contract
|
||||
private final String rootName
|
||||
|
||||
WireMockStubStrategy(GroovyDsl groovyDsl) {
|
||||
WireMockStubStrategy(String rootName, Contract contract, GroovyDsl groovyDsl) {
|
||||
this.rootName = rootName
|
||||
this.contract = contract
|
||||
this.wireMockRequestStubStrategy = new WireMockRequestStubStrategy(groovyDsl)
|
||||
this.wireMockResponseStubStrategy = new WireMockResponseStubStrategy(groovyDsl)
|
||||
this.priority = groovyDsl.priority
|
||||
@@ -29,6 +36,15 @@ class WireMockStubStrategy {
|
||||
}
|
||||
stubMapping.request = request
|
||||
stubMapping.response = response
|
||||
|
||||
if (contract.order != null) {
|
||||
stubMapping.scenarioName = "Scenario_" + rootName
|
||||
stubMapping.requiredScenarioState = contract.order == 0 ? STEP_START : STEP_PREFIX + contract.order
|
||||
if (contract.order < contract.groupSize - 1) {
|
||||
stubMapping.newScenarioState = STEP_PREFIX + (contract.order + 1)
|
||||
}
|
||||
}
|
||||
|
||||
return StubMapping.buildJsonStringFor(stubMapping)
|
||||
}
|
||||
}
|
||||
@@ -8,10 +8,23 @@ import java.nio.file.Path
|
||||
class Contract {
|
||||
final Path path;
|
||||
final boolean ignored;
|
||||
final int groupSize
|
||||
final Integer order;
|
||||
|
||||
Contract(Path path, boolean ignored) {
|
||||
Contract(Path path, boolean ignored, int groupSize, Integer order) {
|
||||
this.groupSize = groupSize
|
||||
this.path = path
|
||||
this.ignored = ignored
|
||||
this.order = order
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Contract{" +
|
||||
"fileName=" + path.fileName +
|
||||
", ignored=" + ignored +
|
||||
", groupSize=" + groupSize +
|
||||
", order=" + order +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.codearte.accurest.file
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap
|
||||
import com.google.common.collect.ListMultimap
|
||||
import com.google.common.collect.Multimap
|
||||
import org.apache.commons.io.FilenameUtils
|
||||
|
||||
@@ -8,13 +9,15 @@ import java.nio.file.FileSystem
|
||||
import java.nio.file.FileSystems
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.PathMatcher
|
||||
import java.util.regex.Pattern
|
||||
|
||||
/**
|
||||
* @author Jakub Kubrynski
|
||||
*/
|
||||
class ContractFileScanner {
|
||||
|
||||
private final String MATCH_PREFIX = "glob:"
|
||||
private static final String MATCH_PREFIX = "glob:"
|
||||
private static final Pattern SCENARIO_STEP_FILENAME_PATTERN = Pattern.compile("[0-9]+_.*")
|
||||
private final File baseDir
|
||||
private final Set<PathMatcher> excludeMatchers
|
||||
private final Set<PathMatcher> ignoreMatchers
|
||||
@@ -32,26 +35,37 @@ class ContractFileScanner {
|
||||
}) as Set
|
||||
}
|
||||
|
||||
Multimap<Path, Contract> findContracts() {
|
||||
Multimap<Path, Contract> result = ArrayListMultimap.create()
|
||||
ListMultimap<Path, Contract> findContracts() {
|
||||
ListMultimap<Path, Contract> result = ArrayListMultimap.create()
|
||||
appendRecursively(baseDir, result)
|
||||
return result
|
||||
}
|
||||
|
||||
private void appendRecursively(File baseDir, Multimap<Path, Contract> result) {
|
||||
for (File file : baseDir.listFiles()) {
|
||||
if (matchesPattern(file, excludeMatchers)) {
|
||||
break;
|
||||
}
|
||||
if (isContractFile(file)) {
|
||||
Path path = file.toPath()
|
||||
result.put(file.parentFile.toPath(), new Contract(path, matchesPattern(file, ignoreMatchers)))
|
||||
} else {
|
||||
appendRecursively(file, result)
|
||||
private void appendRecursively(File baseDir, ListMultimap<Path, Contract> result) {
|
||||
File[] files = baseDir.listFiles()
|
||||
if (!files) {
|
||||
return;
|
||||
}
|
||||
files.sort().eachWithIndex { File file, int index ->
|
||||
if (!matchesPattern(file, excludeMatchers)) {
|
||||
if (isContractFile(file)) {
|
||||
Path path = file.toPath()
|
||||
Integer order = null
|
||||
if (hasScenarioFilenamePattern(path)) {
|
||||
order = index
|
||||
}
|
||||
result.put(file.parentFile.toPath(), new Contract(path, matchesPattern(file, ignoreMatchers), files.size(), order))
|
||||
} else {
|
||||
appendRecursively(file, result)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasScenarioFilenamePattern(Path path) {
|
||||
SCENARIO_STEP_FILENAME_PATTERN.matcher(path.fileName.toString()).matches()
|
||||
}
|
||||
|
||||
boolean matchesPattern(File file, Set<PathMatcher> excludeMatchers) {
|
||||
for (PathMatcher matcher : excludeMatchers) {
|
||||
if (matcher.matches(file.toPath())) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package io.codearte.accurest.builder
|
||||
import io.codearte.accurest.dsl.GroovyDsl
|
||||
import io.codearte.accurest.dsl.WireMockStubStrategy
|
||||
import io.codearte.accurest.dsl.WireMockStubVerifier
|
||||
import io.codearte.accurest.file.Contract
|
||||
import spock.lang.Issue
|
||||
import spock.lang.Specification
|
||||
|
||||
@@ -31,7 +32,7 @@ class JaxRsClientSpockMethodBuilderSpec extends Specification implements WireMoc
|
||||
blockBuilder.toString().contains("\$[?(@.property1 == 'a')]")
|
||||
blockBuilder.toString().contains("\$[?(@.property2 == 'b')]")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
@Issue("#187")
|
||||
@@ -60,7 +61,7 @@ class JaxRsClientSpockMethodBuilderSpec extends Specification implements WireMoc
|
||||
blockBuilder.toString().contains("\$[?(@.property2 == null)]")
|
||||
blockBuilder.toString().contains("\$[?(@.property3 == false)]")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
@Issue("#79")
|
||||
@@ -91,7 +92,7 @@ class JaxRsClientSpockMethodBuilderSpec extends Specification implements WireMoc
|
||||
blockBuilder.toString().contains("\$.property2[*][?(@.a == 'sth')]")
|
||||
blockBuilder.toString().contains("\$.property2[*][?(@.b == 'sthElse')]")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
@Issue("#82")
|
||||
@@ -116,7 +117,7 @@ class JaxRsClientSpockMethodBuilderSpec extends Specification implements WireMoc
|
||||
then:
|
||||
blockBuilder.toString().contains("entity('{\"items\":[\"HOP\"]}', 'application/json')")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
@Issue("#88")
|
||||
@@ -141,7 +142,7 @@ class JaxRsClientSpockMethodBuilderSpec extends Specification implements WireMoc
|
||||
then:
|
||||
blockBuilder.toString().contains("entity('property1=VAL1', 'application/octet-stream')")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
def "should generate assertions for array in response body"() {
|
||||
@@ -170,7 +171,7 @@ class JaxRsClientSpockMethodBuilderSpec extends Specification implements WireMoc
|
||||
blockBuilder.toString().contains("\$[*][?(@.property1 == 'a')]")
|
||||
blockBuilder.toString().contains("\$[*][?(@.property2 == 'b')]")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
def "should generate assertions for array inside response body element"() {
|
||||
@@ -198,7 +199,7 @@ class JaxRsClientSpockMethodBuilderSpec extends Specification implements WireMoc
|
||||
blockBuilder.toString().contains("\$.property1[*][?(@.property3 == 'test2')]")
|
||||
blockBuilder.toString().contains("\$.property1[*][?(@.property2 == 'test1')]")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
def "should generate assertions for nested objects in response body"() {
|
||||
@@ -226,7 +227,7 @@ class JaxRsClientSpockMethodBuilderSpec extends Specification implements WireMoc
|
||||
blockBuilder.toString().contains("\$.property2[?(@.property3 == 'b')]")
|
||||
blockBuilder.toString().contains("\$[?(@.property1 == 'a')]")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
def "should generate regex assertions for map objects in response body"() {
|
||||
@@ -260,7 +261,7 @@ class JaxRsClientSpockMethodBuilderSpec extends Specification implements WireMoc
|
||||
blockBuilder.toString().contains("\$[?(@.property2 =~ /[0-9]{3}/)]")
|
||||
blockBuilder.toString().contains("\$[?(@.property1 == 'a')]")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
def "should generate regex assertions for string objects in response body"() {
|
||||
@@ -288,7 +289,7 @@ class JaxRsClientSpockMethodBuilderSpec extends Specification implements WireMoc
|
||||
blockBuilder.toString().contains("\$[?(@.property2 =~ /[0-9]{3}/)]")
|
||||
blockBuilder.toString().contains("\$[?(@.property1 == 'a')]")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
def "should ignore 'Accept' header and use 'request' method"() {
|
||||
@@ -312,7 +313,7 @@ class JaxRsClientSpockMethodBuilderSpec extends Specification implements WireMoc
|
||||
then:
|
||||
blockBuilder.toString().contains("request('text/plain')")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
def "should ignore 'Content-Type' header and use 'entity' method"() {
|
||||
@@ -340,7 +341,7 @@ class JaxRsClientSpockMethodBuilderSpec extends Specification implements WireMoc
|
||||
blockBuilder.toString().contains("header('Timer', '123')")
|
||||
!blockBuilder.toString().contains("header('Content-Type'")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
def "should generate a call with an url path and query parameters"() {
|
||||
@@ -390,7 +391,7 @@ class JaxRsClientSpockMethodBuilderSpec extends Specification implements WireMoc
|
||||
spockTest.contains('$[?(@.property2 == \'b\')]')
|
||||
spockTest.contains('$[?(@.property1 == \'a\')]')
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
@Issue('#169')
|
||||
@@ -441,7 +442,7 @@ class JaxRsClientSpockMethodBuilderSpec extends Specification implements WireMoc
|
||||
spockTest.contains('$[?(@.property2 == \'b\')]')
|
||||
spockTest.contains('$[?(@.property1 == \'a\')]')
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
def "should generate test for empty body"() {
|
||||
@@ -464,7 +465,7 @@ class JaxRsClientSpockMethodBuilderSpec extends Specification implements WireMoc
|
||||
then:
|
||||
spockTest.contains("entity('', 'application/octet-stream')")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
def "should generate test for String in response body"() {
|
||||
@@ -488,7 +489,7 @@ class JaxRsClientSpockMethodBuilderSpec extends Specification implements WireMoc
|
||||
spockTest.contains('String responseAsString = response.readEntity(String)')
|
||||
spockTest.contains('responseBody == "test"')
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
@Issue('#171')
|
||||
@@ -517,7 +518,7 @@ class JaxRsClientSpockMethodBuilderSpec extends Specification implements WireMoc
|
||||
then:
|
||||
spockTest.contains(".method('GET')")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package io.codearte.accurest.builder
|
||||
import io.codearte.accurest.dsl.GroovyDsl
|
||||
import io.codearte.accurest.dsl.WireMockStubStrategy
|
||||
import io.codearte.accurest.dsl.WireMockStubVerifier
|
||||
import io.codearte.accurest.file.Contract
|
||||
import spock.lang.Issue
|
||||
import spock.lang.Specification
|
||||
import spock.lang.Unroll
|
||||
@@ -37,7 +38,7 @@ class MockMvcSpockMethodBuilderSpec extends Specification implements WireMockStu
|
||||
blockBuilder.toString().contains("\$[?(@.property1 == 'a')]")
|
||||
blockBuilder.toString().contains("\$[?(@.property2 == 'b')]")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
@Issue("#187")
|
||||
@@ -66,7 +67,7 @@ class MockMvcSpockMethodBuilderSpec extends Specification implements WireMockStu
|
||||
blockBuilder.toString().contains("\$[?(@.property2 == null)]")
|
||||
blockBuilder.toString().contains("\$[?(@.property3 == false)]")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
@Issue("#79")
|
||||
@@ -97,7 +98,7 @@ class MockMvcSpockMethodBuilderSpec extends Specification implements WireMockStu
|
||||
blockBuilder.toString().contains("\$.property2[*][?(@.a == 'sth')]")
|
||||
blockBuilder.toString().contains("\$.property2[*][?(@.b == 'sthElse')]")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
@Issue("#82")
|
||||
@@ -122,7 +123,7 @@ class MockMvcSpockMethodBuilderSpec extends Specification implements WireMockStu
|
||||
then:
|
||||
blockBuilder.toString().contains(".body('''{\"items\":[\"HOP\"]}''')")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
@Issue("#88")
|
||||
@@ -147,7 +148,7 @@ class MockMvcSpockMethodBuilderSpec extends Specification implements WireMockStu
|
||||
then:
|
||||
blockBuilder.toString().contains(".body('''property1=VAL1''')")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
@Issue("185")
|
||||
@@ -176,7 +177,7 @@ class MockMvcSpockMethodBuilderSpec extends Specification implements WireMockStu
|
||||
blockBuilder.toString().contains("\$.property[?(@.7 == 0.0)]")
|
||||
blockBuilder.toString().contains("\$.property[?(@.14 == 0.0)]")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
def "should generate assertions for array in response body"() {
|
||||
@@ -205,7 +206,7 @@ class MockMvcSpockMethodBuilderSpec extends Specification implements WireMockStu
|
||||
blockBuilder.toString().contains("\$[*][?(@.property1 == 'a')]")
|
||||
blockBuilder.toString().contains("\$[*][?(@.property2 == 'b')]")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
def "should generate assertions for array inside response body element"() {
|
||||
@@ -233,7 +234,7 @@ class MockMvcSpockMethodBuilderSpec extends Specification implements WireMockStu
|
||||
blockBuilder.toString().contains("\$.property1[*][?(@.property3 == 'test2')]")
|
||||
blockBuilder.toString().contains("\$.property1[*][?(@.property2 == 'test1')]")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
def "should generate assertions for nested objects in response body"() {
|
||||
@@ -261,7 +262,7 @@ class MockMvcSpockMethodBuilderSpec extends Specification implements WireMockStu
|
||||
blockBuilder.toString().contains("\$.property2[?(@.property3 == 'b')]")
|
||||
blockBuilder.toString().contains("\$[?(@.property1 == 'a')]")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
def "should generate regex assertions for map objects in response body"() {
|
||||
@@ -295,7 +296,7 @@ class MockMvcSpockMethodBuilderSpec extends Specification implements WireMockStu
|
||||
blockBuilder.toString().contains("\$[?(@.property2 =~ /[0-9]{3}/)]")
|
||||
blockBuilder.toString().contains("\$[?(@.property1 == 'a')]")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
def "should generate regex assertions for string objects in response body"() {
|
||||
@@ -323,7 +324,7 @@ class MockMvcSpockMethodBuilderSpec extends Specification implements WireMockStu
|
||||
blockBuilder.toString().contains("\$[?(@.property2 =~ /[0-9]{3}/)]")
|
||||
blockBuilder.toString().contains("\$[?(@.property1 == 'a')]")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
@Issue(["#126", "#143"])
|
||||
@@ -349,7 +350,7 @@ class MockMvcSpockMethodBuilderSpec extends Specification implements WireMockStu
|
||||
then:
|
||||
blockBuilder.toString().contains("\$[?(@.property =~ /\\d+/)]")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
def "should generate a call with an url path and query parameters"() {
|
||||
@@ -392,7 +393,7 @@ class MockMvcSpockMethodBuilderSpec extends Specification implements WireMockStu
|
||||
spockTest.contains('$[?(@.property2 == \'b\')]')
|
||||
spockTest.contains('$[?(@.property1 == \'a\')]')
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
@Issue('#169')
|
||||
@@ -436,7 +437,7 @@ class MockMvcSpockMethodBuilderSpec extends Specification implements WireMockStu
|
||||
spockTest.contains('$[?(@.property2 == \'b\')]')
|
||||
spockTest.contains('$[?(@.property1 == \'a\')]')
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
def "should generate test for empty body"() {
|
||||
@@ -459,7 +460,7 @@ class MockMvcSpockMethodBuilderSpec extends Specification implements WireMockStu
|
||||
then:
|
||||
spockTest.contains(".body('''''')")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
def "should generate test for String in response body"() {
|
||||
@@ -483,7 +484,7 @@ class MockMvcSpockMethodBuilderSpec extends Specification implements WireMockStu
|
||||
spockTest.contains('def responseBody = (response.body.asString())')
|
||||
spockTest.contains('responseBody == "test"')
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
@Issue('113')
|
||||
@@ -518,7 +519,7 @@ class MockMvcSpockMethodBuilderSpec extends Specification implements WireMockStu
|
||||
then:
|
||||
spockTest.contains('''response.header('Location') ==~ java.util.regex.Pattern.compile('http://localhost/partners/[0-9]+/users/[0-9]+')''')
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
@Issue('115')
|
||||
@@ -553,7 +554,7 @@ class MockMvcSpockMethodBuilderSpec extends Specification implements WireMockStu
|
||||
then:
|
||||
spockTest.contains('''response.header('Location') ==~ java.util.regex.Pattern.compile('^((http[s]?|ftp):\\/)\\/?([^:\\/\\s]+)(:[0-9]{1,5})?/partners/[0-9]+/users/[0-9]+')''')
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
def "should work with more complex stuff and jsonpaths"() {
|
||||
@@ -590,7 +591,7 @@ class MockMvcSpockMethodBuilderSpec extends Specification implements WireMockStu
|
||||
spockTest.contains('''$.errors[*][?(@.property == 'bank_account_number')]''')
|
||||
spockTest.contains('''$.errors[*][?(@.message == 'incorrect_format')]''')
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
def "should work properly with GString url"() {
|
||||
@@ -619,7 +620,7 @@ class MockMvcSpockMethodBuilderSpec extends Specification implements WireMockStu
|
||||
then:
|
||||
spockTest.contains('''/partners/11/agents/11/customers/09665703Z''')
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy(contractDsl).toWireMockClientStub())
|
||||
stubMappingIsValidWireMockStub(new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub())
|
||||
}
|
||||
|
||||
def "should resolve properties in GString with regular expression"() {
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.codearte.accurest.dsl
|
||||
|
||||
import groovy.json.JsonBuilder
|
||||
import groovy.json.JsonSlurper
|
||||
import io.codearte.accurest.file.Contract
|
||||
import io.codearte.accurest.util.AssertionUtil
|
||||
import spock.lang.Issue
|
||||
import spock.lang.Specification
|
||||
@@ -36,7 +37,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
}
|
||||
}
|
||||
when:
|
||||
String wireMockStub = new WireMockStubStrategy(groovyDsl).toWireMockClientStub()
|
||||
String wireMockStub = new WireMockStubStrategy("Test", new Contract(null, false, 0, null), groovyDsl).toWireMockClientStub()
|
||||
then:
|
||||
AssertionUtil.assertThatJsonsAreEqual('''
|
||||
{
|
||||
@@ -81,7 +82,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
}
|
||||
}
|
||||
when:
|
||||
String wireMockStub = new WireMockStubStrategy(groovyDsl).toWireMockClientStub()
|
||||
String wireMockStub = new WireMockStubStrategy("Test", new Contract(null, false, 0, null), groovyDsl).toWireMockClientStub()
|
||||
then:
|
||||
AssertionUtil.assertThatJsonsAreEqual('''
|
||||
{
|
||||
@@ -129,7 +130,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
}
|
||||
}
|
||||
when:
|
||||
String wireMockStub = new WireMockStubStrategy(groovyDsl).toWireMockClientStub()
|
||||
String wireMockStub = new WireMockStubStrategy("Test", new Contract(null, false, 0, null), groovyDsl).toWireMockClientStub()
|
||||
then:
|
||||
AssertionUtil.assertThatJsonsAreEqual('''
|
||||
{
|
||||
@@ -181,7 +182,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
}
|
||||
}
|
||||
when:
|
||||
String wireMockStub = new WireMockStubStrategy(groovyDsl).toWireMockClientStub()
|
||||
String wireMockStub = new WireMockStubStrategy("Test", new Contract(null, false, 0, null), groovyDsl).toWireMockClientStub()
|
||||
then:
|
||||
AssertionUtil.assertThatJsonsAreEqual(('''
|
||||
{
|
||||
@@ -228,7 +229,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
}
|
||||
}
|
||||
when:
|
||||
String wireMockStub = new WireMockStubStrategy(groovyDsl).toWireMockClientStub()
|
||||
String wireMockStub = new WireMockStubStrategy("Test", new Contract(null, false, 0, null), groovyDsl).toWireMockClientStub()
|
||||
then:
|
||||
AssertionUtil.assertThatJsonsAreEqual('''
|
||||
{
|
||||
@@ -276,7 +277,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
}
|
||||
}
|
||||
when:
|
||||
String wireMockStub = new WireMockStubStrategy(groovyDsl).toWireMockClientStub()
|
||||
String wireMockStub = new WireMockStubStrategy("Test", new Contract(null, false, 0, null), groovyDsl).toWireMockClientStub()
|
||||
then:
|
||||
AssertionUtil.assertThatJsonsAreEqual(('''
|
||||
{
|
||||
@@ -560,7 +561,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
}
|
||||
}
|
||||
when:
|
||||
String wireMockStub = new WireMockStubStrategy(groovyDsl).toWireMockClientStub()
|
||||
String wireMockStub = new WireMockStubStrategy("Test", new Contract(null, false, 0, null), groovyDsl).toWireMockClientStub()
|
||||
then:
|
||||
AssertionUtil.assertThatJsonsAreEqual(('''
|
||||
{
|
||||
@@ -615,7 +616,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
|
||||
}
|
||||
when:
|
||||
String wireMockStub = new WireMockStubStrategy(groovyDsl).toWireMockClientStub()
|
||||
String wireMockStub = new WireMockStubStrategy("Test", new Contract(null, false, 0, null), groovyDsl).toWireMockClientStub()
|
||||
then:
|
||||
AssertionUtil.assertThatJsonsAreEqual(('''
|
||||
{
|
||||
@@ -963,7 +964,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
}
|
||||
}
|
||||
when:
|
||||
String wireMockStub = new WireMockStubStrategy(groovyDsl).toWireMockClientStub()
|
||||
String wireMockStub = new WireMockStubStrategy("Test", new Contract(null, false, 0, null), groovyDsl).toWireMockClientStub()
|
||||
then:
|
||||
AssertionUtil.assertThatJsonsAreEqual(('''
|
||||
{
|
||||
@@ -1136,7 +1137,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
}
|
||||
}
|
||||
when:
|
||||
String wireMockStub = new WireMockStubStrategy(groovyDsl).toWireMockClientStub()
|
||||
String wireMockStub = new WireMockStubStrategy("Test", new Contract(null, false, 0, null), groovyDsl).toWireMockClientStub()
|
||||
then:
|
||||
AssertionUtil.assertThatJsonsAreEqual(('''
|
||||
{
|
||||
@@ -1170,7 +1171,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
}
|
||||
}
|
||||
when:
|
||||
String wireMockStub = new WireMockStubStrategy(groovyDsl).toWireMockClientStub()
|
||||
String wireMockStub = new WireMockStubStrategy("Test", new Contract(null, false, 0, null), groovyDsl).toWireMockClientStub()
|
||||
then:
|
||||
AssertionUtil.assertThatJsonsAreEqual(('''
|
||||
{
|
||||
@@ -1218,7 +1219,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
}
|
||||
}
|
||||
when:
|
||||
String wireMockStub = new WireMockStubStrategy(groovyDsl).toWireMockClientStub()
|
||||
String wireMockStub = new WireMockStubStrategy("Test", new Contract(null, false, 0, null), groovyDsl).toWireMockClientStub()
|
||||
then:
|
||||
AssertionUtil.assertThatJsonsAreEqual(('''
|
||||
{
|
||||
@@ -1269,7 +1270,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
}
|
||||
}
|
||||
when:
|
||||
String wireMockStub = new WireMockStubStrategy(groovyDsl).toWireMockClientStub()
|
||||
String wireMockStub = new WireMockStubStrategy("Test", new Contract(null, false, 0, null), groovyDsl).toWireMockClientStub()
|
||||
then:
|
||||
AssertionUtil.assertThatJsonsAreEqual(('''
|
||||
{
|
||||
@@ -1298,7 +1299,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
@Unroll
|
||||
def 'should generate stub without optional parameters'() {
|
||||
when:
|
||||
String wireMockStub = new WireMockStubStrategy(contractDsl).toWireMockClientStub()
|
||||
String wireMockStub = new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub()
|
||||
then:
|
||||
AssertionUtil.assertThatJsonsAreEqual(('''
|
||||
{
|
||||
@@ -1396,7 +1397,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
}
|
||||
|
||||
String toWireMockClientJsonStub(groovyDsl) {
|
||||
new WireMockStubStrategy(groovyDsl).toWireMockClientStub()
|
||||
new WireMockStubStrategy("Test", new Contract(null, false, 0, null), groovyDsl).toWireMockClientStub()
|
||||
}
|
||||
|
||||
@Issue('180')
|
||||
@@ -1420,7 +1421,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
}
|
||||
}
|
||||
when:
|
||||
String wireMockStub = new WireMockStubStrategy(contractDsl).toWireMockClientStub()
|
||||
String wireMockStub = new WireMockStubStrategy("Test", new Contract(null, false, 0, null), contractDsl).toWireMockClientStub()
|
||||
then:
|
||||
println wireMockStub
|
||||
AssertionUtil.assertThatJsonsAreEqual(('''
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package io.codearte.accurest.dsl
|
||||
|
||||
import com.github.tomakehurst.wiremock.stubbing.StubMapping
|
||||
|
||||
import java.util.regex.Pattern
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.codearte.accurest.file
|
||||
|
||||
import com.google.common.collect.ListMultimap
|
||||
import com.google.common.collect.Multimap
|
||||
import spock.lang.Specification
|
||||
|
||||
@@ -17,7 +18,7 @@ class ContractFileScannerSpec extends Specification {
|
||||
Set<String> ignored = ["other/different/**"] as Set
|
||||
ContractFileScanner scanner = new ContractFileScanner(baseDir, excluded, ignored)
|
||||
when:
|
||||
Multimap<Path, Contract> result = scanner.findContracts()
|
||||
ListMultimap<Path, Contract> result = scanner.findContracts()
|
||||
then:
|
||||
result.keySet().size() == 3
|
||||
result.get(baseDir.toPath().resolve("different")).size() == 1
|
||||
@@ -27,4 +28,18 @@ class ContractFileScannerSpec extends Specification {
|
||||
ignoredSet.size() == 1
|
||||
ignoredSet.ignored == [true]
|
||||
}
|
||||
|
||||
def "should find contracts group in scenario"() {
|
||||
given:
|
||||
File baseDir = new File(this.getClass().getResource("/directory/with/scenario").toURI())
|
||||
ContractFileScanner scanner = new ContractFileScanner(baseDir, [] as Set, [] as Set)
|
||||
when:
|
||||
ListMultimap<Path, Contract> contracts = scanner.findContracts()
|
||||
then:
|
||||
contracts.values().size() == 3
|
||||
contracts.values().find { it.path.fileName.toString().startsWith('01') }.groupSize == 3
|
||||
contracts.values().find { it.path.fileName.toString().startsWith('01') }.order == 0
|
||||
contracts.values().find { it.path.fileName.toString().startsWith('02') }.order == 1
|
||||
contracts.values().find { it.path.fileName.toString().startsWith('03') }.order == 2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package io.codearte.accurest.plugin
|
||||
|
||||
import nebula.test.IntegrationSpec
|
||||
import spock.lang.Stepwise
|
||||
|
||||
@Stepwise
|
||||
class ScenarioProjectSpec extends IntegrationSpec {
|
||||
|
||||
void setup() {
|
||||
copyResources("functionalTest/scenarioProject", "")
|
||||
runTasksSuccessfully('clean') //delete accidental output when previously importing SimpleBoot into Idea to tweak it
|
||||
}
|
||||
|
||||
def "should pass basic flow"() {
|
||||
given:
|
||||
assert fileExists('build.gradle')
|
||||
expect:
|
||||
runTasksSuccessfully('check')
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE")
|
||||
}
|
||||
}
|
||||
|
||||
ext {
|
||||
restAssuredVersion = '2.5.0'
|
||||
spockVersion = '1.0-groovy-2.4'
|
||||
wiremockVersion = '2.0.5-beta'
|
||||
|
||||
accurestStubsBaseDirectory = 'src/test/resources/stubs'
|
||||
}
|
||||
|
||||
subprojects {
|
||||
apply plugin: 'groovy'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile "org.codehaus.groovy:groovy-all:2.4.5"
|
||||
testCompile "org.spockframework:spock-core:$spockVersion"
|
||||
testCompile("junit:junit:4.12")
|
||||
testCompile "com.github.tomakehurst:wiremock:$wiremockVersion"
|
||||
}
|
||||
}
|
||||
|
||||
configure([project(':fraudDetectionService'), project(':loanApplicationService')]) {
|
||||
apply plugin: 'spring-boot'
|
||||
apply plugin: 'accurest'
|
||||
|
||||
ext {
|
||||
wireMockStubsOutputDirRoot = file("${project.buildDir}/production/${project.name}-stubs/")
|
||||
wireMockStubsOutputDir = new File(wireMockStubsOutputDirRoot, 'mappings/')
|
||||
}
|
||||
|
||||
accurest {
|
||||
targetFramework = 'Spock'
|
||||
testMode = 'MockMvc'
|
||||
baseClassForTests = 'com.blogspot.toomuchcoding.MvcSpec'
|
||||
contractsDslDir = file("${project.projectDir.absolutePath}/mappings/")
|
||||
generatedTestSourcesDir = file("${project.buildDir}/generated-sources/")
|
||||
stubsOutputDir = wireMockStubsOutputDir
|
||||
}
|
||||
|
||||
jar {
|
||||
version = '0.0.1'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile("org.springframework.boot:spring-boot-starter-web") {
|
||||
exclude module: "spring-boot-starter-tomcat"
|
||||
}
|
||||
compile("org.springframework.boot:spring-boot-starter-jetty")
|
||||
compile("org.springframework.boot:spring-boot-starter-actuator")
|
||||
|
||||
testRuntime "org.spockframework:spock-spring:$spockVersion"
|
||||
testCompile "org.springframework:spring-test"
|
||||
testCompile "com.jayway.restassured:rest-assured:$restAssuredVersion"
|
||||
testCompile "com.jayway.restassured:spring-mock-mvc:$restAssuredVersion"
|
||||
}
|
||||
|
||||
task cleanup(type: Delete) {
|
||||
delete 'src/test/resources/mappings', 'src/test/resources/stubs'
|
||||
}
|
||||
|
||||
clean.dependsOn('cleanup')
|
||||
|
||||
}
|
||||
|
||||
configure(project(':fraudDetectionService')) {
|
||||
test.dependsOn('generateWireMockClientStubs')
|
||||
}
|
||||
|
||||
configure(project(':loanApplicationService')) {
|
||||
|
||||
task copyCollaboratorStubs(type: Copy) {
|
||||
File fraudBuildDir = project(':fraudDetectionService').buildDir
|
||||
from(new File(fraudBuildDir, "/production/${project(':fraudDetectionService').name}-stubs/"))
|
||||
into "src/test/resources/"
|
||||
}
|
||||
|
||||
generateAccurest.dependsOn('copyCollaboratorStubs')
|
||||
}
|
||||
|
||||
@@ -0,0 +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')
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +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"
|
||||
}""")
|
||||
headers {
|
||||
header('Content-Type': 'application/vnd.fraud.v1+json')
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.blogspot.toomuchcoding.frauddetection;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@EnableAutoConfiguration
|
||||
@ComponentScan
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.blogspot.toomuchcoding.frauddetection;
|
||||
|
||||
import com.blogspot.toomuchcoding.frauddetection.model.FraudCheck;
|
||||
import com.blogspot.toomuchcoding.frauddetection.model.FraudCheckResult;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import static com.blogspot.toomuchcoding.frauddetection.model.FraudCheckStatus.FRAUD;
|
||||
import static com.blogspot.toomuchcoding.frauddetection.model.FraudCheckStatus.OK;
|
||||
import static org.springframework.web.bind.annotation.RequestMethod.PUT;
|
||||
|
||||
@RestController
|
||||
public class FraudDetectionController {
|
||||
|
||||
private static final String FRAUD_SERVICE_JSON_VERSION_1 = "application/vnd.fraud.v1+json";
|
||||
private static final String NO_REASON = null;
|
||||
private static final String AMOUNT_TOO_HIGH = "Amount too high";
|
||||
private static final BigDecimal MAX_AMOUNT = new BigDecimal("5000");
|
||||
|
||||
@RequestMapping(
|
||||
value = "/fraudcheck",
|
||||
method = PUT,
|
||||
consumes = FRAUD_SERVICE_JSON_VERSION_1,
|
||||
produces = FRAUD_SERVICE_JSON_VERSION_1)
|
||||
public FraudCheckResult fraudCheck(@RequestBody FraudCheck fraudCheck) {
|
||||
if (amountGreaterThanThreshold(fraudCheck)) {
|
||||
return new FraudCheckResult(FRAUD, AMOUNT_TOO_HIGH);
|
||||
}
|
||||
return new FraudCheckResult(OK, NO_REASON);
|
||||
}
|
||||
|
||||
private boolean amountGreaterThanThreshold(FraudCheck fraudCheck) {
|
||||
return MAX_AMOUNT.compareTo(fraudCheck.getLoanAmount()) < 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.blogspot.toomuchcoding.frauddetection.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class FraudCheck {
|
||||
|
||||
private String clientPesel;
|
||||
|
||||
private BigDecimal loanAmount;
|
||||
|
||||
public FraudCheck() {
|
||||
}
|
||||
|
||||
public String getClientPesel() {
|
||||
return clientPesel;
|
||||
}
|
||||
|
||||
public void setClientPesel(String clientPesel) {
|
||||
this.clientPesel = clientPesel;
|
||||
}
|
||||
|
||||
public BigDecimal getLoanAmount() {
|
||||
return loanAmount;
|
||||
}
|
||||
|
||||
public void setLoanAmount(BigDecimal loanAmount) {
|
||||
this.loanAmount = loanAmount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.blogspot.toomuchcoding.frauddetection.model;
|
||||
|
||||
public class FraudCheckResult {
|
||||
|
||||
private FraudCheckStatus fraudCheckStatus;
|
||||
|
||||
private String rejectionReason;
|
||||
|
||||
public FraudCheckResult() {
|
||||
}
|
||||
|
||||
public FraudCheckResult(FraudCheckStatus fraudCheckStatus, String rejectionReason) {
|
||||
this.fraudCheckStatus = fraudCheckStatus;
|
||||
this.rejectionReason = rejectionReason;
|
||||
}
|
||||
|
||||
public FraudCheckStatus getFraudCheckStatus() {
|
||||
return fraudCheckStatus;
|
||||
}
|
||||
|
||||
public void setFraudCheckStatus(FraudCheckStatus fraudCheckStatus) {
|
||||
this.fraudCheckStatus = fraudCheckStatus;
|
||||
}
|
||||
|
||||
public String getRejectionReason() {
|
||||
return rejectionReason;
|
||||
}
|
||||
|
||||
public void setRejectionReason(String rejectionReason) {
|
||||
this.rejectionReason = rejectionReason;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.blogspot.toomuchcoding.frauddetection.model;
|
||||
|
||||
public enum FraudCheckStatus {
|
||||
OK, FRAUD
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
server.port=8085
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.blogspot.toomuchcoding
|
||||
|
||||
import com.blogspot.toomuchcoding.frauddetection.FraudDetectionController
|
||||
import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc
|
||||
import spock.lang.Specification
|
||||
|
||||
class MvcSpec extends Specification {
|
||||
def setup() {
|
||||
RestAssuredMockMvc.standaloneSetup(new FraudDetectionController())
|
||||
}
|
||||
|
||||
void assertThatRejectionReasonIsNull(def rejectionReason) {
|
||||
assert !rejectionReason
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,6 @@
|
||||
#Wed Jan 28 00:32:44 CET 2015
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=http\://services.gradle.org/distributions/gradle-2.4-all.zip
|
||||
164
accurest-gradle-plugin/src/test/resources/functionalTest/scenarioProject/gradlew
vendored
Executable file
164
accurest-gradle-plugin/src/test/resources/functionalTest/scenarioProject/gradlew
vendored
Executable file
@@ -0,0 +1,164 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
||||
if $cygwin ; then
|
||||
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
fi
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >&-
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >&-
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
||||
90
accurest-gradle-plugin/src/test/resources/functionalTest/scenarioProject/gradlew.bat
vendored
Normal file
90
accurest-gradle-plugin/src/test/resources/functionalTest/scenarioProject/gradlew.bat
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.blogspot.toomuchcoding.frauddetection;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@EnableAutoConfiguration
|
||||
@ComponentScan
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.blogspot.toomuchcoding.frauddetection;
|
||||
|
||||
import com.blogspot.toomuchcoding.frauddetection.model.FraudCheckStatus;
|
||||
import com.blogspot.toomuchcoding.frauddetection.model.FraudServiceRequest;
|
||||
import com.blogspot.toomuchcoding.frauddetection.model.FraudServiceResponse;
|
||||
import com.blogspot.toomuchcoding.frauddetection.model.LoanApplication;
|
||||
import com.blogspot.toomuchcoding.frauddetection.model.LoanApplicationResult;
|
||||
import com.blogspot.toomuchcoding.frauddetection.model.LoanApplicationStatus;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@Service
|
||||
public class LoanApplicationService {
|
||||
|
||||
private static final String FRAUD_SERVICE_JSON_VERSION_1 =
|
||||
"application/vnd.fraud.v1+json";
|
||||
|
||||
private final RestTemplate restTemplate;
|
||||
|
||||
private int port = 8080;
|
||||
|
||||
public LoanApplicationService() {
|
||||
this.restTemplate = new RestTemplate();
|
||||
}
|
||||
|
||||
public LoanApplicationResult loanApplication(LoanApplication loanApplication) {
|
||||
FraudServiceRequest request =
|
||||
new FraudServiceRequest(loanApplication);
|
||||
|
||||
FraudServiceResponse response =
|
||||
sendRequestToFraudDetectionService(request);
|
||||
|
||||
return buildResponseFromFraudResult(response);
|
||||
}
|
||||
|
||||
private FraudServiceResponse sendRequestToFraudDetectionService(
|
||||
FraudServiceRequest request) {
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.add(HttpHeaders.CONTENT_TYPE, FRAUD_SERVICE_JSON_VERSION_1);
|
||||
|
||||
ResponseEntity<FraudServiceResponse> response =
|
||||
restTemplate.exchange("http://localhost:" + port + "/fraudcheck", HttpMethod.PUT,
|
||||
new HttpEntity<>(request, httpHeaders),
|
||||
FraudServiceResponse.class);
|
||||
|
||||
return response.getBody();
|
||||
}
|
||||
|
||||
private LoanApplicationResult buildResponseFromFraudResult(FraudServiceResponse response) {
|
||||
LoanApplicationStatus applicationStatus = null;
|
||||
if (FraudCheckStatus.OK == response.getFraudCheckStatus()) {
|
||||
applicationStatus = LoanApplicationStatus.LOAN_APPLIED;
|
||||
} else if (FraudCheckStatus.FRAUD == response.getFraudCheckStatus()) {
|
||||
applicationStatus = LoanApplicationStatus.LOAN_APPLICATION_REJECTED;
|
||||
}
|
||||
|
||||
return new LoanApplicationResult(applicationStatus, response.getRejectionReason());
|
||||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.blogspot.toomuchcoding.frauddetection.model;
|
||||
|
||||
public class Client {
|
||||
|
||||
private String pesel;
|
||||
|
||||
public String getPesel() {
|
||||
return pesel;
|
||||
}
|
||||
|
||||
public void setPesel(String pesel) {
|
||||
this.pesel = pesel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.blogspot.toomuchcoding.frauddetection.model;
|
||||
|
||||
public enum FraudCheckStatus {
|
||||
OK, FRAUD
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.blogspot.toomuchcoding.frauddetection.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class FraudServiceRequest {
|
||||
|
||||
private String clientPesel;
|
||||
|
||||
private BigDecimal loanAmount;
|
||||
|
||||
public FraudServiceRequest() {
|
||||
}
|
||||
|
||||
public FraudServiceRequest(LoanApplication loanApplication) {
|
||||
this.clientPesel = loanApplication.getClient().getPesel();
|
||||
this.loanAmount = loanApplication.getAmount();
|
||||
}
|
||||
|
||||
public String getClientPesel() {
|
||||
return clientPesel;
|
||||
}
|
||||
|
||||
public void setClientPesel(String clientPesel) {
|
||||
this.clientPesel = clientPesel;
|
||||
}
|
||||
|
||||
public BigDecimal getLoanAmount() {
|
||||
return loanAmount;
|
||||
}
|
||||
|
||||
public void setLoanAmount(BigDecimal loanAmount) {
|
||||
this.loanAmount = loanAmount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.blogspot.toomuchcoding.frauddetection.model;
|
||||
|
||||
public class FraudServiceResponse {
|
||||
|
||||
private FraudCheckStatus fraudCheckStatus;
|
||||
|
||||
private String rejectionReason;
|
||||
|
||||
public FraudServiceResponse() {
|
||||
}
|
||||
|
||||
public FraudCheckStatus getFraudCheckStatus() {
|
||||
return fraudCheckStatus;
|
||||
}
|
||||
|
||||
public void setFraudCheckStatus(FraudCheckStatus fraudCheckStatus) {
|
||||
this.fraudCheckStatus = fraudCheckStatus;
|
||||
}
|
||||
|
||||
public String getRejectionReason() {
|
||||
return rejectionReason;
|
||||
}
|
||||
|
||||
public void setRejectionReason(String rejectionReason) {
|
||||
this.rejectionReason = rejectionReason;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.blogspot.toomuchcoding.frauddetection.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class LoanApplication {
|
||||
|
||||
private Client client;
|
||||
|
||||
private BigDecimal amount;
|
||||
|
||||
private String loanApplicationId;
|
||||
|
||||
public Client getClient() {
|
||||
return client;
|
||||
}
|
||||
|
||||
public void setClient(Client client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
public BigDecimal getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(BigDecimal amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public String getLoanApplicationId() {
|
||||
return loanApplicationId;
|
||||
}
|
||||
|
||||
public void setLoanApplicationId(String loanApplicationId) {
|
||||
this.loanApplicationId = loanApplicationId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.blogspot.toomuchcoding.frauddetection.model;
|
||||
|
||||
public class LoanApplicationResult {
|
||||
|
||||
private LoanApplicationStatus loanApplicationStatus;
|
||||
|
||||
private String rejectionReason;
|
||||
|
||||
public LoanApplicationResult() {
|
||||
}
|
||||
|
||||
public LoanApplicationResult(LoanApplicationStatus loanApplicationStatus, String rejectionReason) {
|
||||
this.loanApplicationStatus = loanApplicationStatus;
|
||||
this.rejectionReason = rejectionReason;
|
||||
}
|
||||
|
||||
public LoanApplicationStatus getLoanApplicationStatus() {
|
||||
return loanApplicationStatus;
|
||||
}
|
||||
|
||||
public void setLoanApplicationStatus(LoanApplicationStatus loanApplicationStatus) {
|
||||
this.loanApplicationStatus = loanApplicationStatus;
|
||||
}
|
||||
|
||||
public String getRejectionReason() {
|
||||
return rejectionReason;
|
||||
}
|
||||
|
||||
public void setRejectionReason(String rejectionReason) {
|
||||
this.rejectionReason = rejectionReason;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.blogspot.toomuchcoding.frauddetection.model;
|
||||
|
||||
public enum LoanApplicationStatus {
|
||||
LOAN_APPLIED, LOAN_APPLICATION_REJECTED
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
server.port=8090
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.blogspot.toomuchcoding
|
||||
|
||||
import com.blogspot.toomuchcoding.frauddetection.Application
|
||||
import com.blogspot.toomuchcoding.frauddetection.LoanApplicationService
|
||||
import com.blogspot.toomuchcoding.frauddetection.model.Client
|
||||
import com.blogspot.toomuchcoding.frauddetection.model.LoanApplication
|
||||
import com.blogspot.toomuchcoding.frauddetection.model.LoanApplicationResult
|
||||
import com.blogspot.toomuchcoding.frauddetection.model.LoanApplicationStatus
|
||||
import com.github.tomakehurst.wiremock.junit.WireMockClassRule
|
||||
import org.junit.ClassRule
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.boot.test.SpringApplicationContextLoader
|
||||
import org.springframework.test.context.ContextConfiguration
|
||||
import spock.lang.Shared
|
||||
import spock.lang.Specification
|
||||
import spock.lang.Stepwise
|
||||
|
||||
@ContextConfiguration(loader = SpringApplicationContextLoader, classes = Application)
|
||||
@Stepwise
|
||||
class LoanApplicationServiceSpec extends Specification {
|
||||
|
||||
public static int port = org.springframework.util.SocketUtils.findAvailableTcpPort()
|
||||
|
||||
@ClassRule
|
||||
@Shared
|
||||
WireMockClassRule wireMockRule = new WireMockClassRule(port)
|
||||
|
||||
@Autowired
|
||||
LoanApplicationService sut
|
||||
|
||||
def setup() {
|
||||
sut.port = port
|
||||
}
|
||||
|
||||
def 'should successfully apply for loan'() {
|
||||
given:
|
||||
LoanApplication application =
|
||||
new LoanApplication(client: new Client(pesel: '1234567890'), amount: 123.123)
|
||||
when:
|
||||
LoanApplicationResult loanApplication = sut.loanApplication(application)
|
||||
then:
|
||||
loanApplication.loanApplicationStatus == LoanApplicationStatus.LOAN_APPLIED
|
||||
loanApplication.rejectionReason == null
|
||||
}
|
||||
|
||||
def 'should be rejected due to abnormal loan amount'() {
|
||||
given:
|
||||
LoanApplication application =
|
||||
new LoanApplication(client: new Client(pesel: '1234567890'), amount: 99_999)
|
||||
when:
|
||||
LoanApplicationResult loanApplication = sut.loanApplication(application)
|
||||
then:
|
||||
loanApplication.loanApplicationStatus == LoanApplicationStatus.LOAN_APPLICATION_REJECTED
|
||||
loanApplication.rejectionReason == 'Amount too high'
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +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\"}"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +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}"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
include ':fraudDetectionService'
|
||||
include ':loanApplicationService'
|
||||
Reference in New Issue
Block a user