fix:测试计划关联测试报错
This commit is contained in:
parent
8f12d2786a
commit
0ab466293c
|
@ -126,6 +126,8 @@ public class TestPlanService {
|
||||||
private TestPlanApiScenarioMapper testPlanApiScenarioMapper;
|
private TestPlanApiScenarioMapper testPlanApiScenarioMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private ApiScenarioMapper apiScenarioMapper;
|
private ApiScenarioMapper apiScenarioMapper;
|
||||||
|
@Resource
|
||||||
|
private TestCaseTestMapper testCaseTestMapper;
|
||||||
|
|
||||||
public synchronized String addTestPlan(AddTestPlanRequest testPlan) {
|
public synchronized String addTestPlan(AddTestPlanRequest testPlan) {
|
||||||
if (getTestPlanByName(testPlan.getName()).size() > 0) {
|
if (getTestPlanByName(testPlan.getName()).size() > 0) {
|
||||||
|
@ -433,57 +435,65 @@ public class TestPlanService {
|
||||||
if(request.getChecked()){
|
if(request.getChecked()){
|
||||||
if (!testCaseIds.isEmpty()) {
|
if (!testCaseIds.isEmpty()) {
|
||||||
testCaseIds.forEach(caseId -> {
|
testCaseIds.forEach(caseId -> {
|
||||||
TestCaseWithBLOBs testDtail=testCaseMapper.selectByPrimaryKey(caseId);
|
List<TestCaseTest> list=new ArrayList<>();
|
||||||
if(StringUtils.equals(testDtail.getType(),TestCaseStatus.performance.name())){
|
TestCaseTestExample examp=new TestCaseTestExample();
|
||||||
TestPlanLoadCase t = new TestPlanLoadCase();
|
examp.createCriteria().andTestCaseIdEqualTo(caseId);
|
||||||
t.setId(UUID.randomUUID().toString());
|
if(testCaseTestMapper.countByExample(examp)>0){
|
||||||
t.setTestPlanId(request.getPlanId());
|
list=testCaseTestMapper.selectByExample(examp);
|
||||||
t.setLoadCaseId(testDtail.getTestId());
|
}
|
||||||
t.setCreateTime(System.currentTimeMillis());
|
list.forEach(l->{
|
||||||
t.setUpdateTime(System.currentTimeMillis());
|
if(StringUtils.equals(l.getTestType(),TestCaseStatus.performance.name())){
|
||||||
TestPlanLoadCaseExample testPlanLoadCaseExample=new TestPlanLoadCaseExample();
|
TestPlanLoadCase t = new TestPlanLoadCase();
|
||||||
testPlanLoadCaseExample.createCriteria().andTestPlanIdEqualTo(request.getPlanId()).andLoadCaseIdEqualTo(t.getLoadCaseId());
|
t.setId(UUID.randomUUID().toString());
|
||||||
if (testPlanLoadCaseMapper.countByExample(testPlanLoadCaseExample) <=0) {
|
t.setTestPlanId(request.getPlanId());
|
||||||
testPlanLoadCaseMapper.insert(t);
|
t.setLoadCaseId(l.getTestId());
|
||||||
|
t.setCreateTime(System.currentTimeMillis());
|
||||||
|
t.setUpdateTime(System.currentTimeMillis());
|
||||||
|
TestPlanLoadCaseExample testPlanLoadCaseExample=new TestPlanLoadCaseExample();
|
||||||
|
testPlanLoadCaseExample.createCriteria().andTestPlanIdEqualTo(request.getPlanId()).andLoadCaseIdEqualTo(t.getLoadCaseId());
|
||||||
|
if (testPlanLoadCaseMapper.countByExample(testPlanLoadCaseExample) <=0) {
|
||||||
|
testPlanLoadCaseMapper.insert(t);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if(StringUtils.equals(l.getTestType(),TestCaseStatus.testcase.name())){
|
||||||
|
TestPlanApiCase t=new TestPlanApiCase();
|
||||||
|
ApiTestCaseWithBLOBs apitest=apiTestCaseMapper.selectByPrimaryKey(l.getTestId());
|
||||||
|
ApiDefinitionWithBLOBs apidefinition=apiDefinitionMapper.selectByPrimaryKey(apitest.getApiDefinitionId());
|
||||||
|
t.setId(UUID.randomUUID().toString());
|
||||||
|
t.setTestPlanId(request.getPlanId());
|
||||||
|
t.setApiCaseId(l.getTestId());
|
||||||
|
t.setEnvironmentId(apidefinition.getEnvironmentId());
|
||||||
|
t.setCreateTime(System.currentTimeMillis());
|
||||||
|
t.setUpdateTime(System.currentTimeMillis());
|
||||||
|
TestPlanApiCaseExample example=new TestPlanApiCaseExample();
|
||||||
|
example.createCriteria().andTestPlanIdEqualTo(request.getPlanId()).andApiCaseIdEqualTo(t.getApiCaseId());
|
||||||
|
if(testPlanApiCaseMapper.countByExample(example)<=0){
|
||||||
|
testPlanApiCaseMapper.insert(t);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
if(StringUtils.equals(testDtail.getType(),TestCaseStatus.testcase.name())){
|
|
||||||
TestPlanApiCase t=new TestPlanApiCase();
|
|
||||||
ApiTestCaseWithBLOBs apitest=apiTestCaseMapper.selectByPrimaryKey(testDtail.getTestId());
|
|
||||||
ApiDefinitionWithBLOBs apidefinition=apiDefinitionMapper.selectByPrimaryKey(apitest.getApiDefinitionId());
|
|
||||||
t.setId(UUID.randomUUID().toString());
|
|
||||||
t.setTestPlanId(request.getPlanId());
|
|
||||||
t.setApiCaseId(testDtail.getTestId());
|
|
||||||
t.setEnvironmentId(apidefinition.getEnvironmentId());
|
|
||||||
t.setCreateTime(System.currentTimeMillis());
|
|
||||||
t.setUpdateTime(System.currentTimeMillis());
|
|
||||||
TestPlanApiCaseExample example=new TestPlanApiCaseExample();
|
|
||||||
example.createCriteria().andTestPlanIdEqualTo(request.getPlanId()).andApiCaseIdEqualTo(t.getApiCaseId());
|
|
||||||
if(testPlanApiCaseMapper.countByExample(example)<=0){
|
|
||||||
testPlanApiCaseMapper.insert(t);
|
|
||||||
}
|
}
|
||||||
|
if(StringUtils.equals(l.getTestType(),TestCaseStatus.automation.name())){
|
||||||
|
TestPlanApiScenario t=new TestPlanApiScenario();
|
||||||
|
ApiScenarioWithBLOBs testPlanApiScenario=apiScenarioMapper.selectByPrimaryKey(l.getTestId());
|
||||||
|
t.setId(UUID.randomUUID().toString());
|
||||||
|
t.setTestPlanId(request.getPlanId());
|
||||||
|
t.setApiScenarioId(l.getTestId());
|
||||||
|
t.setLastResult(testPlanApiScenario.getLastResult());
|
||||||
|
t.setPassRate(testPlanApiScenario.getPassRate());
|
||||||
|
t.setReportId(testPlanApiScenario.getReportId());
|
||||||
|
t.setStatus(testPlanApiScenario.getStatus());
|
||||||
|
t.setCreateTime(System.currentTimeMillis());
|
||||||
|
t.setUpdateTime(System.currentTimeMillis());
|
||||||
|
TestPlanApiScenarioExample example=new TestPlanApiScenarioExample();
|
||||||
|
example.createCriteria().andTestPlanIdEqualTo(request.getPlanId()).andApiScenarioIdEqualTo(t.getApiScenarioId());
|
||||||
|
if(testPlanApiScenarioMapper.countByExample(example)<=0){
|
||||||
|
testPlanApiScenarioMapper.insert(t);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if(StringUtils.equals(testDtail.getType(),TestCaseStatus.automation.name())){
|
});
|
||||||
TestPlanApiScenario t=new TestPlanApiScenario();
|
|
||||||
ApiScenarioWithBLOBs testPlanApiScenario=apiScenarioMapper.selectByPrimaryKey(testDtail.getTestId());
|
|
||||||
t.setId(UUID.randomUUID().toString());
|
|
||||||
t.setTestPlanId(request.getPlanId());
|
|
||||||
t.setApiScenarioId(testDtail.getTestId());
|
|
||||||
t.setLastResult(testPlanApiScenario.getLastResult());
|
|
||||||
t.setPassRate(testPlanApiScenario.getPassRate());
|
|
||||||
t.setReportId(testPlanApiScenario.getReportId());
|
|
||||||
t.setStatus(testPlanApiScenario.getStatus());
|
|
||||||
t.setCreateTime(System.currentTimeMillis());
|
|
||||||
t.setUpdateTime(System.currentTimeMillis());
|
|
||||||
TestPlanApiScenarioExample example=new TestPlanApiScenarioExample();
|
|
||||||
example.createCriteria().andTestPlanIdEqualTo(request.getPlanId()).andApiScenarioIdEqualTo(t.getApiScenarioId());
|
|
||||||
if(testPlanApiScenarioMapper.countByExample(example)<=0){
|
|
||||||
testPlanApiScenarioMapper.insert(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue