parent
d50e1c0ee9
commit
18defbfa05
|
@ -247,6 +247,9 @@ public class ApiScenarioImportUtil {
|
|||
test.setUserId(SessionUtils.getUserId());
|
||||
test.setLatest(true);
|
||||
test.setOrder(apiDefinitionService.getImportNextOrder(projectId));
|
||||
if (test.getName().length() > 255) {
|
||||
test.setName(test.getName().substring(0, 255));
|
||||
}
|
||||
apiDefinitionMapper.insert(test);
|
||||
definitionMap.put(object.getString("path") + object.getString("method") + object.getString("protocol"), test);
|
||||
return test;
|
||||
|
@ -279,6 +282,9 @@ public class ApiScenarioImportUtil {
|
|||
objectNew.remove("referenced");
|
||||
apiTestCase.setRequest(objectNew.toJSONString());
|
||||
apiTestCase.setOrder(apiDefinitionService.getImportNextCaseOrder(projectId));
|
||||
if (apiTestCase.getName().length() > 255) {
|
||||
apiTestCase.setName(apiTestCase.getName().substring(0, 255));
|
||||
}
|
||||
apiTestCaseMapper.insert(apiTestCase);
|
||||
}
|
||||
|
||||
|
|
|
@ -1131,11 +1131,12 @@ public class ApiDefinitionService {
|
|||
int batchCount = 0;
|
||||
for (int i = 0; i < cases.size(); i++) {
|
||||
ApiTestCaseWithBLOBs item = cases.get(i);
|
||||
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = apiDefinitionMapper.selectByPrimaryKey(item.getApiDefinitionId());
|
||||
if (apiDefinitionWithBLOBs == null) {
|
||||
List<ApiDefinitionWithBLOBs> data = apiImport.getData();
|
||||
List<ApiDefinitionWithBLOBs> collect = data.stream().filter(t -> t.getId().equals(item.getApiDefinitionId())).collect(toList());
|
||||
if (collect.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
insertOrUpdateImportCase(item, request, apiDefinitionWithBLOBs, apiTestCaseMapper);
|
||||
insertOrUpdateImportCase(item, request, collect.get(0), apiTestCaseMapper);
|
||||
}
|
||||
if (batchCount % 300 == 0) {
|
||||
sqlSession.flushStatements();
|
||||
|
@ -1166,7 +1167,12 @@ public class ApiDefinitionService {
|
|||
|
||||
private void insertOrUpdateImportCase(ApiTestCaseWithBLOBs apiTestCase, ApiTestImportRequest apiTestImportRequest, ApiDefinitionWithBLOBs apiDefinition, ApiTestCaseMapper apiTestCaseMapper) {
|
||||
SaveApiTestCaseRequest checkRequest = new SaveApiTestCaseRequest();
|
||||
checkRequest.setName(apiTestCase.getName());
|
||||
if (apiTestCase.getName().length() > 255) {
|
||||
apiTestCase.setName(apiTestCase.getName().substring(0, 255));
|
||||
checkRequest.setName(apiTestCase.getName().substring(0, 255));
|
||||
} else {
|
||||
checkRequest.setName(apiTestCase.getName());
|
||||
}
|
||||
checkRequest.setApiDefinitionId(apiTestCase.getApiDefinitionId());
|
||||
checkRequest.setId(apiTestCase.getId());
|
||||
ApiTestCase sameCase = apiTestCaseService.getSameCase(checkRequest);
|
||||
|
|
Loading…
Reference in New Issue