package org.bench4q.recorder;

import static org.junit.Assert.*;

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

import org.bench4q.recorder.httpcapture.Bench4qTestScriptAdapter;
import org.bench4q.share.helper.RunScenarioModelHelper;
import org.bench4q.share.models.agent.ParameterModel;
import org.bench4q.share.models.agent.RunScenarioModel;
import org.junit.Test;

public class TestBench4qTestScriptAdapter {
	private Bench4qTestScriptAdapter bench4qTestScriptAdapter;

	private Bench4qTestScriptAdapter getBench4qTestScriptAdapter() {
		return bench4qTestScriptAdapter;
	}

	private void setBench4qTestScriptAdapter(
			Bench4qTestScriptAdapter bench4qTestScriptAdapter) {
		this.bench4qTestScriptAdapter = bench4qTestScriptAdapter;
	}

	public TestBench4qTestScriptAdapter() {
		this.setBench4qTestScriptAdapter(new Bench4qTestScriptAdapter(
				new RunScenarioModel()));
	}

	@Test
	public void testInsertUserBehaviorsToScenario() {
		List<ParameterModel> params = new ArrayList<ParameterModel>();
		params.add(RunScenarioModelHelper.createParameterModel("url",
				"www.baidu.com"));
		this.getBench4qTestScriptAdapter().insertUserBehaviorsToScenario(
				RunScenarioModelHelper.createUserBehaviorModel(0, "http",
						"get", params));
		assertEquals(
				1,
				RunScenarioModelHelper.getBatches(
						this.getBench4qTestScriptAdapter()
								.getRunScenarioModel()).size());
	}
}
