8000 add · mgicode/mgicode-interface-test@74df494 · GitHub
[go: up one dir, main page]

Skip to content

Commit 74df494

Browse files
author
pengrk
committed
add
1 parent 60bf89b commit 74df494

File tree

3 files changed

+74
-9
lines changed

3 files changed

+74
-9
lines changed

src/main/java/com/mgicode/test/domain/ApiRequest.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ public class ApiRequest {
88
private Asserts asserts;
99

1010
private String description;
11+
12+
//
13+
private boolean preSuccess;
1114

15+
1216
public RestApi getRestApi() {
1317
return restApi;
1418
}
@@ -34,6 +38,11 @@ public String getDescription() {
3438
public void setDescription(String description) {
3539
this.description = description;
3640
}
37-
41+
public boolean isPreSuccess() {
42+
return preSuccess;
43+
}
44+
public void setPreSuccess(boolean preSuccess) {
45+
this.preSuccess = preSuccess;
46+
}
3847

3948
}

src/main/java/com/mgicode/test/rules/InRuleUtils.java

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,49 @@ public static InRule loop(int level, String name, InRule inrule, InRuleCallBack
1616
if (dotName == null || dotName.trim().isEmpty()) {
1717
dotName = "";
1818
} else {
19-
dotName = name + inrule.getName();
19+
dotName = name +"."+ inrule.getName();
2020
}
2121
icb.exec(level, dotName, inrule);
2222
if (inrule.getDataRule() != null && inrule.getDataRule().size() > 0) {
2323
for (InRule child : inrule.getDataRule().values()) {
24-
icb.exec(level + 1, dotName,child);
24+
icb.exec(level + 1, dotName, child);
2525
}
2626
}
2727

2828
return inrule;
2929
}
3030

31+
public static boolean loopBreak(InRule inrule, InRuleCallBack icb) {
32+
33+
return loopBreak(0, "", inrule, icb);
34+
35+
}
36+
37+
public static boolean loopBreak(int level, String name, InRule inrule, InRuleCallBack icb) {
38+
39+
String dotName = name;
40+
if (dotName == null || dotName.trim().isEmpty()) {
41+
dotName = "";
42+
} else {
43+
dotName = name + inrule.getName();
44+
}
45+
boolean flag = icb.exec(level, dotName, inrule);
46+
if (flag == false) {
47+
return false;
48+
}
49+
if (inrule.getDataRule() != null && inrule.getDataRule().size() > 0) {
50+
for (InRule child : inrule.getDataRule().values()) {
51+
52+
boolean flag1 = icb.exec(level + 1, dotName, child);
53+
if (flag1 == false) {
54+
break;
55+
}
56+
}
57+
}
58+
59+
return true;
60+
}
61+
3162
/**
3263
* 把inrule的excluded设定为false
3364
*
@@ -37,13 +68,14 @@ public static void initInRuleState(InRule inrule) {
3768

3869
loop(inrule, (level, name, inrule1) -> {
3970
inrule1.setExcluded(false);
71+
return true;
4072
});
4173

4274
}
4375

4476
public interface InRuleCallBack {
4577

46-
public void exec(int level, String name, InRule inrule);
78+
public boolean exec(int level, String name, InRule inrule);
4779
}
4880

4981
}

src/main/java/com/mgicode/test/service/ingen/SimpleInDataGen.java

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.mgicode.test.service.ingen;
22

3+
import java.util.HashMap;
34
import java.util.List;
5+
import java.util.Map;
46

57
import com.mgicode.test.domain.ApiConfig;
68
import com.mgicode.test.domain.ApiRequest;
@@ -39,19 +41,41 @@ else if (as.getCount().contains(">")) {
3941
public List<ApiRequest> genMax(Asserts as, ApiConfig apiConfig) {
4042
// 每个assert
4143
// 排除已经指定数据的字段
42-
InRuleUtils.loop(apiConfig.getInRule(), (level, name, inrule1) -> {
44+
InRuleUtils.loop(apiConfig.getInRule(), (level, name, inrule) -> {
4345
for (String key : as.getIn().keySet()) {
4446
if (key.equals(name)) {
45-
inrule1.setExcluded(true);
47+
inrule.setExcluded(true);
4648
break;
4749
}
4850
}
51+
return true;
4952
});
5053

51-
//目前只考虑二层(o数据上只有一层),即采用form-data的方式进行
52-
53-
54+
// 目前只考虑二层(o数据上只有一层),即采用form-data的方式进行
55+
56+
// "in": {
57+
// "laneEnSeriaNo": "{{user.name}}",
58+
// "enTime": "322eee"
59+
// },
60+
61+
ApiRequest apiRequest = new ApiRequest();
62+
Map<String, ?> inDataMap = new HashMap<>();
63+
64+
InRuleUtils.loopBreak(apiConfig.getInRule(), (level, name, inrule) -> {
65+
// 处理第一层,看看参数是否可以完成为空
66+
if (level == 0) {
67+
boolean required = inrule.isRequired();
68+
//required
5469

70+
71+
} else if (level == 1) {
72+
73+
}
74+
75+
return true;
76+
77+
});
78+
5579
return null;
5680
}
5781

0 commit comments

Comments
 (0)
0