fix(Mock测试): 修复Mock数组多元素匹配时匹配不到的问题

修复Mock数组多元素匹配时匹配不到的问题
This commit is contained in:
song-tianyang 2021-11-24 18:50:47 +08:00 committed by 刘瑞斌
parent bf028cab58
commit 2fce7044cb
2 changed files with 32 additions and 9 deletions

View File

@ -167,14 +167,19 @@ public class JsonStructUtils {
return false;
} else {
for (int i = 0; i < matchArr.size(); i++) {
for (int j = i; j < sourceArr.size(); j++) {
boolean finalChack = false;
sourceForeach:for (int j = i; j < sourceArr.size(); j++) {
Object matchItemObj = matchArr.get(i);
Object sourceItemObj = sourceArr.get(j);
boolean check = checkObjCompliance(sourceItemObj, matchItemObj);
if (!check) {
return check;
if (check) {
finalChack = true;
break;
}
}
if(!finalChack){
return false;
}
}
return true;
}

View File

@ -80,7 +80,24 @@ public class TestPlanLoadCaseService {
public List<TestPlanLoadCaseDTO> list(LoadCaseRequest request) {
request.setOrders(ServiceUtils.getDefaultSortOrder(request.getOrders()));
return extTestPlanLoadCaseMapper.selectTestPlanLoadCaseList(request);
List<TestPlanLoadCaseDTO> testPlanLoadCaseDTOList = extTestPlanLoadCaseMapper.selectTestPlanLoadCaseList(request);
this.syncReportStatus(testPlanLoadCaseDTOList);
return testPlanLoadCaseDTOList;
}
private void syncReportStatus(List<TestPlanLoadCaseDTO> testPlanLoadCaseDTOList) {
for (TestPlanLoadCaseDTO dto : testPlanLoadCaseDTOList) {
if (StringUtils.isNotEmpty(dto.getLoadReportId()) && StringUtils.equalsIgnoreCase(dto.getStatus(), "run")) {
LoadTestReport report = loadTestReportMapper.selectByPrimaryKey(dto.getLoadReportId());
if (report != null && StringUtils.equalsAnyIgnoreCase(report.getStatus(), "Starting", "Running", "Reporting")) {
dto.setStatus(report.getStatus());
TestPlanLoadCaseWithBLOBs updateModel = new TestPlanLoadCaseWithBLOBs();
updateModel.setId(dto.getId());
updateModel.setStatus(report.getStatus());
testPlanLoadCaseMapper.updateByPrimaryKeySelective(updateModel);
}
}
}
}
public List<String> selectTestPlanLoadCaseIds(LoadCaseRequest request) {
@ -155,7 +172,7 @@ public class TestPlanLoadCaseService {
if (request.getConfig() != null && request.getConfig().getMode().equals(RunModeConstants.SERIAL.toString())) {
serialRun(request);
} else {
ExecutorService executorService = Executors.newFixedThreadPool(request.getRequests().size(),new NamedThreadFactory("TestPlanLoadCaseService"));
ExecutorService executorService = Executors.newFixedThreadPool(request.getRequests().size(), new NamedThreadFactory("TestPlanLoadCaseService"));
request.getRequests().forEach(item -> {
executorService.submit(new ParallelExecTask(performanceTestService, testPlanLoadCaseMapper, item));
});
@ -170,7 +187,7 @@ public class TestPlanLoadCaseService {
}
private void serialRun(RunBatchTestPlanRequest request) throws Exception {
ExecutorService executorService = Executors.newFixedThreadPool(request.getRequests().size(),new NamedThreadFactory("TestPlanLoadCaseService-serial"));
ExecutorService executorService = Executors.newFixedThreadPool(request.getRequests().size(), new NamedThreadFactory("TestPlanLoadCaseService-serial"));
for (RunTestPlanRequest runTestPlanRequest : request.getRequests()) {
Future<LoadTestReportWithBLOBs> future = executorService.submit(new SerialExecTask(performanceTestService, testPlanLoadCaseMapper, loadTestReportMapper, runTestPlanRequest, request.getConfig()));
LoadTestReportWithBLOBs report = future.get();
@ -378,8 +395,8 @@ public class TestPlanLoadCaseService {
return buildCases(cases);
}
public List<TestPlanLoadCaseDTO> getAllCases(Collection<String> ids,String planId,String status) {
List<TestPlanLoadCaseDTO> cases = extTestPlanLoadCaseMapper.getCasesByIds(ids,planId, status);
public List<TestPlanLoadCaseDTO> getAllCases(Collection<String> ids, String planId, String status) {
List<TestPlanLoadCaseDTO> cases = extTestPlanLoadCaseMapper.getCasesByIds(ids, planId, status);
return buildCases(cases);
}
@ -438,6 +455,7 @@ public class TestPlanLoadCaseService {
/**
* 用例自定义排序
*
* @param request
*/
public void updateOrder(ResetOrderRequest request) {
@ -450,7 +468,7 @@ public class TestPlanLoadCaseService {
public void checkStatusByDeleteLoadCaseReportId(String reportId) {
List<String> updatedId = extTestPlanLoadCaseMapper.selectIdByLoadCaseReportIdAndStatusIsRun(reportId);
if(CollectionUtils.isNotEmpty(updatedId)){
if (CollectionUtils.isNotEmpty(updatedId)) {
for (String id : updatedId) {
extTestPlanLoadCaseMapper.updateStatusNullById(id);
}