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

@ -1,37 +1,37 @@
function Behavior() {
this.table = $("#url").DataTable();
this.table.column(5).visible(false);
this.getBehaviorResultsFirstly = function(testPlanId, map,scripts) {
this.getBehaviorResultsFirstly = function(testPlanId, map, scripts) {
for (var i = 0; i < scripts.length; i++) {
var url = testPlanId + "/" + scripts[i].scriptId + "/behaviors";
this.getBehaviorResult(url, map, scripts[i].scriptName, this.table);
}
for(var i=0;i<scripts.length;i++){
var url = testPlanId + "/" + scripts[i].scriptId
+ "/behaviors";
this.getBehaviorResult(url, map, scripts[i].scriptName, this.table);
}
}
this.loadBehaviorResults = function(testPlanId, scripts) {
var map = new HashMap();
this.getBehaviorResultsFirstly(testPlanId,map,scripts);
this.getBehaviorResultsFirstly(testPlanId, map, scripts);
var behavior = this;
if (scripts == null) {
return;
}
this.intervalId = setInterval(function() {
this.intervalId = setInterval(
function() {
for ( var i = 0; i < scripts.length; i++) {
for (var i = 0; i < scripts.length; i++) {
var url = testPlanId + "/" + scripts[i].scriptId
+ "/behaviors";
behavior.getBehaviorResult(url, map, scripts[i].scriptName,
behavior.table);
}
var url = testPlanId + "/" + scripts[i].scriptId
+ "/behaviors";
behavior.getBehaviorResult(url, map,
scripts[i].scriptName, behavior.table);
}
}, 10000);
}, 10000);
}
this.getBehaviorResult = function(url, map, scriptName, table) {
@ -44,12 +44,12 @@ function Behavior() {
map.put(scriptName, data);
behaviorResult.insertDataToTable(table, map);
if ($("#status").attr("status") == "Complete") {
if(behaviorResult.intervalId!=null){
if (behaviorResult.intervalId != null) {
clearInterval(behaviorResult.intervalId);
}
}
}, "json").error(function(){
}, "json").error(function() {
information($.i18n.prop('failed-connect-server'));
});
@ -57,20 +57,20 @@ function Behavior() {
this.insertDataToTable = function(table, map) {
table.clear();
for ( var k = 0; k < map.length(); k++) {
for (var k = 0; k < map.length(); k++) {
var names = map.getKeys();
var behaviors = map.get(names[k]).behaviorBriefModels;
if (behaviors == null) {
return;
}
for ( var j = 0; j < behaviors.length; j++) {
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,14 +80,20 @@ 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%;");
var thead = $("<thead></thead>");
var tr = $("<tr></tr>");
for ( var i = 0; i < theader.length; i++) {
for (var i = 0; i < theader.length; i++) {
var th = $("<th>" + theader[i] + "</th>");
th.attr("style", "width:10% ;");
tr.append(th);
@ -96,7 +102,7 @@ function Behavior() {
table.append(thead);
var tbody = $("<tbody></tbody>");
table.append(tbody);
for ( var i = 0; i < detailDatas.length; i++) {
for (var i = 0; i < detailDatas.length; i++) {
var tr = this.createDetailRow(detailDatas[i], url, theader)
tbody.append(tr);
@ -106,9 +112,12 @@ 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++) {
for (var i = 0; i < dataArray.length; i++) {
var td = $("<td></td>");
td.attr("style", "width: 10%;");
td.html(dataArray[i]);