Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HCX-63 Add ymlAPI #54

Merged
merged 1 commit into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
-------------------
Expand Down
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
<jacoco-maven-plugin.version>0.8.5</jacoco-maven-plugin.version>
<groovydoc-maven-plugin.version>2.1</groovydoc-maven-plugin.version>
<vavr.version>0.10.2</vavr.version>
<snakeyaml.version>1.26</snakeyaml.version>
</properties>
<repositories>
<repository>
Expand Down Expand Up @@ -273,6 +274,11 @@
<version>${vavr.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>${snakeyaml.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
32 changes: 32 additions & 0 deletions src/org/camunda/latera/bss/http/YmlApiProcessor.groovy
Original file line number Diff line number Diff line change
@@ -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 [:]
}
}
}
29 changes: 29 additions & 0 deletions test/org/camunda/latera/bss/config/yml_api.yml
Original file line number Diff line number Diff line change
@@ -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