This commit is contained in:
Marcin Grzejszczak
2019-04-16 10:33:22 +04:00
parent 366b77c3a1
commit b90f1a0d6f
2 changed files with 3 additions and 7 deletions

View File

@@ -41,16 +41,14 @@ class YamlContractConverter implements ContractConverter<List<YamlContract>> {
boolean isAccepted(File file) {
String name = file.getName()
boolean acceptFile = name.endsWith(".yml") || name.endsWith(".yaml")
if (acceptFile){
try {
yamlToContracts.convertFrom(file)
this.yamlToContracts.convertFrom(file)
} catch (e) {
log.warn("Error Processing yaml file. Skipping Contract Generation ", e)
acceptFile = false
}
}
return acceptFile
}

View File

@@ -89,10 +89,8 @@ class YamlContractConverterSpec extends Specification {
URL ymlRestXmlFile = YamlContractConverterSpec.
getResource("/yml/contract_rest_xml.yml")
File ymlRestXml = new File(ymlRestXmlFile.toURI())
URL oa3SpecUrl = YamlContractConverterSpec.getResource('/yml/oa3/openapi_petstore.yml')
File oa3File = new File(oa3SpecUrl.toURI())
YamlContractConverter converter = new YamlContractConverter()
String xmlContractBody = '''
<test>
@@ -1326,7 +1324,7 @@ ignored: false
.replaceAll("\n", "").replaceAll(' ', '')
}
def "Should accept file"(){
def "should accept a yaml file that is a proper scc YAML contract"(){
when:
def accepted = converter.isAccepted(ymlWithRest3)
@@ -1334,7 +1332,7 @@ ignored: false
accepted
}
def "Should NOT accept file"(){
def "should not accept a YAML file that is not a scc YAML contract"(){
when:
def accepted = converter.isAccepted(oa3File)