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