refactor
This commit is contained in:
coderfengyun 2014-09-15 16:25:29 +08:00
parent 030794d5ca
commit 226e9ec522
7 changed files with 60 additions and 51 deletions

View File

@ -174,10 +174,10 @@ public class TestPlanController extends BaseController {
public ScriptBehaviorsBriefModel getBehaviorsBrief(
@PathVariable UUID testPlanRunID, @PathVariable int scriptId)
throws Bench4QException, NullPointerException {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
throw new Bench4QException(HAVE_NO_POWER, EXCEPTION_HAPPEND
+ "when get behaviors's brief", "/getBehaviorsBrief");
}
// if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
// throw new Bench4QException(HAVE_NO_POWER, EXCEPTION_HAPPEND
// + "when get behaviors's brief", "/getBehaviorsBrief");
// }
ScriptBehaviorsBriefModel result = this
.getTestPlanScriptResultService()
.getLatestScriptBehaviorsBrief(testPlanRunID, scriptId);
@ -189,10 +189,10 @@ public class TestPlanController extends BaseController {
public ScriptPagesBriefModel getPagesBrief(
@PathVariable UUID testPlanRunId, @PathVariable int scriptId)
throws Bench4QException {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
throw new Bench4QException(HAVE_NO_POWER, EXCEPTION_HAPPEND
+ "when get behaviors's brief", "/getBehaviorsBrief");
}
// if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
// throw new Bench4QException(HAVE_NO_POWER, EXCEPTION_HAPPEND
// + "when get behaviors's brief", "/getBehaviorsBrief");
// }
ScriptPagesBriefModel pagesBriefModel = this
.getTestPlanScriptResultService().getLatestScriptPagesBrief(
testPlanRunId, scriptId);

View File

@ -65,7 +65,7 @@ public class BehaviorBriefStatistics extends ScriptStatistics {
result.setTotalCountFromBegin(this.totalCountFromBegin);
for (BehaviorStatusCodeStatistics item : this.detailStatisticsMap
.values()) {
result.getList().add(
result.getDetailStatusList().add(
(ScriptBehaviorStatusCodeModel) item.getStatistics());
}
return result;

View File

@ -29,7 +29,7 @@ public class Test_BehaviorBriefStatistics {
assertEquals(8, result.getTotalCountFromBegin());
int countForAllDetail = 0;
for (ScriptBehaviorStatusCodeModel behaviorStatusCodeModel : result
.getList()) {
.getDetailStatusList()) {
countForAllDetail += behaviorStatusCodeModel.getCount();
}
assertEquals(result.getTotalCountFromBegin(), countForAllDetail);

View File

@ -13,10 +13,10 @@ public class ScriptBehaviorBriefModel {
private String BehaviorUrl;
private long successCountFromBegin;
private long totalCountFromBegin;
private List<ScriptBehaviorStatusCodeModel> list;
private List<ScriptBehaviorStatusCodeModel> detailStatusList;
public ScriptBehaviorBriefModel() {
this.setList(new LinkedList<ScriptBehaviorStatusCodeModel>());
this.setDetailStatusList(new LinkedList<ScriptBehaviorStatusCodeModel>());
}
@XmlElement
@ -57,12 +57,12 @@ public class ScriptBehaviorBriefModel {
@XmlElementWrapper(name = "statusResults")
@XmlElement
public List<ScriptBehaviorStatusCodeModel> getList() {
return list;
public List<ScriptBehaviorStatusCodeModel> getDetailStatusList() {
return detailStatusList;
}
public void setList(List<ScriptBehaviorStatusCodeModel> list) {
this.list = list;
public void setDetailStatusList(List<ScriptBehaviorStatusCodeModel> list) {
this.detailStatusList = list;
}
}

View File

@ -289,6 +289,7 @@ public class TestPlanController extends BaseController {
return fail(map, "");
}
map = success(map);
System.out.println(MarshalHelper.tryMarshal(scriptBehaviorsBriefModel));
map.put("behaviors", scriptBehaviorsBriefModel);
return map;
}

View File

@ -156,10 +156,9 @@ public class TestPlanService {
}
for (ScriptBehaviorBriefModel behaviorBriefModel : scriptBehaviorsBriefModel
.getBehaviorBriefModels()) {
if (behaviorBriefModel.getList() != null)
if (behaviorBriefModel.getDetailStatusList() != null)
behaviorStatusCodeResultModels.addAll(behaviorBriefModel
.getList());
.getDetailStatusList());
}
return behaviorStatusCodeResultModels;
}

View File

@ -4,8 +4,7 @@ function Behavior() {
this.getBehaviorResultsFirstly = function(testPlanId, map, scripts) {
for (var i = 0; i < scripts.length; i++) {
var url = testPlanId + "/" + scripts[i].scriptId
+ "/behaviors";
var url = testPlanId + "/" + scripts[i].scriptId + "/behaviors";
this.getBehaviorResult(url, map, scripts[i].scriptName, this.table);
}
@ -21,14 +20,15 @@ function Behavior() {
return;
}
this.intervalId = setInterval(function() {
this.intervalId = setInterval(
function() {
for (var i = 0; i < scripts.length; i++) {
var url = testPlanId + "/" + scripts[i].scriptId
+ "/behaviors";
behavior.getBehaviorResult(url, map, scripts[i].scriptName,
behavior.table);
behavior.getBehaviorResult(url, map,
scripts[i].scriptName, behavior.table);
}
}, 10000);
@ -67,10 +67,10 @@ function Behavior() {
for (var j = 0; j < behaviors.length; j++) {
var data = behaviors[j];
var rowNode = table.row.add(
[ "", data.behaviorUrl, names[k], data.totalCount,
data.successfulCount,
data.detailStatusCodeResultModels ]).draw()
.node();
[ "", data.behaviorUrl, names[k],
data.totalCountFromBegin,
data.successCountFromBegin,
data.detailStatusList ]).draw().node();
var td = $(rowNode).find("td")[0];
$(td).addClass("details-control");
}
@ -80,7 +80,13 @@ function Behavior() {
}
this.createDetailTable = function(url, detailDatas) {
var theader=[ $.i18n.prop('result-url'), $.i18n.prop('result-url-statusCode'), $.i18n.prop('result-url-count'), $.i18n.prop('result-url-contentLength'), $.i18n.prop('result-url-minRes'), $.i18n.prop('result-url-maxRes'), $.i18n.prop('result-url-totalRes')];
var theader = [ $.i18n.prop('result-url'),
$.i18n.prop('result-url-statusCode'),
$.i18n.prop('result-url-count'),
$.i18n.prop('result-url-contentLength'),
$.i18n.prop('result-url-minRes'),
$.i18n.prop('result-url-maxRes'),
$.i18n.prop('result-url-totalRes') ];
var table = $("<table></table>");
table.addClass("innerTable");
$(table).attr("style", "width: 100%;");
@ -106,7 +112,10 @@ function Behavior() {
this.createDetailRow = function(detailData, url, theader) {
var tr = $("<tr></tr>");
var dataArray = [url,detailData.statusCode,detailData.count,detailData.contentLength,detailData.minResponseTime,detailData.maxResponseTime,detailData.totalResponseTimeThisTime];
var dataArray = [ url, detailData.statusCode, detailData.count,
detailData.contentLength, detailData.minResponseTime,
detailData.maxResponseTime,
detailData.totalResponseTimeThisTime ];
dataArray[0] = url;
for (var i = 0; i < dataArray.length; i++) {
var td = $("<td></td>");