parent
73c26d9439
commit
b0faf5b729
|
@ -14,7 +14,8 @@ import org.bench4q.share.models.agent.statistics.BehaviorBriefModel;
|
|||
public class ControlBehavior extends PluginImplementBehavior {
|
||||
|
||||
public ControlBehavior(BehaviorModel behaviorModel) {
|
||||
if (behaviorModel.getType() != Behavior.CONTROL_BEHAVIOR) {
|
||||
if (!behaviorModel.getType()
|
||||
.equalsIgnoreCase(Behavior.CONTROL_BEHAVIOR)) {
|
||||
throw new Bench4QRunTimeException(
|
||||
"Not the right type, here we need CONTROL_BEHAVIOR, but it is"
|
||||
+ behaviorModel.getType());
|
||||
|
|
|
@ -5,6 +5,7 @@ import static org.junit.Assert.*;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
import org.bench4q.agent.scenario.instruction.ControlInstruction;
|
||||
|
@ -82,6 +83,11 @@ public class Test_Behavior {
|
|||
|
||||
@Test
|
||||
public void testCompileIfBehavior2Instruction() {
|
||||
// Behavior behavior = Behavior.buildWith(BehaviorModel.)
|
||||
List<BehaviorModel> elseBehaviors = new ArrayList<BehaviorModel>(), thenBehaviors = new ArrayList<BehaviorModel>();
|
||||
Behavior behavior = Behavior.buildWith(BehaviorModel
|
||||
.IfBehaviorBuilder(BehaviorModel.testBehaviorBuilder(1,
|
||||
"isDefined", "context", Arrays.asList(ParameterModel
|
||||
.createParameter("name", "a")))),
|
||||
thenBehaviors, elseBehaviors);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,9 +31,9 @@ public class MainController {
|
|||
return new LimitableFieldsModel();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/startMonitor/{testPlanId}", method = RequestMethod.PUT)
|
||||
@RequestMapping(value = "/{testPlanId}", method = RequestMethod.PUT)
|
||||
@ResponseBody
|
||||
public String start(@PathVariable UUID testPlanId,
|
||||
public String submitLimit(@PathVariable UUID testPlanId,
|
||||
@RequestBody LimitModel limits) {
|
||||
return new String("startted");
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.bench4q.share.models.agent.ParameterModel;
|
|||
public class BehaviorModel {
|
||||
private static final String USER_BEHAVIOR = "USERBEHAVIOR";
|
||||
private static final String TIMER_BEHAVIOR = "TIMERBEHAVIOR";
|
||||
private static final String TEST_BEHAVIOR = "TESTBEHAVIOR";
|
||||
private int id;
|
||||
private String use;
|
||||
private String name;
|
||||
|
@ -64,10 +65,6 @@ public class BehaviorModel {
|
|||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
//
|
||||
// public BehaviorModel() {
|
||||
// }
|
||||
|
||||
public static BehaviorModel TimerBehaviorBuilder(int id, String name,
|
||||
String use, List<ParameterModel> parameters) {
|
||||
BehaviorModel behaviorBaseModel = buildBehaviorModelWithoutType(id,
|
||||
|
@ -94,6 +91,14 @@ public class BehaviorModel {
|
|||
return behaviorBaseModel;
|
||||
}
|
||||
|
||||
public static BehaviorModel testBehaviorBuilder(int id, String name,
|
||||
String use, List<ParameterModel> params) {
|
||||
BehaviorModel result = buildBehaviorModelWithoutType(id, name, use,
|
||||
params);
|
||||
result.setType(TEST_BEHAVIOR);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static BehaviorModel ControlBehaviorBuilder(int id, String name,
|
||||
String use, List<ParameterModel> parameters) {
|
||||
BehaviorModel result = buildBehaviorModelWithoutType(id, name, use,
|
||||
|
@ -102,4 +107,10 @@ public class BehaviorModel {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static BehaviorModel IfBehaviorBuilder(
|
||||
BehaviorModel testBehaviorBuilder) {
|
||||
// TODo:
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue