+
@Override
+public Collection<Contract> convertFrom(File file) {
+ try {
+ YamlContract yamlContract = new Yaml().loadAs(new FileInputStream(file), YamlContract.class)
+ return [Contract.make {
+ request {
+ method(yamlContract?.request?.method)
+ url(yamlContract?.request?.url)
+ headers {
+ yamlContract?.request?.headers?.each { String key, Object value ->
+ header(key, value)
}
- body(yamlContract?.request?.body)
}
- response {
- status(yamlContract?.response?.status)
- headers {
- yamlContract?.response?.headers?.each { String key, Object value ->
- header(key, value)
- }
+ body(yamlContract?.request?.body)
+ }
+ response {
+ status(yamlContract?.response?.status)
+ headers {
+ yamlContract?.response?.headers?.each { String key, Object value ->
+ header(key, value)
}
- body(yamlContract?.response?.body)
}
- }]
- }
- catch (FileNotFoundException e) {
- throw new IllegalStateException(e)
- }
+ body(yamlContract?.response?.body)
+ }
+ }]
}
-
- @Override
+ catch (FileNotFoundException e) {
+ throw new IllegalStateException(e)
+ }
+}
+