-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
SpringDemoTest.java
62 lines (53 loc) · 2.16 KB
/
SpringDemoTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package com.ql.util.express.test.spring;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import org.unitils.UnitilsJUnit4;
import org.unitils.spring.annotation.SpringApplicationContext;
import org.unitils.spring.annotation.SpringBeanByName;
@SpringApplicationContext("classpath:spring-express-config.xml")
public class SpringDemoTest extends UnitilsJUnit4 {
@SpringBeanByName
private QlExpressUtil qlExpressUtil;
@Test
public void testScript() throws Exception {
String express = ""
+ "if(bizLogicBean.getUserInfo(nick)!=null) {"
+ " userDO = bizLogicBean.getUserInfo(nick);"
+ " if(userDO.salary>20000 && userDO.salary<20000) {"
+ " System.out.println('高级客户:'+userDO.nick);"
+ " } else if(userDO.salary>=200000) {"
+ " System.out.println('vip客户:'+userDO.nick);"
+ " } else {"
+ " System.out.println('普通客户:'+userDO.nick);"
+ " }"
+ "} else {"
+ " System.out.println('用户信息不存在');"
+ "}";
Map<String, Object> context = new HashMap<>();
context.put("nick", "马总");
qlExpressUtil.execute(express, context);
context.put("nick", "小王");
qlExpressUtil.execute(express, context);
context.put("nick", "XXX");
qlExpressUtil.execute(express, context);
}
@Test
public void testScript2() throws Exception {
String express = ""
+ "userDO = 读取用户信息(nick);"
+ "if(userDO != null) {"
+ " if(判定用户是否vip)"
+ " System.out.println('vip客户:' + nick);"
+ "} else {"
+ " System.out.println('用户信息不存在,nick:' + nick);"
+ "}";
Map<String, Object> context = new HashMap<>();
context.put("nick", "马总");
qlExpressUtil.execute(express, context);
context.put("nick", "小王");
qlExpressUtil.execute(express, context);
context.put("nick", "XXX");
qlExpressUtil.execute(express, context);
}
}