diff --git a/CHANGELOG.md b/CHANGELOG.md index 00e6e85a..94b9a9d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ v1.5 [unreleased] - [#13](https://github.com/latera/camunda-ext/pull/13) Fix id and non-id fields in helpers.hydra.Individual trait methods - [#35](https://github.com/latera/camunda-ext/pull/35) Set private modifier for hid.hydra.Account#put* methods - [#36](https://github.com/latera/camunda-ext/pull/36) Rename Bill to Invoice +### Refactoring +- [#54](https://github.com/latera/camunda-ext/pull/54) Add ymlAPI for testing v1.4.3 [unreleased] ------------------- diff --git a/pom.xml b/pom.xml index e7bc213a..c713b71e 100644 --- a/pom.xml +++ b/pom.xml @@ -68,6 +68,7 @@ 0.8.5 2.1 0.10.2 + 1.26 @@ -273,6 +274,11 @@ ${vavr.version} compile + + org.yaml + snakeyaml + ${snakeyaml.version} + diff --git a/src/org/camunda/latera/bss/http/YmlApiProcessor.groovy b/src/org/camunda/latera/bss/http/YmlApiProcessor.groovy new file mode 100644 index 00000000..2b43976f --- /dev/null +++ b/src/org/camunda/latera/bss/http/YmlApiProcessor.groovy @@ -0,0 +1,32 @@ +package org.camunda.latera.bss.http; + +import org.yaml.snakeyaml.Yaml + +class YmlApiProcessor { + public LinkedHashMap config + + YmlApiProcessor() { + Yaml parser = new Yaml() + this.config = parser.load(("/camunda/lib/yml_api.yml" as File).text) + } + + public LinkedHashMap sendRequest(Map params, CharSequence method = 'get') { + String uriParams = "" + + if (params.body) { + uriParams = params.body.collect{ key, value -> "$key=$value" }.join('&') + } + + if (params.query) { + uriParams = params.query.collect{ key, value -> "$key=$value" }.join('&') + } + + LinkedHashMap result = this.config.requests[method][params.path][uriParams] + + if (result) { + return result + } else { + return [:] + } + } +} diff --git a/test/org/camunda/latera/bss/config/yml_api.yml b/test/org/camunda/latera/bss/config/yml_api.yml new file mode 100644 index 00000000..6d7d377d --- /dev/null +++ b/test/org/camunda/latera/bss/config/yml_api.yml @@ -0,0 +1,29 @@ +requests: + put: + '/orders/ord-123': + 'asd=123': + response: + status: 200 + obj1: 123 + obj2: 123 + post: + '/orders/ord-123': + 'asd=123': + response: + status: 200 + obj1: 123 + obj2: 123 + get: + '/orders/ord-123': + 'asd=123': + response: + status: 200 + obj1: 123 + obj2: 123 + delete: + '/orders/ord-123': + 'asd=123': + response: + status: 200 + obj1: 123 + obj2: 123