refactor and move scenario helper
This commit is contained in:
parent
12a1373199
commit
7ba32b6cf6
|
@ -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<BatchModel> getBatches(
|
||||
RunScenarioModel runScenarioModelNew) {
|
||||
List<BatchModel> result = new ArrayList<BatchModel>();
|
||||
for (PageModel page : runScenarioModelNew.getPages()) {
|
||||
result.addAll(page.getBatches());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static BehaviorModel createUserBehaviorModel(int id, String use,
|
||||
String name, List<ParameterModel> 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;
|
||||
}
|
||||
}
|
|
@ -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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue