/**
 * MetadataCreationTest.java
 * Created on Jun 21, 2008
 * (C) Copyright TANDBERG Television Ltd.
 */
package com.tandbergtv.watchpoint.pmm.action.schedule.ingest.unitTests;

import junit.framework.TestCase;

import com.tandbergtv.watchpoint.pmm.action.schedule.ingest.GenerateMetadataAction;
import com.tandbergtv.watchpoint.pmm.action.schedule.ingest.SetTitleStatsAction;
import com.tandbergtv.watchpoint.pmm.action.schedule.ingest.converter.DefaultProgramListConverter;
import com.tandbergtv.watchpoint.pmm.action.schedule.ingest.converter.TVNToPMMScheduleConverter;
import com.tandbergtv.watchpoint.pmm.util.schedule.ingest.ConversionResult;
import com.tandbergtv.watchpoint.pmm.util.schedule.ingest.FileType;

/**
 * @author spuranik
 * 
 */
public class MetadataCreationTest extends TestCase {

	public void _testConvert() {
		String inputFilepath = "D:\\Projects\\Watchpoint\\PMM Templates\\Schedule Ingest\\planners\\Aug-Planner.xls";
		String outputFilepath = "d:\\content\\temp\\Aug-Planner.xml";

		try {
			TVNToPMMScheduleConverter converter = new TVNToPMMScheduleConverter();

			if (converter.canConvert(inputFilepath)) {
				ConversionResult result = converter.convert(inputFilepath,
						outputFilepath);
				System.out.println("Conversion errorMsg: "
						+ result.getErrorMsg());
				System.out.println("Failed Title: " + result.getFailedTitle());
				System.out.println("Input File type: " + result.getFileType());
			} else {
				System.out.println(converter.getClass().getName()
						+ " cannot convert file: " + inputFilepath);
			}
		} catch (RuntimeException e) {
			System.out.println("Error while converting file: " + e.toString());
		}

		System.out.println("Done converting the file.");
	}

	public void testMetadatCreation() {
		String plannerFilepath = "d:\\content\\data\\DTV.com\\programList\\pl.xml";
		String metadataFolder = "d:\\content\\temp\\";

		GenerateMetadataAction action = new GenerateMetadataAction();
		action.setProviderId("DTV.com");
		action.generateMetadata(plannerFilepath, FileType.PROGRAM_LIST, metadataFolder);

		System.out.println("Done metadata file generation.");
	}

	public void _testTitleStatistics() {
		SetTitleStatsAction statsAction = new SetTitleStatsAction();
		String inputFilepath = "d:\\content\\data\\DTV.com\\planner\\specialChars_Sample-Planner-2.xml";

		try {
			String stats = statsAction.getPlannerTitleStatistics(inputFilepath);
			System.out.println(stats);
		} catch (RuntimeException e) {
			e.printStackTrace();
		}

	}

	public void _testCopy() {
		String inputFilepath = "D:\\content\\data\\DTV.com\\ingest\\planner\\pl.xml";
		String outputPath = "D:\\content\\temp\\pl.xml";

		DefaultProgramListConverter converter = new DefaultProgramListConverter();
		if (converter.canConvert(inputFilepath)) {
			ConversionResult result = converter.convert(inputFilepath,
					outputPath);

			System.out.println("Error msg: " + result.getErrorMsg());
			System.out.println("Failed titles: " + result.getFailedTitle());
			System.out.println("File type: " + result.getFileType());
		}
	}
}
