package org.bench4q.recorder;

import java.util.ArrayList;
import java.util.List;

import org.bench4q.recorder.httpcapture.Bench4qTestScriptAdapter;
import org.bench4q.recorder.httpcapture.IScriptAdapter;
import org.bench4q.recorder.httpcapture.generator.Bench4qCodeGenerator;
import org.bench4q.share.models.agent.ParameterModel;
import org.bench4q.share.models.agent.RunScenarioModel;
import org.bench4q.share.models.agent.scriptrecord.BehaviorModel;

public abstract class TestRecordBase {
	private IScriptAdapter adapter;
	private Bench4qCodeGenerator codeGenerator;
	protected static String parentUrl = "http://localhost:8080/Bench4QTestCase/testcase.html";
	protected static String independentUrl = "www.baidu.com";
	protected static String childrenUrl1 = "http://localhost:8080/Bench4QTestCase/script/agenttable.js";

	protected IScriptAdapter getAdpater() {
		return adapter;
	}

	private void setAdpater(IScriptAdapter adapter) {
		this.adapter = adapter;
	}

	protected Bench4qCodeGenerator getCodeGenerator() {
		return codeGenerator;
	}

	private void setCodeGenerator(Bench4qCodeGenerator codeGenerator) {
		this.codeGenerator = codeGenerator;
	}

	protected void init() {
		this.setAdpater(new Bench4qTestScriptAdapter(new RunScenarioModel()));
		this.setCodeGenerator(new Bench4qCodeGenerator(this.getAdpater()));
	}

	protected BehaviorModel createUserBehaviorModel(String url) {
		List<ParameterModel> params = new ArrayList<ParameterModel>();
		ParameterModel param = new ParameterModel();
		param.setKey("url");
		param.setValue(url);
		params.add(param);
		return BehaviorModel.UserBehaviorBuilder(1, "Get", "http", params);
	}
}
