refactor and move scenario helper

This commit is contained in:
coderfengyun 2014-03-19 17:45:31 +08:00
parent 12a1373199
commit 7ba32b6cf6
2 changed files with 48 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -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) {
}
}
}