|
@@ -1,6 +1,8 @@
|
|
package com.mooctest.crowd.site.service.impl;
|
|
package com.mooctest.crowd.site.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.GsonBuilder;
|
|
import com.google.gson.GsonBuilder;
|
|
import com.mooctest.crowd.domain.dao.*;
|
|
import com.mooctest.crowd.domain.dao.*;
|
|
@@ -11,10 +13,7 @@ import com.mooctest.crowd.domain.exception.BaseException;
|
|
import com.mooctest.crowd.domain.exception.CrowdTestTaskNotExistException;
|
|
import com.mooctest.crowd.domain.exception.CrowdTestTaskNotExistException;
|
|
import com.mooctest.crowd.domain.exception.ExportTaskFileNotExistException;
|
|
import com.mooctest.crowd.domain.exception.ExportTaskFileNotExistException;
|
|
import com.mooctest.crowd.domain.exception.FileIsEmptyException;
|
|
import com.mooctest.crowd.domain.exception.FileIsEmptyException;
|
|
-import com.mooctest.crowd.domain.model.ApplicationTypePO;
|
|
|
|
-import com.mooctest.crowd.domain.model.EndPointPO;
|
|
|
|
-import com.mooctest.crowd.domain.model.FieldPO;
|
|
|
|
-import com.mooctest.crowd.domain.model.TestActionPO;
|
|
|
|
|
|
+import com.mooctest.crowd.domain.model.*;
|
|
import com.mooctest.crowd.domain.repository.CrowdTestProjectRepo;
|
|
import com.mooctest.crowd.domain.repository.CrowdTestProjectRepo;
|
|
import com.mooctest.crowd.domain.repository.CrowdTestTaskRepo;
|
|
import com.mooctest.crowd.domain.repository.CrowdTestTaskRepo;
|
|
import com.mooctest.crowd.domain.repository.UserRepo;
|
|
import com.mooctest.crowd.domain.repository.UserRepo;
|
|
@@ -88,6 +87,9 @@ public class CrowdTaskServiceImpl implements CrowdTaskService {
|
|
TestTypeDao testTypeDao;
|
|
TestTypeDao testTypeDao;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
|
+ TestCaseDao testCaseDao;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
TestActionDao testActionDao;
|
|
TestActionDao testActionDao;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -274,10 +276,10 @@ public class CrowdTaskServiceImpl implements CrowdTaskService {
|
|
this.needTestcase(task);
|
|
this.needTestcase(task);
|
|
|
|
|
|
task.setEndPoint(endPoint);
|
|
task.setEndPoint(endPoint);
|
|
-// project.addTask(task);
|
|
|
|
-// projectRepo.saveCrowdTestProject(project);
|
|
|
|
-// return getTaskDetails(projectCode, taskCode, userId);
|
|
|
|
- return getTaskDetails(projectCode, "TASK-JKCS-2022030715008", userId);
|
|
|
|
|
|
+ project.addTask(task);
|
|
|
|
+ projectRepo.saveCrowdTestProject(project);
|
|
|
|
+ return getTaskDetails(projectCode, taskCode, userId);
|
|
|
|
+// return getTaskDetails(projectCode, "TASK-JKCS-2022030715008", userId);
|
|
}
|
|
}
|
|
|
|
|
|
private void createTaskToCrowdService(CrowdTestTaskCommand command, Long userId, CrowdTestTask task, EndPoint endPoint) {
|
|
private void createTaskToCrowdService(CrowdTestTaskCommand command, Long userId, CrowdTestTask task, EndPoint endPoint) {
|
|
@@ -386,19 +388,19 @@ public class CrowdTaskServiceImpl implements CrowdTaskService {
|
|
private void needTestcase(CrowdTestTask task) {
|
|
private void needTestcase(CrowdTestTask task) {
|
|
if (task.getNeedTestcase() == 1) {
|
|
if (task.getNeedTestcase() == 1) {
|
|
String testcaseData = this.generateTestcase();
|
|
String testcaseData = this.generateTestcase();
|
|
- System.out.println(testcaseData);
|
|
|
|
- List<TestCase> testcaseList = (List<TestCase>) JSON.parse(testcaseData);
|
|
|
|
- System.out.println(testcaseList.get(0).testActions);
|
|
|
|
|
|
+ List<TestCase> testcaseList = JSON.parseArray(testcaseData, TestCase.class);
|
|
// 进行数据库存储
|
|
// 进行数据库存储
|
|
-// for (int i = 0; i < testcaseList.size(); i++) {
|
|
|
|
-// System.out.println(testcaseList.get(i).testActions);
|
|
|
|
-// testcaseList.get(i).testActions.stream().map(testAction -> {
|
|
|
|
-// testAction.taskCode = task.getCode();
|
|
|
|
-// testActionDao.save(Converter.convert(TestActionPO.class, testAction));
|
|
|
|
-// return testAction;
|
|
|
|
-// });
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
|
|
+ for (int i = 0; i < testcaseList.size(); i++) {
|
|
|
|
+ TestCase testCase = new TestCase();
|
|
|
|
+ testCase.setTaskCode(task.getCode());
|
|
|
|
+ TestCasePO testCasePO = testCaseDao.save(Converter.convert(TestCasePO.class, testCase));
|
|
|
|
+ List<TestAction> testActions = testcaseList.get(i).getTestActions();
|
|
|
|
+ for (int j = 0; j < testActions.size(); j++) {
|
|
|
|
+ TestAction testAction = testActions.get(j);
|
|
|
|
+ testAction.setTestCaseId(testCasePO.getId());
|
|
|
|
+ testActionDao.save(Converter.convert(TestActionPO.class, testAction));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|