refactor, and add pagebrief

This commit is contained in:
coderfengyun 2013-12-24 16:45:43 +08:00
parent 47bc1e946d
commit 0d99d28724
7 changed files with 26 additions and 18 deletions

View File

@ -328,7 +328,7 @@ public class TestPlanController extends BaseController {
@RequestMapping(value = "/getBehaviorsBrief/{testPlanRunID}/{scriptId}", method = RequestMethod.GET)
@ResponseBody
public ScriptBehaviorsBriefModel getBehaviorBrief(
public ScriptBehaviorsBriefModel getBehaviorsBrief(
@PathVariable UUID testPlanRunID, @PathVariable int scriptId)
throws Bench4QException {
ScriptBehaviorsBriefModel ret = new ScriptBehaviorsBriefModel();
@ -357,4 +357,11 @@ public class TestPlanController extends BaseController {
return this.getRunningScriptService().getBehaviorsBrief(testPlanRunID,
runningScript, new BehaviorsBriefStatistics());
}
@RequestMapping(value = "/pageBrief/{testPlanRunId}/{scriptId}/{pageId}")
@ResponseBody
public void getPageBrief(@PathVariable UUID testPlanRunId,
@PathVariable int scriptId, @PathVariable int pageId) {
}
}

View File

@ -4,10 +4,11 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bench4q.share.models.agent.BehaviorBriefModel;
import org.bench4q.share.models.agent.BehaviorStatusCodeResultModel;
import org.bench4q.share.models.agent.DataStatisticsModel;
import org.bench4q.share.models.agent.TestBehaviorsBriefModel;
import org.bench4q.share.models.agent.statistics.DataStatisticsModel;
import org.bench4q.share.models.agent.statistics.AgentBehaviorsBriefModel;
public class BehaviorsBriefStatistics implements DataStatistics {
private Map<Integer, Map<Integer, BehaviorStatusCodeResultModel>> map;
@ -26,7 +27,7 @@ public class BehaviorsBriefStatistics implements DataStatistics {
}
public Object getStatistics() {
TestBehaviorsBriefModel ret = new TestBehaviorsBriefModel();
AgentBehaviorsBriefModel ret = new AgentBehaviorsBriefModel();
List<BehaviorBriefModel> list = new ArrayList<BehaviorBriefModel>();
for (int behaviorId : this.getMap().keySet()) {
BehaviorBriefModel behaviorBriefModel = new BehaviorBriefModel();
@ -59,10 +60,10 @@ public class BehaviorsBriefStatistics implements DataStatistics {
}
public void add(DataStatisticsModel dataUnit) {
if (!(dataUnit instanceof TestBehaviorsBriefModel)) {
if (!(dataUnit instanceof AgentBehaviorsBriefModel)) {
return;
}
TestBehaviorsBriefModel input = (TestBehaviorsBriefModel) dataUnit;
AgentBehaviorsBriefModel input = (AgentBehaviorsBriefModel) dataUnit;
for (BehaviorBriefModel behaviorBriefModel : input
.getBehaviorBriefModels()) {
if (!this.getMap().containsKey(behaviorBriefModel.getBehaviorId())) {

View File

@ -1,6 +1,6 @@
package org.bench4q.master.datastatistics;
import org.bench4q.share.models.agent.DataStatisticsModel;
import org.bench4q.share.models.agent.statistics.DataStatisticsModel;
public interface DataStatistics {
public void add(DataStatisticsModel dataUnit);

View File

@ -1,7 +1,7 @@
package org.bench4q.master.datastatistics;
import org.bench4q.share.models.agent.AgentBriefStatusModel;
import org.bench4q.share.models.agent.DataStatisticsModel;
import org.bench4q.share.models.agent.statistics.AgentBriefStatusModel;
import org.bench4q.share.models.agent.statistics.DataStatisticsModel;
import org.bench4q.share.models.master.ScriptBriefResultModel;
public class ScriptBriefStatistics implements DataStatistics {

View File

@ -12,11 +12,11 @@ import org.bench4q.master.testplan.highavailable.faultolerence.BriefAgentFault;
import org.bench4q.share.communication.HttpRequester;
import org.bench4q.share.communication.HttpRequester.HttpResponse;
import org.bench4q.share.helper.MarshalHelper;
import org.bench4q.share.models.agent.AgentBriefStatusModel;
import org.bench4q.share.models.agent.RunScenarioModel;
import org.bench4q.share.models.agent.RunScenarioResultModel;
import org.bench4q.share.models.agent.StopTestModel;
import org.bench4q.share.models.agent.TestBehaviorsBriefModel;
import org.bench4q.share.models.agent.statistics.AgentBriefStatusModel;
import org.bench4q.share.models.agent.statistics.AgentBehaviorsBriefModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -100,7 +100,7 @@ public class RunningAgentService {
return agent.getHostName() + ":" + agent.getPort();
}
public TestBehaviorsBriefModel behaviorsBrief(Agent agent, UUID runId) {
public AgentBehaviorsBriefModel behaviorsBrief(Agent agent, UUID runId) {
try {
HttpResponse httpResponse = this.getHttpRequester().sendGet(
buildBaseUrl(agent) + "/test/behaviorsBrief/"
@ -108,8 +108,8 @@ public class RunningAgentService {
if (HttpRequester.isInvalidResponse(httpResponse)) {
return null;
}
return (TestBehaviorsBriefModel) MarshalHelper.unmarshal(
TestBehaviorsBriefModel.class, httpResponse.getContent());
return (AgentBehaviorsBriefModel) MarshalHelper.unmarshal(
AgentBehaviorsBriefModel.class, httpResponse.getContent());
} catch (Exception e) {
logger.error(ExceptionLog.getExceptionStackTrace(e)
+ " When behaviorsBrief");

View File

@ -6,8 +6,8 @@ import org.bench4q.master.datastatistics.DataStatistics;
import org.bench4q.master.service.db.TestPlanScriptService;
import org.bench4q.master.testplan.entity.RunningAgent;
import org.bench4q.master.testplan.entity.RunningScript;
import org.bench4q.share.models.agent.AgentBriefStatusModel;
import org.bench4q.share.models.agent.TestBehaviorsBriefModel;
import org.bench4q.share.models.agent.statistics.AgentBriefStatusModel;
import org.bench4q.share.models.agent.statistics.AgentBehaviorsBriefModel;
import org.bench4q.share.models.master.ScriptBehaviorsBriefModel;
import org.bench4q.share.models.master.ScriptBriefResultModel;
import org.springframework.beans.factory.annotation.Autowired;
@ -74,7 +74,7 @@ public class RunningScriptService {
ScriptBehaviorsBriefModel result = new ScriptBehaviorsBriefModel();
result.setFinished(false);
result.setTestBehaviorsBriefModel((TestBehaviorsBriefModel) dataStatistics
result.setTestBehaviorsBriefModel((AgentBehaviorsBriefModel) dataStatistics
.getStatistics());
// TODO: save this in the database
return result;

View File

@ -3,7 +3,7 @@ package org.bench4q.master.test;
import static org.junit.Assert.*;
import org.bench4q.master.datastatistics.ScriptBriefStatistics;
import org.bench4q.share.models.agent.AgentBriefStatusModel;
import org.bench4q.share.models.agent.statistics.AgentBriefStatusModel;
import org.bench4q.share.models.master.ScriptBriefResultModel;
import org.junit.Test;