refactor
This commit is contained in:
parent
ba91fbfb5b
commit
84ca3d8ccc
|
@ -19,7 +19,6 @@ import org.bench4q.master.domain.TestPlanInBusiness;
|
||||||
import org.bench4q.master.entity.TestPlanDB;
|
import org.bench4q.master.entity.TestPlanDB;
|
||||||
import org.bench4q.master.exception.Bench4QException;
|
import org.bench4q.master.exception.Bench4QException;
|
||||||
import org.bench4q.master.report.ReportService;
|
import org.bench4q.master.report.ReportService;
|
||||||
import org.bench4q.master.service.communication.RunningScriptService;
|
|
||||||
import org.bench4q.master.service.infrastructure.TestPlanService;
|
import org.bench4q.master.service.infrastructure.TestPlanService;
|
||||||
import org.bench4q.master.service.infrastructure.UserService;
|
import org.bench4q.master.service.infrastructure.UserService;
|
||||||
import org.bench4q.master.testplan.TestPlanContainer;
|
import org.bench4q.master.testplan.TestPlanContainer;
|
||||||
|
@ -56,7 +55,6 @@ public class TestPlanController extends BaseController {
|
||||||
private TestPlanContainer testPlanContainer;
|
private TestPlanContainer testPlanContainer;
|
||||||
private TestPlanService testPlanService;
|
private TestPlanService testPlanService;
|
||||||
private ReportService reportService;
|
private ReportService reportService;
|
||||||
private RunningScriptService runningScriptService;
|
|
||||||
private Logger logger;
|
private Logger logger;
|
||||||
|
|
||||||
private TestPlanEngine getTestPlanRunner() {
|
private TestPlanEngine getTestPlanRunner() {
|
||||||
|
@ -95,16 +93,6 @@ public class TestPlanController extends BaseController {
|
||||||
this.reportService = reportService;
|
this.reportService = reportService;
|
||||||
}
|
}
|
||||||
|
|
||||||
private RunningScriptService getRunningScriptService() {
|
|
||||||
return runningScriptService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private void setRunningScriptService(
|
|
||||||
RunningScriptService runningScriptService) {
|
|
||||||
this.runningScriptService = runningScriptService;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Logger getLogger() {
|
private Logger getLogger() {
|
||||||
return logger;
|
return logger;
|
||||||
}
|
}
|
||||||
|
@ -192,7 +180,7 @@ public class TestPlanController extends BaseController {
|
||||||
runningScriptModels, monitorModels);
|
runningScriptModels, monitorModels);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/getScriptBrief/{testPlanId}/{scriptId}", method = RequestMethod.GET)
|
@RequestMapping(value = "/scriptBrief/{testPlanId}/{scriptId}", method = RequestMethod.GET)
|
||||||
@ResponseStatus(value = HttpStatus.OK)
|
@ResponseStatus(value = HttpStatus.OK)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ScriptBriefResultModel getScriptBrief(@PathVariable UUID testPlanId,
|
public ScriptBriefResultModel getScriptBrief(@PathVariable UUID testPlanId,
|
||||||
|
@ -219,7 +207,7 @@ public class TestPlanController extends BaseController {
|
||||||
ret.setFinished(true);
|
ret.setFinished(true);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ret = this.getRunningScriptService().getScriptBrief(runningScript);
|
ret = runningScript.getScriptBrief();
|
||||||
ret.setPlanedRunningTime(runningScript.getConfig().getExecuteRange());
|
ret.setPlanedRunningTime(runningScript.getConfig().getExecuteRange());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -344,7 +332,7 @@ public class TestPlanController extends BaseController {
|
||||||
ret.setFinished(true);
|
ret.setFinished(true);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
return this.getRunningScriptService().getBehaviorsBrief(runningScript);
|
return runningScript.getBehaviorsBrief();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void guardForTestPlan(UUID testPlanRunID) throws Bench4QException {
|
private void guardForTestPlan(UUID testPlanRunID) throws Bench4QException {
|
||||||
|
@ -371,7 +359,6 @@ public class TestPlanController extends BaseController {
|
||||||
throw new Bench4QException(EXCEPTION_HAPPEND + " RunningScript",
|
throw new Bench4QException(EXCEPTION_HAPPEND + " RunningScript",
|
||||||
"", "/pageBrief/{testPlanRunId}/{scriptId}/{pageId}");
|
"", "/pageBrief/{testPlanRunId}/{scriptId}/{pageId}");
|
||||||
}
|
}
|
||||||
return this.getRunningScriptService().getPageBrief(runningScript,
|
return runningScript.getPageBrief(pageId);
|
||||||
pageId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -262,7 +262,7 @@ public class RunningScript extends Observable {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScriptPageBriefModel getPageBriefModel(int pageId) {
|
public ScriptPageBriefModel getPageBrief(int pageId) {
|
||||||
for (RunningAgent runningAgent : getRunningAgents()) {
|
for (RunningAgent runningAgent : getRunningAgents()) {
|
||||||
this.getPageBriefStatistics().add(
|
this.getPageBriefStatistics().add(
|
||||||
this.getRunningAgentService().pageBrief(
|
this.getRunningAgentService().pageBrief(
|
||||||
|
@ -317,7 +317,7 @@ public class RunningScript extends Observable {
|
||||||
public void run() {
|
public void run() {
|
||||||
getScriptBrief();
|
getScriptBrief();
|
||||||
for (int i = 0; i < getScenario().getPages().size(); i++) {
|
for (int i = 0; i < getScenario().getPages().size(); i++) {
|
||||||
getPageBriefModel(i);
|
getPageBrief(i);
|
||||||
}
|
}
|
||||||
getBehaviorsBrief();
|
getBehaviorsBrief();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,62 +0,0 @@
|
||||||
package org.bench4q.master.service.communication;
|
|
||||||
|
|
||||||
import org.bench4q.master.domain.RunningScript;
|
|
||||||
import org.bench4q.master.service.infrastructure.TestPlanScriptService;
|
|
||||||
import org.bench4q.share.models.master.statistics.ScriptBehaviorsBriefModel;
|
|
||||||
import org.bench4q.share.models.master.statistics.ScriptBriefResultModel;
|
|
||||||
import org.bench4q.share.models.master.statistics.ScriptPageBriefModel;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class RunningScriptService {
|
|
||||||
private TestPlanScriptService testPlanScriptService;
|
|
||||||
|
|
||||||
private TestPlanScriptService getTestPlanScriptService() {
|
|
||||||
return testPlanScriptService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private void setTestPlanScriptService(
|
|
||||||
TestPlanScriptService testPlanScriptService) {
|
|
||||||
this.testPlanScriptService = testPlanScriptService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ScriptBriefResultModel getScriptBrief(RunningScript runningScript)
|
|
||||||
throws NullPointerException {
|
|
||||||
guardRunningScriptExist(runningScript);
|
|
||||||
ScriptBriefResultModel result = runningScript.getScriptBrief();
|
|
||||||
this.getTestPlanScriptService().saveScriptBriefResult(
|
|
||||||
runningScript.getTestPlanID(), runningScript.getScriptId(),
|
|
||||||
result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void guardRunningScriptExist(RunningScript runningScript)
|
|
||||||
throws NullPointerException {
|
|
||||||
if (RunningScript.notValidScript(runningScript)) {
|
|
||||||
throw new NullPointerException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ScriptBehaviorsBriefModel getBehaviorsBrief(
|
|
||||||
RunningScript runningScript) throws NullPointerException {
|
|
||||||
guardRunningScriptExist(runningScript);
|
|
||||||
ScriptBehaviorsBriefModel result = runningScript.getBehaviorsBrief();
|
|
||||||
this.getTestPlanScriptService().saveBehaviorsBriefResult(
|
|
||||||
runningScript.getTestPlanID(), runningScript.getScriptId(),
|
|
||||||
result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ScriptPageBriefModel getPageBrief(RunningScript runningScript,
|
|
||||||
int pageId) throws NullPointerException {
|
|
||||||
guardRunningScriptExist(runningScript);
|
|
||||||
ScriptPageBriefModel result = runningScript.getPageBriefModel(pageId);
|
|
||||||
this.getTestPlanScriptService().savePageBriefResult(
|
|
||||||
runningScript.getTestPlanID(), runningScript.getScriptId(),
|
|
||||||
result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -204,7 +204,7 @@ public class TestPlanTester extends TestBase_MakeUpTestPlan {
|
||||||
public ScriptBriefResultModel getScriptBrief(UUID testPlanId, int scriptId)
|
public ScriptBriefResultModel getScriptBrief(UUID testPlanId, int scriptId)
|
||||||
throws IOException, JAXBException {
|
throws IOException, JAXBException {
|
||||||
HttpResponse httpResponse = this.httpRequester.sendGet(this._url
|
HttpResponse httpResponse = this.httpRequester.sendGet(this._url
|
||||||
+ "/getScriptBrief/" + testPlanId.toString() + "/" + scriptId,
|
+ "/scriptBrief/" + testPlanId.toString() + "/" + scriptId,
|
||||||
null, createAccessTokenMap());
|
null, createAccessTokenMap());
|
||||||
System.out.println(httpResponse.getContent());
|
System.out.println(httpResponse.getContent());
|
||||||
ScriptBriefResultModel ret = (ScriptBriefResultModel) MarshalHelper
|
ScriptBriefResultModel ret = (ScriptBriefResultModel) MarshalHelper
|
||||||
|
|
Loading…
Reference in New Issue