refactor for behaviorsBrief
This commit is contained in:
parent
9cdaf9462e
commit
c32e58c19d
|
@ -223,7 +223,6 @@ public class TestController {
|
|||
behaviorBriefModel.setBehaviorId(behaviorId);
|
||||
behaviorBriefModel
|
||||
.setDetailStatusCodeResultModels(detailStatusCodeResultModels);
|
||||
behaviorBriefModel.setTestId(runId);
|
||||
return behaviorBriefModel;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,28 +1,16 @@
|
|||
package org.bench4q.agent.api.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "BehaviorBriefModel")
|
||||
public class BehaviorBriefModel {
|
||||
private UUID testId;
|
||||
private int behaviorId;
|
||||
private int behaviorUrl;
|
||||
private String behaviorUrl;
|
||||
private List<BehaviorStatusCodeResultModel> detailStatusCodeResultModels;
|
||||
|
||||
@XmlElement
|
||||
public UUID getTestId() {
|
||||
return testId;
|
||||
}
|
||||
|
||||
public void setTestId(UUID testId) {
|
||||
this.testId = testId;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public int getBehaviorId() {
|
||||
return behaviorId;
|
||||
|
@ -33,11 +21,11 @@ public class BehaviorBriefModel {
|
|||
}
|
||||
|
||||
@XmlElement
|
||||
public int getBehaviorUrl() {
|
||||
public String getBehaviorUrl() {
|
||||
return behaviorUrl;
|
||||
}
|
||||
|
||||
public void setBehaviorUrl(int behaviorUrl) {
|
||||
public void setBehaviorUrl(String behaviorUrl) {
|
||||
this.behaviorUrl = behaviorUrl;
|
||||
}
|
||||
|
||||
|
|
|
@ -84,14 +84,10 @@ public class AgentResultDataCollector extends AbstractDataCollector {
|
|||
return testID == null ? "default" : testID.toString();
|
||||
}
|
||||
|
||||
public void setTestID(UUID testID) {
|
||||
private void setTestID(UUID testID) {
|
||||
this.testID = testID;
|
||||
}
|
||||
|
||||
public Map<Integer, Map<Integer, DetailStatusCodeResult>> getDetailMap() {
|
||||
return detailMap;
|
||||
}
|
||||
|
||||
private void setDetailMap(
|
||||
Map<Integer, Map<Integer, DetailStatusCodeResult>> detailMap) {
|
||||
this.detailMap = detailMap;
|
||||
|
@ -103,7 +99,7 @@ public class AgentResultDataCollector extends AbstractDataCollector {
|
|||
init();
|
||||
}
|
||||
|
||||
public void init() {
|
||||
private void init() {
|
||||
reset();
|
||||
this.setCumulativeFailCount(0);
|
||||
this.setCumulativeSucessfulCount(0);
|
||||
|
@ -191,16 +187,15 @@ public class AgentResultDataCollector extends AbstractDataCollector {
|
|||
}
|
||||
|
||||
private void dealWithDetailResult(BehaviorResult behaviorResult) {
|
||||
if (!this.detailMap.containsKey(behaviorResult.getBehaviorId())) {
|
||||
this.detailMap.put(new Integer(behaviorResult.getBehaviorId()),
|
||||
new HashMap<Integer, DetailStatusCodeResult>());
|
||||
}
|
||||
insertWhenNotExist(behaviorResult);
|
||||
Map<Integer, DetailStatusCodeResult> detailStatusMap = this.detailMap
|
||||
.get(behaviorResult.getBehaviorId());
|
||||
|
||||
if (!detailStatusMap.containsKey(behaviorResult.getStatusCode())) {
|
||||
detailStatusMap.put(new Integer(behaviorResult.getStatusCode()),
|
||||
new DetailStatusCodeResult());
|
||||
detailStatusMap
|
||||
.put(new Integer(behaviorResult.getStatusCode()),
|
||||
new DetailStatusCodeResult(behaviorResult
|
||||
.getContentType()));
|
||||
}
|
||||
|
||||
DetailStatusCodeResult detailResult = detailStatusMap
|
||||
|
@ -212,7 +207,6 @@ public class AgentResultDataCollector extends AbstractDataCollector {
|
|||
detailResult.contentLength = 0;
|
||||
return;
|
||||
}
|
||||
detailResult.contentType = behaviorResult.getContentType();
|
||||
detailResult.contentLength += behaviorResult.getContentLength();
|
||||
if (behaviorResult.getResponseTime() > detailResult.maxResponseTime) {
|
||||
detailResult.maxResponseTime = behaviorResult.getResponseTime();
|
||||
|
@ -222,6 +216,13 @@ public class AgentResultDataCollector extends AbstractDataCollector {
|
|||
}
|
||||
}
|
||||
|
||||
private void insertWhenNotExist(BehaviorResult behaviorResult) {
|
||||
if (!this.detailMap.containsKey(behaviorResult.getBehaviorId())) {
|
||||
this.detailMap.put(new Integer(behaviorResult.getBehaviorId()),
|
||||
new HashMap<Integer, DetailStatusCodeResult>());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(BehaviorResult behaviorResult) {
|
||||
super.add(behaviorResult);
|
||||
|
|
|
@ -9,7 +9,8 @@ public class DetailStatusCodeResult {
|
|||
public long maxResponseTime;
|
||||
public String contentType;
|
||||
|
||||
public DetailStatusCodeResult() {
|
||||
public DetailStatusCodeResult(String contentType) {
|
||||
this.contentType = contentType;
|
||||
this.count = 0;
|
||||
this.contentLength = 0;
|
||||
this.minResponseTime = Long.MAX_VALUE;
|
||||
|
|
|
@ -66,7 +66,7 @@ public class DetailStatisticsTest {
|
|||
}
|
||||
|
||||
private DetailStatusCodeResult makeExpectedResultForOne() {
|
||||
DetailStatusCodeResult ret = new DetailStatusCodeResult();
|
||||
DetailStatusCodeResult ret = new DetailStatusCodeResult("");
|
||||
ret.contentLength = 20;
|
||||
ret.count = 1;
|
||||
ret.maxResponseTime = 200;
|
||||
|
@ -95,7 +95,7 @@ public class DetailStatisticsTest {
|
|||
|
||||
private DetailStatusCodeResult buildCodeResult(long contentLength,
|
||||
long count, long maxResponseTime, long minResponseTime) {
|
||||
DetailStatusCodeResult ret = new DetailStatusCodeResult();
|
||||
DetailStatusCodeResult ret = new DetailStatusCodeResult("");
|
||||
ret.contentLength = contentLength;
|
||||
ret.count = count;
|
||||
ret.maxResponseTime = maxResponseTime;
|
||||
|
|
Loading…
Reference in New Issue