package org.musetest.core.test.plugins;

import org.musetest.core.*;
import org.musetest.core.resource.*;
import org.musetest.core.test.plugin.*;
import org.musetest.core.values.*;

/**
 * @author Christopher L Merrill (see LICENSE.txt for license details)
 */
public class CompoundPlugin extends BaseTestPlugin
	{
	public CompoundPlugin(CompoundPluginConfiguration config)
		{
		super(config);
		}

	@Override
	public boolean addToContext(MuseExecutionContext context, boolean automatic) throws MuseExecutionError
		{
		if (automatic && !applyAutomatically(context))
			return false;

		if (!applyToThisTest(context))
			return false;

		MuseValueSource source = BaseValueSource.getValueSource(_configuration.parameters(), CompoundPluginConfiguration.LISTS_PARAM, true, context.getProject());
		String id_list_param = BaseValueSource.getValue(source, context, false, String.class);
		String[] id_list = id_list_param.split(",");

		for (String id : id_list)
			{
			final ResourceToken resource = context.getProject().getResourceStorage().findResource(id);
			if (resource.getResource() instanceof TestPluginConfiguration)
				((TestPluginConfiguration)resource.getResource()).createPlugin().addToContext(context, false);
			}
		return true;
		}

	@Override
	public void initialize(MuseExecutionContext context)
		{
		}
	}

@@ -175,16 +175,37 @@
 ues.*;%0A%0A
+import java.util.*;%0A%0A
 /**%0A * @
@@ -808,16 +808,394 @@
 ect());%0A
+%09%09Object id_list_obj = BaseValueSource.getValue(source, context, false);%0A%09%09String%5B%5D id_list;%0A%09%09if (id_list_obj instanceof List)%0A%09%09%09%7B%0A%09%09%09final List%3CString%3E list = (List) id_list_obj;%0A%09%09%09id_list = new String%5Blist.size()%5D;%0A%09%09%09for (int i = 0; i %3C list.size(); i++)%0A%09%09%09%09id_list%5Bi%5D = ((List) id_list_obj).get(i).toString();%0A%09%09%09%7D%0A%09%09else if (id_list_obj.toString().contains(%22,%22))%0A%09%09%09%7B%0A%09
 %09%09String
@@ -1273,33 +1273,25 @@
 g.class);%0A%09%09
-String%5B%5D 
+%09
 id_list = id
@@ -1313,16 +1313,106 @@
 it(%22,%22);
+%0A%09%09%09%7D%0A%09%09else%0A%09%09%09%7B%0A%09%09%09id_list = new String%5B1%5D;%0A%09%09%09id_list%5B0%5D = id_list_obj.toString();%0A%09%09%09%7D
 %0A%0A%09%09for 

Enhance CompoundPlugin to accept the list of plugin ids as a single string, a list of strings or a comma-separated list in a string.