master
wangbing 6 years ago
parent ccbd3c8e7a
commit d2ff67475c

@ -252,7 +252,7 @@ public class OptionApiController {
} }
} }
api.setMethod("api." + module + "." + Tool.camelToPoint(req.getName().replaceAll("Request\\.java", ""))); api.setMethod(module + "." + Tool.camelToPoint(req.getName().replaceAll("Request\\.java", "")));
if (api.getTargetRequest().startsWith("Api")){ if (api.getTargetRequest().startsWith("Api")){

@ -21,18 +21,18 @@ public class ApiCallable implements Callable {
private File rsp; private File rsp;
private File ent; private File ent;
private File enums; private File enums;
private List<Api> apis; private List<Api> apiList;
private Tool tool = new Tool(); private Tool tool = new Tool();
private FreeMarkerManager freeMarkerManager; private FreeMarkerManager freeMarkerManager;
public ApiCallable(File api, File req, File rsp, File ent, File enums, List<Api> apis) { public ApiCallable(File api, File req, File rsp, File ent, File enums, List<Api> apiList) {
this.api = api; this.api = api;
this.req = req; this.req = req;
this.rsp = rsp; this.rsp = rsp;
this.ent = ent; this.ent = ent;
this.enums = enums; this.enums = enums;
this.apis = apis; this.apiList = apiList;
this.freeMarkerManager = ManagerFactory.getFreeMarkerManager(); this.freeMarkerManager = ManagerFactory.getFreeMarkerManager();
} }
@ -66,7 +66,7 @@ public class ApiCallable implements Callable {
sbtest.append("test" + File.separator); sbtest.append("test" + File.separator);
sbtest.append("java" + File.separator); sbtest.append("java" + File.separator);
JavaClassReader javaClass = new JavaClassReader(apis.get(0).getReq()); JavaClassReader javaClass = new JavaClassReader(apiList.get(0).getReq());
String[] split = javaClass.getDomainName().split("\\."); String[] split = javaClass.getDomainName().split("\\.");
for (String s1 : split) { for (String s1 : split) {
@ -99,7 +99,7 @@ public class ApiCallable implements Callable {
Set<String> managerList = new HashSet<>(); Set<String> managerList = new HashSet<>();
List<Method> methodList = new ArrayList<>(); List<Method> methodList = new ArrayList<>();
for (Api api : apis) { for (Api api : apiList) {
if (api.isCheck()) { if (api.isCheck()) {
try { try {
@ -411,6 +411,7 @@ public class ApiCallable implements Callable {
ctx.put("module", javaClass.getModuleName()); ctx.put("module", javaClass.getModuleName());
ctx.put("managerList", managerList); ctx.put("managerList", managerList);
ctx.put("methodList", methodList); ctx.put("methodList", methodList);
ctx.put("apiList", apiList);
freeMarkerManager.outputTemp(new File(testdomain.getAbsolutePath(), "ApiTest.java"), "Java_api/ApiTest.ftl", ctx); freeMarkerManager.outputTemp(new File(testdomain.getAbsolutePath(), "ApiTest.java"), "Java_api/ApiTest.ftl", ctx);
} }

@ -1,7 +1,7 @@
package ${domain}; package ${domain};
import ${domain}.request.ApiExampleRequest; import ${domain}.request.*;
import ${domain}.response.ApiExampleResponse; import ${domain}.response.*;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -53,13 +53,6 @@ public class ApiTest {
} }
@Test
public void testApiExample() {
ApiExampleRequest request = new ApiExampleRequest();
ApiExampleResponse response = apiClient.execute(request);
Assert.assertTrue(!response.hasError());
}
@Test @Test
public void testFileUpload() { public void testFileUpload() {
{//无进度显示 {//无进度显示
@ -94,5 +87,13 @@ public class ApiTest {
}); });
} }
} }
<#list apiList as item>
@Test
public void test${item.targetRequest}() {
${item.targetRequest} request = new ${item.targetRequest}();
${item.targetResponse} response = apiClient.execute(request);
Assert.assertTrue(!response.hasError());
}
</#list>
} }

@ -28,7 +28,7 @@ ${i}
} }
public String apiMethod() { public String apiMethod() {
return "api.${module}.${tool.camelToPoint(className)}"; return "${module}.${tool.camelToPoint(className)}";
} }
public Class<${className}Response> responseClass() { public Class<${className}Response> responseClass() {

Loading…
Cancel
Save

Powered by TurnKey Linux.