// Path: src/test/java/org/jboss/elasticsearch/tools/content/testtools/ESRealClientTestBase.java
// public abstract class ESRealClientTestBase {
// 
//   private Client client;
// 
//   private Node node;
// 
//   private File tempFolder;
// 
//   /**
//    * Prepare ES inmemory client for unit test. Do not forgot to call {@link #finalizeESClientForUnitTest()} at the end
//    * of test!
//    * 
//    * @return
//    * @throws Exception
//    */
//   public final Client prepareESClientForUnitTest() throws Exception {
//     try {
//       // For unit tests it is recommended to use local node.
//       // This is to ensure that your node will never join existing cluster on the network.
// 
//       // path.data location
//       tempFolder = new File("tmp");
//       String tempFolderName = tempFolder.getCanonicalPath();
// 
//       if (tempFolder.exists()) {
//         FileUtils.deleteDirectory(tempFolder);
//       }
//       if (!tempFolder.mkdir()) {
//         throw new IOException("Could not create a temporary folder [" + tempFolderName + "]");
//       }
// 
//       // Make sure that the index and metadata are not stored on the disk
//       // path.data folder is created but we make sure it is removed after test finishes
//       Settings settings = org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder()
//           .put("index.store.type", "memory").put("gateway.type", "none").put("http.enabled", "false")
//           .put("path.data", tempFolderName).build();
// 
//       node = NodeBuilder.nodeBuilder().settings(settings).local(true).node();
// 
//       client = node.client();
// 
//       return client;
//     } catch (Exception e) {
//       finalizeESClientForUnitTest();
//       throw e;
//     }
//   }
// 
//   public final void finalizeESClientForUnitTest() {
//     if (client != null)
//       client.close();
//     client = null;
//     if (node != null)
//       node.close();
//     node = null;
// 
//     if (tempFolder != null && tempFolder.exists()) {
//       try {
//         FileUtils.deleteDirectory(tempFolder);
//       } catch (IOException e) {
//         // nothing to do
//       }
//     }
//     tempFolder = null;
//   }
// 
// }
// 
// 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 java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import junit.framework.Assert;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.settings.SettingsException;
import org.elasticsearch.common.xcontent.support.XContentMapValues;
import org.jboss.elasticsearch.tools.content.testtools.ESRealClientTestBase;
import org.jboss.elasticsearch.tools.content.testtools.TestUtils;
import org.junit.Test;
import org.mockito.Mockito;
/*
 * JBoss, Home of Professional Open Source
 * Copyright 2012 Red Hat Inc. and/or its affiliates and other contributors
 * as indicated by the @authors tag. All rights reserved.
 */
package org.jboss.elasticsearch.tools.content;




/**
 * Unit test for {@link ESLookupValuePreprocessor}.
 * 
 * @author Vlastimil Elias (velias at redhat dot com)
 */
public class ESLookupValuePreprocessorTest extends ESRealClientTestBase {

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Test
	public void init_settingerrors() {
		ESLookupValuePreprocessor tested = new ESLookupValuePreprocessor();
		Client client = Mockito.mock(Client.class);

		// case - ES client mandatory
		try {
// Path: src/test/java/org/jboss/elasticsearch/tools/content/testtools/ESRealClientTestBase.java
// public abstract class ESRealClientTestBase {
// 
//   private Client client;
// 
//   private Node node;
// 
//   private File tempFolder;
// 
//   /**
//    * Prepare ES inmemory client for unit test. Do not forgot to call {@link #finalizeESClientForUnitTest()} at the end
//    * of test!
//    * 
//    * @return
//    * @throws Exception
//    */
//   public final Client prepareESClientForUnitTest() throws Exception {
//     try {
//       // For unit tests it is recommended to use local node.
//       // This is to ensure that your node will never join existing cluster on the network.
// 
//       // path.data location
//       tempFolder = new File("tmp");
//       String tempFolderName = tempFolder.getCanonicalPath();
// 
//       if (tempFolder.exists()) {
//         FileUtils.deleteDirectory(tempFolder);
//       }
//       if (!tempFolder.mkdir()) {
//         throw new IOException("Could not create a temporary folder [" + tempFolderName + "]");
//       }
// 
//       // Make sure that the index and metadata are not stored on the disk
//       // path.data folder is created but we make sure it is removed after test finishes
//       Settings settings = org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder()
//           .put("index.store.type", "memory").put("gateway.type", "none").put("http.enabled", "false")
//           .put("path.data", tempFolderName).build();
// 
//       node = NodeBuilder.nodeBuilder().settings(settings).local(true).node();
// 
//       client = node.client();
// 
//       return client;
//     } catch (Exception e) {
//       finalizeESClientForUnitTest();
//       throw e;
//     }
//   }
// 
//   public final void finalizeESClientForUnitTest() {
//     if (client != null)
//       client.close();
//     client = null;
//     if (node != null)
//       node.close();
//     node = null;
// 
//     if (tempFolder != null && tempFolder.exists()) {
//       try {
//         FileUtils.deleteDirectory(tempFolder);
//       } catch (IOException e) {
//         // nothing to do
//       }
//     }
//     tempFolder = null;
//   }
// 
// }
// 
// 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/ESLookupValuePreprocessorTest.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import junit.framework.Assert;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.settings.SettingsException;
import org.elasticsearch.common.xcontent.support.XContentMapValues;
import org.jboss.elasticsearch.tools.content.testtools.ESRealClientTestBase;
import org.jboss.elasticsearch.tools.content.testtools.TestUtils;
import org.junit.Test;
import org.mockito.Mockito;

/*
 * JBoss, Home of Professional Open Source
 * Copyright 2012 Red Hat Inc. and/or its affiliates and other contributors
 * as indicated by the @authors tag. All rights reserved.
 */
package org.jboss.elasticsearch.tools.content;




/**
 * Unit test for {@link ESLookupValuePreprocessor}.
 * 
 * @author Vlastimil Elias (velias at redhat dot com)
 */
public class ESLookupValuePreprocessorTest extends ESRealClientTestBase {

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Test
	public void init_settingerrors() {
		ESLookupValuePreprocessor tested = new ESLookupValuePreprocessor();
		Client client = Mockito.mock(Client.class);

		// case - ES client mandatory
		try {
			Map<String, Object> settings = TestUtils.loadJSONFromClasspathFile("/ESLookupValue_preprocessData-nobases.json");