// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/connection/ElasticSearchConnectionHandler.java
// public class ElasticSearchConnectionHandler extends ConnectionHandler {
// 
//     /**
//      * Constructor.
//      *
//      * @param configuration the configuration.
//      */
//     public ElasticSearchConnectionHandler(IConfiguration configuration) {
//         super(configuration);
//     }
// 
//     /**
//      * This method creates a elasticsearch connection.
//      *
//      * @param iCredentials           the credentials to connect with the database.
//      * @param connectorClusterConfig the cluster configuration.
//      * @throws ConnectionException if the connection is not established.
//      * @return a elasticsearch connection.
//      */
//     @Override
//     @TimerJ
//     protected Connection createNativeConnection(ICredentials iCredentials,
//             ConnectorClusterConfig connectorClusterConfig) throws ConnectionException {
//         Connection connection;
//         if (isNodeClient(connectorClusterConfig)) {
//             connection = new NodeConnection(iCredentials, connectorClusterConfig);
//         }
//         else {
//             try {connection = new TransportConnection(iCredentials, connectorClusterConfig);}
//             catch (ExecutionException exception){
//                 throw new ConnectionException("The connection could not be established", exception);
//             }
//         }
//         if (!connection.isConnected()) {
//              throw new ConnectionException("The connection could not be established");}
//         return connection;
//     }
// 
//     /**
//      * Return true if the config says that the connection is nodeClient. false in other case.
//      *
//      * @param config the configuration.
//      * @return true if is configure to be a node connection. False in other case.
//      */
//     @TimerJ
//     private boolean isNodeClient(ConnectorClusterConfig config) {
//         return Boolean.parseBoolean(config.getConnectorOptions().get(ConfigurationOptions.NODE_TYPE.getManifestOption()));
//     }
// 
// }


import com.stratio.connector.commons.connection.Connection;
import com.stratio.connector.elasticsearch.core.connection.ElasticSearchConnectionHandler;
import com.stratio.crossdata.common.data.*;
import com.stratio.crossdata.common.exceptions.ExecutionException;
import com.stratio.crossdata.common.exceptions.UnsupportedException;
import com.stratio.crossdata.common.metadata.ColumnMetadata;
import com.stratio.crossdata.common.metadata.IndexMetadata;
import com.stratio.crossdata.common.metadata.TableMetadata;
import com.stratio.crossdata.common.statements.structures.Selector;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.client.Client;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.Mock;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Map;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.mock;
/*
 * Licensed to STRATIO (C) under one or more contributor license agreements.
 * See the NOTICE file distributed with this work for additional information
 * regarding copyright ownership.  The STRATIO (C) licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package com.stratio.connector.elasticsearch.core.engine.utils;




/**
 * IndexRequestBuilderCreator Tester.
 *
 * @author <Authors name>
 * @version 1.0
 */

public class IndexRequestBuilderCreatorExceptionTest {

    private static final String CLUSTER_NAME = "CLUSTER NAME";
    private static final String INDEX_NAME = "INDEX_NAME";
    private static final String TYPE_NAME = "TYPE_NAME";
    private TableName tableName = new TableName(INDEX_NAME, TYPE_NAME);
    private static final String ROW_NAME = "row_name";
    private static final String OTHER_ROW_NAME = "OTHER_ROW_NAME";
    private static final String CELL_VALUE = "cell_value";

    @Rule
    public ExpectedException exception = ExpectedException.none();
    IndexRequestBuilderCreator indexRequestBuilderCreator;
    private LinkedHashMap<ColumnName, ColumnMetadata> columns = new LinkedHashMap<>();
    private Map<Selector, Selector> options = new LinkedHashMap<>();
    private Map<IndexName, IndexMetadata> indexes = new HashMap<IndexName, IndexMetadata>();
    private ClusterName clusterRef = new ClusterName(CLUSTER_NAME);
    private LinkedList<ColumnName> partitionKey = new LinkedList<ColumnName>();
    private LinkedList<ColumnName> clusterKey = new LinkedList<ColumnName>();

    @Mock
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/connection/ElasticSearchConnectionHandler.java
// public class ElasticSearchConnectionHandler extends ConnectionHandler {
// 
//     /**
//      * Constructor.
//      *
//      * @param configuration the configuration.
//      */
//     public ElasticSearchConnectionHandler(IConfiguration configuration) {
//         super(configuration);
//     }
// 
//     /**
//      * This method creates a elasticsearch connection.
//      *
//      * @param iCredentials           the credentials to connect with the database.
//      * @param connectorClusterConfig the cluster configuration.
//      * @throws ConnectionException if the connection is not established.
//      * @return a elasticsearch connection.
//      */
//     @Override
//     @TimerJ
//     protected Connection createNativeConnection(ICredentials iCredentials,
//             ConnectorClusterConfig connectorClusterConfig) throws ConnectionException {
//         Connection connection;
//         if (isNodeClient(connectorClusterConfig)) {
//             connection = new NodeConnection(iCredentials, connectorClusterConfig);
//         }
//         else {
//             try {connection = new TransportConnection(iCredentials, connectorClusterConfig);}
//             catch (ExecutionException exception){
//                 throw new ConnectionException("The connection could not be established", exception);
//             }
//         }
//         if (!connection.isConnected()) {
//              throw new ConnectionException("The connection could not be established");}
//         return connection;
//     }
// 
//     /**
//      * Return true if the config says that the connection is nodeClient. false in other case.
//      *
//      * @param config the configuration.
//      * @return true if is configure to be a node connection. False in other case.
//      */
//     @TimerJ
//     private boolean isNodeClient(ConnectorClusterConfig config) {
//         return Boolean.parseBoolean(config.getConnectorOptions().get(ConfigurationOptions.NODE_TYPE.getManifestOption()));
//     }
// 
// }


// Path: connector-elasticsearch/src/test/java/com/stratio/connector/elasticsearch/core/engine/utils/IndexRequestBuilderCreatorExceptionTest.java
import com.stratio.connector.commons.connection.Connection;
import com.stratio.connector.elasticsearch.core.connection.ElasticSearchConnectionHandler;
import com.stratio.crossdata.common.data.*;
import com.stratio.crossdata.common.exceptions.ExecutionException;
import com.stratio.crossdata.common.exceptions.UnsupportedException;
import com.stratio.crossdata.common.metadata.ColumnMetadata;
import com.stratio.crossdata.common.metadata.IndexMetadata;
import com.stratio.crossdata.common.metadata.TableMetadata;
import com.stratio.crossdata.common.statements.structures.Selector;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.client.Client;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.Mock;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Map;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.mock;

/*
 * Licensed to STRATIO (C) under one or more contributor license agreements.
 * See the NOTICE file distributed with this work for additional information
 * regarding copyright ownership.  The STRATIO (C) licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package com.stratio.connector.elasticsearch.core.engine.utils;




/**
 * IndexRequestBuilderCreator Tester.
 *
 * @author <Authors name>
 * @version 1.0
 */

public class IndexRequestBuilderCreatorExceptionTest {

    private static final String CLUSTER_NAME = "CLUSTER NAME";
    private static final String INDEX_NAME = "INDEX_NAME";
    private static final String TYPE_NAME = "TYPE_NAME";
    private TableName tableName = new TableName(INDEX_NAME, TYPE_NAME);
    private static final String ROW_NAME = "row_name";
    private static final String OTHER_ROW_NAME = "OTHER_ROW_NAME";
    private static final String CELL_VALUE = "cell_value";

    @Rule
    public ExpectedException exception = ExpectedException.none();
    IndexRequestBuilderCreator indexRequestBuilderCreator;
    private LinkedHashMap<ColumnName, ColumnMetadata> columns = new LinkedHashMap<>();
    private Map<Selector, Selector> options = new LinkedHashMap<>();
    private Map<IndexName, IndexMetadata> indexes = new HashMap<IndexName, IndexMetadata>();
    private ClusterName clusterRef = new ClusterName(CLUSTER_NAME);
    private LinkedList<ColumnName> partitionKey = new LinkedList<ColumnName>();
    private LinkedList<ColumnName> clusterKey = new LinkedList<ColumnName>();

    @Mock
    private ElasticSearchConnectionHandler connectionHandler;