package org.musetest.core.suite;

import org.musetest.core.*;
import org.musetest.core.context.*;
import org.musetest.core.resource.*;

import java.util.*;

/**
 * A MuseTestSuite produced from a single test with varying sets of parameters.
 *
 * @author Christopher L Merrill (see LICENSE.txt for license details)
 */
@MuseTypeId("parameterized_test_suite")
public class ParameterListTestSuite implements MuseTestSuite
    {
    @Override
    public List<TestConfiguration> generateTestList(MuseProject project)
        {
        List<TestConfiguration> tests = new ArrayList<>();
        for (Map<String, Object> param_set : _parameters)
            {
            TestExecutionContext context = new DefaultTestExecutionContext(project);
            for (String name : param_set.keySet())
                context.setVariable(name, param_set.get(name));
            tests.add(new TestConfiguration(project.findResource(_testid, MuseTest.class), context));
            }
        return tests;
        }

    @Override
    public ResourceMetadata getMetadata()
        {
        return _metadata;
        }

    public String getTestId()
        {
        return _testid;
        }

    @SuppressWarnings("unused")    // used by Jackson for de/serialization
    public void setTestId(String testid)
        {
        _testid = testid;
        }

    public List<Map<String, Object>> getParameters()
        {
        return _parameters;
        }

    @SuppressWarnings("unused")    // used by Jackson for de/serialization
    public void setParameters(List<Map<String, Object>> parameter_map_list)
        {
        _parameters = parameter_map_list;
        }

    private ResourceMetadata _metadata = new ResourceMetadata();
    private List<Map<String, Object>> _parameters;
    private String _testid;
    }



@@ -127,16 +127,49 @@
 ource.*;
+%0Aimport org.musetest.core.test.*;
 %0A%0Aimport
@@ -896,40 +896,24 @@
     
-tests.add(new TestConfiguration(
+MuseTest test = 
 proj
@@ -953,16 +953,145 @@
 t.class)
+;%0A            if (test == null)%0A                test = new MissingTest(_testid);%0A            tests.add(new TestConfiguration(test
 , contex

handle bad test id in a ParameterListTestSuite