From 0d99d287242b899cef7f3c3f95eeb9f786bf3256 Mon Sep 17 00:00:00 2001 From: coderfengyun Date: Tue, 24 Dec 2013 16:45:43 +0800 Subject: [PATCH] refactor, and add pagebrief --- .../org/bench4q/master/api/TestPlanController.java | 9 ++++++++- .../datastatistics/BehaviorsBriefStatistics.java | 11 ++++++----- .../bench4q/master/datastatistics/DataStatistics.java | 2 +- .../master/datastatistics/ScriptBriefStatistics.java | 4 ++-- .../service/communication/RunningAgentService.java | 10 +++++----- .../service/communication/RunningScriptService.java | 6 +++--- .../master/test/ScriptBriefStatisticsTest.java | 2 +- 7 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/bench4q/master/api/TestPlanController.java b/src/main/java/org/bench4q/master/api/TestPlanController.java index 3a6e819e..e37b2b61 100644 --- a/src/main/java/org/bench4q/master/api/TestPlanController.java +++ b/src/main/java/org/bench4q/master/api/TestPlanController.java @@ -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) { + + } } diff --git a/src/main/java/org/bench4q/master/datastatistics/BehaviorsBriefStatistics.java b/src/main/java/org/bench4q/master/datastatistics/BehaviorsBriefStatistics.java index 139d1b4a..ec657e60 100644 --- a/src/main/java/org/bench4q/master/datastatistics/BehaviorsBriefStatistics.java +++ b/src/main/java/org/bench4q/master/datastatistics/BehaviorsBriefStatistics.java @@ -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> map; @@ -26,7 +27,7 @@ public class BehaviorsBriefStatistics implements DataStatistics { } public Object getStatistics() { - TestBehaviorsBriefModel ret = new TestBehaviorsBriefModel(); + AgentBehaviorsBriefModel ret = new AgentBehaviorsBriefModel(); List list = new ArrayList(); 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())) { diff --git a/src/main/java/org/bench4q/master/datastatistics/DataStatistics.java b/src/main/java/org/bench4q/master/datastatistics/DataStatistics.java index 6dd27b92..98d089c4 100644 --- a/src/main/java/org/bench4q/master/datastatistics/DataStatistics.java +++ b/src/main/java/org/bench4q/master/datastatistics/DataStatistics.java @@ -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); diff --git a/src/main/java/org/bench4q/master/datastatistics/ScriptBriefStatistics.java b/src/main/java/org/bench4q/master/datastatistics/ScriptBriefStatistics.java index 165e9547..2cf47de8 100644 --- a/src/main/java/org/bench4q/master/datastatistics/ScriptBriefStatistics.java +++ b/src/main/java/org/bench4q/master/datastatistics/ScriptBriefStatistics.java @@ -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 { diff --git a/src/main/java/org/bench4q/master/service/communication/RunningAgentService.java b/src/main/java/org/bench4q/master/service/communication/RunningAgentService.java index 30af4116..175fc108 100644 --- a/src/main/java/org/bench4q/master/service/communication/RunningAgentService.java +++ b/src/main/java/org/bench4q/master/service/communication/RunningAgentService.java @@ -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"); diff --git a/src/main/java/org/bench4q/master/service/communication/RunningScriptService.java b/src/main/java/org/bench4q/master/service/communication/RunningScriptService.java index 5c3d7f7a..6fb4a631 100644 --- a/src/main/java/org/bench4q/master/service/communication/RunningScriptService.java +++ b/src/main/java/org/bench4q/master/service/communication/RunningScriptService.java @@ -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; diff --git a/src/test/java/org/bench4q/master/test/ScriptBriefStatisticsTest.java b/src/test/java/org/bench4q/master/test/ScriptBriefStatisticsTest.java index 286fb419..8c5f8652 100644 --- a/src/test/java/org/bench4q/master/test/ScriptBriefStatisticsTest.java +++ b/src/test/java/org/bench4q/master/test/ScriptBriefStatisticsTest.java @@ -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;