/**
 * DefaultHandlerTest.java
 * Created on Jul 31, 2008
 * (C) Copyright TANDBERG Television Ltd.
 */
package com.tandbergtv.watchpoint.pmm.job.unitTests;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import junit.framework.TestCase;

import com.tandbergtv.watchpoint.pmm.dao.hibernate.HibernateContext;
import com.tandbergtv.watchpoint.pmm.entities.JobParameter;
import com.tandbergtv.watchpoint.pmm.job.handler.DefaultHandler;
import com.tandbergtv.watchpoint.pmm.job.util.JobScheduleInfoConstants;
import com.tandbergtv.watchpoint.pmm.util.ContainerCacheActivator;

/**
 * @author spuranik
 *
 */
public class DefaultHandlerTest extends TestCase {

	private ContainerCacheActivator activator = new ContainerCacheActivator();
	
	/* (non-Javadoc)
	 * @see junit.framework.TestCase#setUp()
	 */
	@Override
	protected void setUp() throws Exception {
		HibernateContext.getContext().initializeContext();
		
		activator.start();
		super.setUp();
	}

	/* (non-Javadoc)
	 * @see junit.framework.TestCase#tearDown()
	 */
	@Override
	protected void tearDown() throws Exception {
		
		HibernateContext.getContext().closeContext();
		
		activator.stop();
		super.tearDown();
	}

	public void testHandler()
	{
		List<JobParameter> jobParams = new ArrayList<JobParameter>();
		JobParameter j1 = new JobParameter();
		j1.setName("Test Variable");
		j1.setValue("$Partner.Name");
		jobParams.add(j1);
		JobParameter j2 = new JobParameter();
		j2.setName("Boolean Variable");
		j2.setValue("true");
		jobParams.add(j2);		
		
		Map<String, Object> callbackInfo = new HashMap<String, Object>();	
		
		callbackInfo.put(JobScheduleInfoConstants.JOB_SELECTED_TEMPLATE_NAME, "TestTemplate1");
		callbackInfo.put(JobScheduleInfoConstants.JOB_PRIORITY, "Normal");		
		callbackInfo.put(JobScheduleInfoConstants.CONTEXTID, 1L);
		callbackInfo.put(JobScheduleInfoConstants.JOB_PARAMETERS, jobParams);
		
		DefaultHandler handler = new DefaultHandler();
		handler.executeJob(callbackInfo, new Date());
	}
	
	
}
