package com.dianping.cat.consumer.advanced;

import java.util.ArrayList;
import java.util.List;

import org.unidal.lookup.configuration.AbstractResourceConfigurator;
import org.unidal.lookup.configuration.Component;

import com.dianping.cat.abtest.spi.internal.ABTestCodec;
import com.dianping.cat.advanced.metric.config.entity.MetricItemConfig;
import com.dianping.cat.analysis.MessageAnalyzer;
import com.dianping.cat.storage.BucketManager;
import com.dianping.cat.task.TaskManager;
import com.dianping.cat.task.TaskManagerTest.MockTaskManager;

public class Configurator extends AbstractResourceConfigurator {

	public static void main(String[] args) {
		generatePlexusComponentsXmlFile(new Configurator());
	}

	protected Class<?> getTestClass() {
		return MetricAnalyzerTest.class;
	}

	@Override
	public List<Component> defineComponents() {
		List<Component> all = new ArrayList<Component>();
		final String ID = MetricAnalyzer.ID;

		all.add(C(MetricConfigManager.class, ExtendedMetricConfigManager.class));
		all.add(C(ProductLineConfigManager.class));
		all.add(C(TaskManager.class, MockTaskManager.class));
		all.add(C(MessageAnalyzer.class, ID, MetricAnalyzer.class) //
		      .req(BucketManager.class, MetricConfigManager.class)//
		      .req(ProductLineConfigManager.class, ABTestCodec.class, TaskManager.class));

		return all;
	}

	public static class ExtendedMetricConfigManager extends MetricConfigManager {
		
		private MetricItemConfig m_config = new MetricItemConfig();
		
		@Override
		public MetricItemConfig queryMetricItemConfig(String id) {
			return m_config;
		}
	}
}

@@ -54,47 +54,242 @@
 ava.
-util.ArrayList;%0Aimport java.util.List;%0A
+text.SimpleDateFormat;%0Aimport java.util.ArrayList;%0Aimport java.util.Date;%0Aimport java.util.HashMap;%0Aimport java.util.HashSet;%0Aimport java.util.List;%0Aimport java.util.Map;%0Aimport java.util.Set;%0A%0Aimport org.unidal.dal.jdbc.DalException;
 %0Aimp
@@ -676,70 +676,8 @@
 ger;
-%0Aimport com.dianping.cat.task.TaskManagerTest.MockTaskManager;
 %0A%0Apu
@@ -1553,18 +1553,16 @@
 nager %7B%0A
-%09%09
 %0A%09%09priva
@@ -1616,18 +1616,16 @@
 nfig();%0A
-%09%09
 %0A%09%09@Over
@@ -1716,11 +1716,622 @@
 ;%0A%09%09%7D%0A%09%7D
+%0A%0A%09public static class MockTaskManager extends TaskManager %7B%0A%09%09private Map%3CInteger, Set%3CString%3E%3E m_results = new HashMap%3CInteger, Set%3CString%3E%3E();%0A%0A%09%09private SimpleDateFormat sdf = new SimpleDateFormat(%22yyyy-MM-dd HH:mm%22);%0A%0A%09%09@Override%0A%09%09protected void createTask(Date period, String ip, String domain, int reportType) throws DalException %7B%0A%09%09%09Set%3CString%3E lists = m_results.get(reportType);%0A%0A%09%09%09if (lists == null) %7B%0A%09%09%09%09lists = new HashSet%3CString%3E();%0A%09%09%09%09m_results.put(reportType, lists);%0A%09%09%09%7D%0A%0A%09%09%09lists.add(sdf.format(period));%0A%09%09%7D%0A%0A%09%09public Map%3CInteger, Set%3CString%3E%3E getResults() %7B%0A%09%09%09return m_results;%0A%09%09%7D%0A%0A%09%7D
 %0A%7D%0A

fix compile bug