Skip to content

Commit 93efaf1

Browse files
committed
from json success
1 parent 8cd69a4 commit 93efaf1

File tree

2 files changed

+48
-5
lines changed

2 files changed

+48
-5
lines changed

agouti-http/src/test/java/com/ztianzeng/agouti/http/HttpTaskTest.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
import com.fasterxml.jackson.databind.ObjectMapper;
2121
import com.ztianzeng.agouti.core.WorkFlow;
2222
import com.ztianzeng.agouti.core.executor.BaseExecutor;
23+
import com.ztianzeng.agouti.core.parse.WorkFlowParse;
24+
import com.ztianzeng.agouti.core.resource.AbstractResource;
25+
import com.ztianzeng.agouti.core.resource.ClassPathResource;
2326
import com.ztianzeng.common.tasks.Task;
2427
import com.ztianzeng.common.workflow.WorkFlowDef;
2528
import com.ztianzeng.common.workflow.WorkflowTask;
@@ -81,9 +84,29 @@ public static void init() throws Exception {
8184
server.start();
8285
}
8386

87+
88+
8489
@Test
8590
public void startWorkFlow() {
8691
BaseExecutor baseExecutor = new BaseExecutor();
92+
WorkFlowDef workFlowDef = fromResource();
93+
94+
95+
WorkFlow workFlow = baseExecutor.startWorkFlow(workFlowDef, null);
96+
Object d1Key = workFlow.getOutputs().get("d1Key");
97+
Assert.assertEquals(d1Key,"input_key1");
98+
}
99+
100+
101+
private WorkFlowDef fromResource() {
102+
String path = "workFlowDef.json";
103+
AbstractResource resource = new ClassPathResource(
104+
path, ClassLoader.getSystemClassLoader());
105+
106+
return WorkFlowParse.parse(resource);
107+
}
108+
109+
private WorkFlowDef fromDef(){
87110
WorkFlowDef workFlowDef = new WorkFlowDef();
88111
workFlowDef.setName("name");
89112
workFlowDef.setDescription("desc");
@@ -123,12 +146,8 @@ public void startWorkFlow() {
123146

124147
workFlowDef.getTasks().add(d1);
125148
workFlowDef.getTasks().add(d2);
126-
127-
WorkFlow workFlow = baseExecutor.startWorkFlow(workFlowDef, null);
128-
Object d1Key = workFlow.getOutputs().get("d1Key");
129-
Assert.assertEquals(d1Key,"input_key1");
149+
return workFlowDef;
130150
}
131-
132151
@Test
133152
public void testPost() {
134153
Task task = new Task();
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "work flow",
3+
"description": "desc",
4+
"outputParameters": {
5+
"d1Key": "${d1.response.body.input_key1}"
6+
},
7+
"tasks": [
8+
{
9+
"name": "d1",
10+
"alias": "d1",
11+
"type": "HTTP",
12+
"inputParameters": {
13+
"http_request": {
14+
"uri": "http://localhost:7009/post",
15+
"body": {
16+
"input_key1": "value1",
17+
"input_key2": "45.3d"
18+
},
19+
"method": "POST"
20+
}
21+
}
22+
}
23+
]
24+
}

0 commit comments

Comments
 (0)