package org.momut.ooas.test;

import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.Collection;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.momut.ooas.CompilerConfiguration.Backend;
import org.momut.ooas.test.utils.OoasTest;

@RunWith(Parameterized.class)
public class SmokeOoasTests extends OoasTest {
	/**
	 * This function returns a list of a list of parameters.
	 * These parameters are used by JUnit to call the constructor
	 * of the test.
	 * @return a collection of parameter lists
	 * @throws IOException
	 */
	@Parameterized.Parameters(name="{0}: OOAS Compiler")
	public static Collection<Object[]> testFiles() throws IOException {
		final File outDir = OoasTest.createOutputDirectory(SmokeOoasTests.class);
		return Arrays.asList(new Object[][] {
			{ "portest"                  , s_standardDir, outDir},
			{ "inlinetest"               , s_standardDir, outDir},
			{ "simpletest"               , s_standardDir, outDir},
			{ "slicetest"                , s_standardDir, outDir},
			{ "AlarmSystem"              , s_standardDir, outDir},
//			{ "mms"                      , s_complexDir, outDir},
//			{ "tas"                      , s_complexDir, outDir}
		});
	}

	private final File m_outDir;

	/**
	 * Constructor
	 * @param testName The test name (name of the uml file without the ".uml" prefix)
	 * @param directory The directory containing the UML models
	 */
	public SmokeOoasTests(String testName, String directory, File outDir) {
		super(testName, directory + testName + ".ooas");
		m_outDir = outDir;
	}

	/**
	 * Run the MoMuT mutation toolchain.
	 * */
	@Test
	public void test() throws URISyntaxException, UnsupportedEncodingException, IOException {
		final URI modelUri = OoasTest.class.getClassLoader().getResource(m_model).toURI();
		runOoasCompiler(m_testName, new File(modelUri), m_outDir, Backend.Prolog);
	}
}
