Added the option "inProgress" to the contract
without this change we can't have a contract that will generate a stub but not a test. Of course that's for a reason since it's overriding the very essence of contract test. with this change we assume that the users know what they're doing and that they will use this flag rarerly. Cause it means that you can have a false positive. related to gh-881
This commit is contained in:
@@ -113,7 +113,9 @@ class TestGenerator {
|
||||
void generateTestClasses(final String basePackageName) {
|
||||
ListMultimap<Path, ContractMetadata> contracts = contractFileScanner.
|
||||
findContracts()
|
||||
contracts.asMap().entrySet().each {
|
||||
contracts.asMap().entrySet()
|
||||
.findAll { Map.Entry<Path, Collection<ContractMetadata>> entry -> !entry.value.any { it.anyInProgress() }}
|
||||
.each {
|
||||
Map.Entry<Path, Collection<ContractMetadata>> entry ->
|
||||
processIncludedDirectory(
|
||||
relativizeContractPath(entry), (Collection<ContractMetadata>) entry.
|
||||
|
||||
@@ -58,6 +58,7 @@ class ContractsToYaml {
|
||||
}
|
||||
yamlContract.name = contract.name
|
||||
yamlContract.ignored = contract.ignored
|
||||
yamlContract.inProgress = contract.inProgress
|
||||
yamlContract.description = contract.description
|
||||
yamlContract.label = contract.label
|
||||
request(contract, yamlContract)
|
||||
|
||||
@@ -52,6 +52,8 @@ public class YamlContract {
|
||||
|
||||
public boolean ignored;
|
||||
|
||||
public boolean inProgress;
|
||||
|
||||
public static class Request {
|
||||
|
||||
public String method;
|
||||
|
||||
@@ -98,6 +98,9 @@ class YamlToContracts {
|
||||
if (yamlContract.ignored) {
|
||||
ignored()
|
||||
}
|
||||
if (yamlContract.inProgress) {
|
||||
inProgress()
|
||||
}
|
||||
if (yamlContract.request?.method) {
|
||||
request {
|
||||
method(yamlContract.request?.method)
|
||||
|
||||
@@ -86,6 +86,10 @@ class ContractMetadata {
|
||||
return this.convertedContractWithMetadata
|
||||
.find { it.contract == contract }
|
||||
}
|
||||
|
||||
boolean anyInProgress() {
|
||||
return this.convertedContract.any { it.inProgress }
|
||||
}
|
||||
}
|
||||
|
||||
@CompileStatic
|
||||
|
||||
@@ -716,6 +716,7 @@ label: null
|
||||
name: "post1"
|
||||
priority: null
|
||||
ignored: false
|
||||
inProgress: false
|
||||
'''
|
||||
String expectedYaml2 = '''\
|
||||
---
|
||||
@@ -757,6 +758,7 @@ label: null
|
||||
name: "post2"
|
||||
priority: null
|
||||
ignored: false
|
||||
inProgress: false
|
||||
'''
|
||||
when:
|
||||
Map<String, byte[]> strings = converter.store([
|
||||
@@ -985,6 +987,7 @@ ignored: false
|
||||
name("fooo")
|
||||
label("card_rejected")
|
||||
ignored()
|
||||
inProgress()
|
||||
input {
|
||||
messageFrom("input")
|
||||
messageBody([
|
||||
@@ -1093,6 +1096,7 @@ ignored: false
|
||||
YamlContract yamlContract = yamlContracts.first()
|
||||
yamlContract.name == "fooo"
|
||||
yamlContract.ignored == true
|
||||
yamlContract.inProgress == true
|
||||
yamlContract.label == "card_rejected"
|
||||
yamlContract.input.messageFrom == "input"
|
||||
yamlContract.input.messageBody == [
|
||||
|
||||
Reference in New Issue
Block a user