// Path: src/main/java/org/jboss/elasticsearch/tools/content/IsDateInRangePreprocessor.java
// protected static final String CFG_CHECKED_DATE = "checked_date";
// 
// Path: src/main/java/org/jboss/elasticsearch/tools/content/IsDateInRangePreprocessor.java
// protected static final String CFG_DEFAULT_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSXX";
// 
// Path: src/main/java/org/jboss/elasticsearch/tools/content/IsDateInRangePreprocessor.java
// protected static final String CFG_LEFT_DATE = "left_date";
// 
// Path: src/main/java/org/jboss/elasticsearch/tools/content/IsDateInRangePreprocessor.java
// protected static final String CFG_RESULT_FIELD = "result_field";
// 
// Path: src/main/java/org/jboss/elasticsearch/tools/content/IsDateInRangePreprocessor.java
// protected static final String CFG_RIGHT_DATE = "right_date";
// 
// Path: src/test/java/org/jboss/elasticsearch/tools/content/testtools/TestUtils.java
// public abstract class TestUtils {
// 
// 	/**
// 	 * Assert passed string is same as contnt of given file loaded from classpath.
// 	 * 
// 	 * @param expectedFilePath path to file inside classpath
// 	 * @param actual content to assert
// 	 * @throws IOException
// 	 */
// 	public static void assertStringFromClasspathFile(String expectedFilePath, String actual) throws IOException {
// 		Assert.assertEquals(readStringFromClasspathFile(expectedFilePath), actual);
// 	}
// 
// 	/**
// 	 * Read file from classpath into String. UTF-8 encoding expected.
// 	 * 
// 	 * @param filePath in classpath to read data from.
// 	 * @return file content.
// 	 * @throws IOException
// 	 */
// 	public static String readStringFromClasspathFile(String filePath) throws IOException {
// 		StringWriter stringWriter = new StringWriter();
// 		IOUtils.copy(TestUtils.class.getResourceAsStream(filePath), stringWriter, "UTF-8");
// 		return stringWriter.toString();
// 	}
// 
// 	/**
// 	 * Read JSON file from classpath into Map of Map structure.
// 	 * 
// 	 * @param filePath path in classpath pointing to JSON file to read
// 	 * @return parsed JSON file
// 	 * @throws SettingsException
// 	 */
// 	public static Map<String, Object> loadJSONFromClasspathFile(String filePath) throws SettingsException {
// 		XContentParser parser = null;
// 		try {
// 			parser = XContentFactory.xContent(XContentType.JSON).createParser(TestUtils.class.getResourceAsStream(filePath));
// 			return parser.mapAndClose();
// 		} catch (IOException e) {
// 			throw new SettingsException(e.getMessage(), e);
// 		} finally {
// 			if (parser != null)
// 				parser.close();
// 		}
// 	}
// 
// }


import static org.jboss.elasticsearch.tools.content.IsDateInRangePreprocessor.CFG_CHECKED_DATE;
import static org.jboss.elasticsearch.tools.content.IsDateInRangePreprocessor.CFG_DEFAULT_DATE_FORMAT;
import static org.jboss.elasticsearch.tools.content.IsDateInRangePreprocessor.CFG_LEFT_DATE;
import static org.jboss.elasticsearch.tools.content.IsDateInRangePreprocessor.CFG_RESULT_FIELD;
import static org.jboss.elasticsearch.tools.content.IsDateInRangePreprocessor.CFG_RIGHT_DATE;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import junit.framework.Assert;
import org.elasticsearch.common.settings.SettingsException;
import org.jboss.elasticsearch.tools.content.testtools.TestUtils;
import org.junit.Test;
		} catch (SettingsException e) {
			Assert.assertEquals(
					"Missing or empty 'settings/"+CFG_RESULT_FIELD+"' configuration value for 'Test mapper' preprocessor",
					e.getMessage());
		}
		
		// case - at least one of left_date or right_date must be provided
		settings.put(CFG_RESULT_FIELD, "target");
		try {
			tested.init("Test mapper", null, settings);
			Assert.fail("SettingsException must be thrown");
		} catch (SettingsException e) {
			Assert.assertEquals(
					"At least one of dates defining range, settings/"+CFG_LEFT_DATE+" or settings/"+CFG_RIGHT_DATE+" need to be provided.",
					e.getMessage());
		}

		// case - no more mandatory setting fields
		settings.put(CFG_RIGHT_DATE, "right_date");
		tested.init("Test mapper", null, settings); 
	}

	@Test
	public void init() {
		
		// case - mandatory fields only filled in
		IsDateInRangePreprocessor tested = new IsDateInRangePreprocessor();
		Map<String, Object> settings = new HashMap<String, Object>();
		settings.put( CFG_CHECKED_DATE, "tested_date" );
		settings.put( CFG_RESULT_FIELD, "target" );
// Path: src/main/java/org/jboss/elasticsearch/tools/content/IsDateInRangePreprocessor.java
// protected static final String CFG_CHECKED_DATE = "checked_date";
// 
// Path: src/main/java/org/jboss/elasticsearch/tools/content/IsDateInRangePreprocessor.java
// protected static final String CFG_DEFAULT_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSXX";
// 
// Path: src/main/java/org/jboss/elasticsearch/tools/content/IsDateInRangePreprocessor.java
// protected static final String CFG_LEFT_DATE = "left_date";
// 
// Path: src/main/java/org/jboss/elasticsearch/tools/content/IsDateInRangePreprocessor.java
// protected static final String CFG_RESULT_FIELD = "result_field";
// 
// Path: src/main/java/org/jboss/elasticsearch/tools/content/IsDateInRangePreprocessor.java
// protected static final String CFG_RIGHT_DATE = "right_date";
// 
// Path: src/test/java/org/jboss/elasticsearch/tools/content/testtools/TestUtils.java
// public abstract class TestUtils {
// 
// 	/**
// 	 * Assert passed string is same as contnt of given file loaded from classpath.
// 	 * 
// 	 * @param expectedFilePath path to file inside classpath
// 	 * @param actual content to assert
// 	 * @throws IOException
// 	 */
// 	public static void assertStringFromClasspathFile(String expectedFilePath, String actual) throws IOException {
// 		Assert.assertEquals(readStringFromClasspathFile(expectedFilePath), actual);
// 	}
// 
// 	/**
// 	 * Read file from classpath into String. UTF-8 encoding expected.
// 	 * 
// 	 * @param filePath in classpath to read data from.
// 	 * @return file content.
// 	 * @throws IOException
// 	 */
// 	public static String readStringFromClasspathFile(String filePath) throws IOException {
// 		StringWriter stringWriter = new StringWriter();
// 		IOUtils.copy(TestUtils.class.getResourceAsStream(filePath), stringWriter, "UTF-8");
// 		return stringWriter.toString();
// 	}
// 
// 	/**
// 	 * Read JSON file from classpath into Map of Map structure.
// 	 * 
// 	 * @param filePath path in classpath pointing to JSON file to read
// 	 * @return parsed JSON file
// 	 * @throws SettingsException
// 	 */
// 	public static Map<String, Object> loadJSONFromClasspathFile(String filePath) throws SettingsException {
// 		XContentParser parser = null;
// 		try {
// 			parser = XContentFactory.xContent(XContentType.JSON).createParser(TestUtils.class.getResourceAsStream(filePath));
// 			return parser.mapAndClose();
// 		} catch (IOException e) {
// 			throw new SettingsException(e.getMessage(), e);
// 		} finally {
// 			if (parser != null)
// 				parser.close();
// 		}
// 	}
// 
// }


// Path: src/test/java/org/jboss/elasticsearch/tools/content/IsDateInRangePreprocessorTest.java
import static org.jboss.elasticsearch.tools.content.IsDateInRangePreprocessor.CFG_CHECKED_DATE;
import static org.jboss.elasticsearch.tools.content.IsDateInRangePreprocessor.CFG_DEFAULT_DATE_FORMAT;
import static org.jboss.elasticsearch.tools.content.IsDateInRangePreprocessor.CFG_LEFT_DATE;
import static org.jboss.elasticsearch.tools.content.IsDateInRangePreprocessor.CFG_RESULT_FIELD;
import static org.jboss.elasticsearch.tools.content.IsDateInRangePreprocessor.CFG_RIGHT_DATE;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import junit.framework.Assert;
import org.elasticsearch.common.settings.SettingsException;
import org.jboss.elasticsearch.tools.content.testtools.TestUtils;
import org.junit.Test;

		} catch (SettingsException e) {
			Assert.assertEquals(
					"Missing or empty 'settings/"+CFG_RESULT_FIELD+"' configuration value for 'Test mapper' preprocessor",
					e.getMessage());
		}
		
		// case - at least one of left_date or right_date must be provided
		settings.put(CFG_RESULT_FIELD, "target");
		try {
			tested.init("Test mapper", null, settings);
			Assert.fail("SettingsException must be thrown");
		} catch (SettingsException e) {
			Assert.assertEquals(
					"At least one of dates defining range, settings/"+CFG_LEFT_DATE+" or settings/"+CFG_RIGHT_DATE+" need to be provided.",
					e.getMessage());
		}

		// case - no more mandatory setting fields
		settings.put(CFG_RIGHT_DATE, "right_date");
		tested.init("Test mapper", null, settings); 
	}

	@Test
	public void init() {
		
		// case - mandatory fields only filled in
		IsDateInRangePreprocessor tested = new IsDateInRangePreprocessor();
		Map<String, Object> settings = new HashMap<String, Object>();
		settings.put( CFG_CHECKED_DATE, "tested_date" );
		settings.put( CFG_RESULT_FIELD, "target" );
		settings.put( CFG_LEFT_DATE, "left_date" );