package org.musetest.core.suite;

import org.musetest.core.*;
import org.musetest.core.resource.*;
import org.musetest.core.resource.types.*;
import org.musetest.core.test.*;
import org.slf4j.*;

import java.util.*;

/**
 * A MuseTestSuite that creates tests based on a list of test IDs.
 *
 * @author Christopher L Merrill (see LICENSE.txt for license details)
 */
@MuseTypeId("suite_of_ids")
public class IdListTestSuite extends BaseMuseResource implements MuseTestSuite
    {
    @Override
    public List<TestConfiguration> generateTestList(MuseProject project)
        {
        List<TestConfiguration> tests = new ArrayList<>(_test_ids.size());
        for (String id : _test_ids)
            {
            MuseTest test = project.getResourceStorage().getResource(id, MuseTest.class);
            if (test == null)
                {
                LOG.error("Test with id {} was not found in the project", id);
                tests.add(new TestConfiguration(new MissingTest(id)));
                }
            else
                tests.add(new TestConfiguration(test));
            }
        return tests;
        }

    public List<String> getTestIds()
        {
        return Collections.unmodifiableList(_test_ids);
        }

    @SuppressWarnings("unused")  // used by Jackson
    public void setTestIds(List<String> ids)
        {
        _test_ids = ids;
        }

    @Override
    public ResourceType getType()
        {
        return new TestSuiteResourceType();
        }

    @SuppressWarnings("unused,WeakerAccess")  // discovered and instantiated by reflection (see class ResourceTypes)
    public static class IdListTestSuiteSubtype extends ResourceSubtype
        {
        public IdListTestSuiteSubtype()
            {
            super(TYPE_ID, "List of tests", IdListTestSuite.class, new MuseTestSuite.TestSuiteResourceType());
            }
        }

    private List<String> _test_ids = new ArrayList<>();

    public final static String TYPE_ID = IdListTestSuite.class.getAnnotation(MuseTypeId.class).value();

    private final static Logger LOG = LoggerFactory.getLogger(IdListTestSuite.class);
    }



@@ -1386,102 +1386,1058 @@
    @
-Override%0A    public ResourceType getType()%0A        %7B%0A        return new TestSuiteResourceType(
+SuppressWarnings(%22unused%22)  // public API%0A    public boolean addTestId(String id)%0A        %7B%0A        boolean added = _test_ids.add(id);%0A        for (ChangeListener listener : _listeners)%0A            listener.testIdAdded(id);%0A        return added;%0A        %7D%0A%0A    @SuppressWarnings(%22unused%22)  // public API%0A    public boolean removeTestId(String id)%0A        %7B%0A        boolean added = _test_ids.remove(id);%0A        for (ChangeListener listener : _listeners)%0A            listener.testIdRemoved(id);%0A        return added;%0A        %7D%0A%0A    @Override%0A    public ResourceType getType()%0A        %7B%0A        return new TestSuiteResourceType();%0A        %7D%0A%0A    public void addChangeListener(ChangeListener listener)%0A        %7B%0A        _listeners.add(listener);%0A        %7D%0A%0A    public boolean removeChangeListener(ChangeListener listener)%0A        %7B%0A        return _listeners.remove(listener);%0A        %7D%0A%0A    @SuppressWarnings(%22unused%22)  // public API%0A    public interface ChangeListener%0A        %7B%0A        void testIdAdded(String id);%0A        void testIdRemoved(String id
 );%0A 
@@ -2887,24 +2887,97 @@
 yList%3C%3E();%0A%0A
+    private transient Set%3CChangeListener%3E _listeners = new HashSet%3C%3E();%0A%0A
     public f

Add change methods & listeners to IdListTestSuite