
package org.eclipse.birt.report.tests.engine.regression;

import java.util.Collection;
import java.util.Iterator;

import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.IParameterSelectionChoice;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.engine.api.IReportEngineFactory;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.impl.GetParameterDefinitionTask;

import utility.EngineCase;

/**
 * <b>Regression test case description:</b>
 * <p>
 * Set a cascadding parameter to the joint datase will cause an error
 * <p>
 * </p>
 * <b>Test description:</b>
 * <p>
 * Create a design file with Join dataset and set a cascading parameter with
 * some default value.
 * <P>
 * The cascading parameter should be displayed correctly.
 * </p>
 */

public class Regression_134458 extends EngineCase
{

	protected void setUp( ) throws Exception
	{
		super.setUp( );
	}

	public void test_Regression_134458( ) throws Exception
	{
		EngineConfig config = new EngineConfig( );

		Platform.startup( config );

		IReportEngineFactory factory = (IReportEngineFactory) Platform
				.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );

		IReportEngine engine = factory.createReportEngine( config );

		// create task
		// TODO:
		IReportRunnable runnable = engine.openReportDesign( getClassFolder( )
				+ "/" + INPUT_FOLDER + "/" + "regression_134458.rptdesign" );

		GetParameterDefinitionTask paraTask = (GetParameterDefinitionTask) engine
				.createGetParameterDefinitionTask( runnable );

		Collection c = paraTask.getSelectionListForCascadingGroup(
				"NewCascadingParameterGroup", new Object[]{"Mini Caravy"} );
		assertEquals( c.size( ), 1 );
		Iterator it = c.iterator( );
		if ( it.hasNext( ) )
		{
			Object o = it.next( );
			assertTrue( o instanceof IParameterSelectionChoice );
			Object value = ( (IParameterSelectionChoice) o ).getValue( );
			assertEquals( "Citeaux", value );
		}
		assertNotNull( paraTask.getParameters( ).iterator( ) );
	}
}