diff --git a/src/main/java/org/bench4q/share/helper/RunScenarioModelHelper.java b/src/main/java/org/bench4q/share/helper/RunScenarioModelHelper.java new file mode 100644 index 00000000..6adba146 --- /dev/null +++ b/src/main/java/org/bench4q/share/helper/RunScenarioModelHelper.java @@ -0,0 +1,34 @@ +package org.bench4q.share.helper; + +import java.util.ArrayList; +import java.util.List; + +import org.bench4q.share.models.agent.ParameterModel; +import org.bench4q.share.models.agent.RunScenarioModel; +import org.bench4q.share.models.agent.scriptrecord.BatchModel; +import org.bench4q.share.models.agent.scriptrecord.BehaviorModel; +import org.bench4q.share.models.agent.scriptrecord.PageModel; + +public class RunScenarioModelHelper { + public static List getBatches( + RunScenarioModel runScenarioModelNew) { + List result = new ArrayList(); + for (PageModel page : runScenarioModelNew.getPages()) { + result.addAll(page.getBatches()); + } + return result; + } + + public static BehaviorModel createUserBehaviorModel(int id, String use, + String name, List parameterModels) { + return BehaviorModel.UserBehaviorBuilder(id, name, use, + parameterModels); + } + + public static ParameterModel createParameterModel(String key, String value) { + ParameterModel parameterModel = new ParameterModel(); + parameterModel.setKey(key); + parameterModel.setValue(value); + return parameterModel; + } +} diff --git a/src/main/java/org/bench4q/share/helper/TestHelper.java b/src/main/java/org/bench4q/share/helper/TestHelper.java index 8deecd1e..45826b05 100644 --- a/src/main/java/org/bench4q/share/helper/TestHelper.java +++ b/src/main/java/org/bench4q/share/helper/TestHelper.java @@ -1,5 +1,7 @@ package org.bench4q.share.helper; +import java.io.File; +import java.io.IOException; import java.lang.reflect.Method; public class TestHelper { @@ -11,4 +13,16 @@ public class TestHelper { return method.invoke(targetObject, params); } + public static void createFileIfNotExist(File file) { + if (file.exists()) { + return; + } + if (!file.getParentFile().exists()) { + file.mkdirs(); + } + try { + file.createNewFile(); + } catch (IOException e) { + } + } }