// Path: src/main/java/com/stratio/connector/deep/configuration/DeepConnectorConstants.java
// public final class DeepConnectorConstants {
// 	private DeepConnectorConstants(){
// 
// 	}
// 
// 	public static final String HDFS = "hdfs";
// 	public static final String SPARK_MASTER = "spark.master";
// 	public static final String SPARK_HOME = "spark.home";
// 	public static final String SPARK_JARS = "spark.jars";
// 	public static final String CLUSTER_PREFIX_CONSTANT = "cluster";
// 	public static final String IMPL_CLASS_SUFIX_CONSTANT = ".implClass";
// 	public static final String EXTRACTOR_IMPL_CLASS = "extractorImplClass";
// 	public static final String DEEP_CONNECTOR_JOB_CONSTANT = "DeepConnectorJob";
// 
// 	public static final int DEFAULT_RESULT_SIZE = 10000;
// 	public static final String PROPERTY_DEFAULT_LIMIT = "DefaultLimit";
//     public static final String SPARK_EXECUTOR_MEMORY = "spark.executor.memory";
//     public static final String SPARK_DRIVER_MEMORY = "spark.driver.memory";
//     public static final String  SPARK_TASK_CPUS = "spark.task.cpus";
//     public static final String  SPARK_DEFAULT_PARALELISM = "spark.default.parallelism";
//     public static final String  SPARK_CORES_MAX = "spark.cores.max";
//     public static final String  SPARK_DRIVER_RESULTSIZE = "spark.driver.maxResultSize";
// 
// 
// 
// 
// }


import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.powermock.api.mockito.PowerMockito.whenNew;
import java.util.HashMap;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.internal.util.reflection.Whitebox;
import org.powermock.modules.junit4.PowerMockRunner;
import com.stratio.connector.deep.configuration.DeepConnectorConstants;
import com.stratio.crossdata.common.connector.ConnectorClusterConfig;
import com.stratio.crossdata.common.connector.IConfiguration;
import com.stratio.crossdata.common.data.ClusterName;
import com.stratio.crossdata.common.data.DataStoreName;
import com.stratio.crossdata.common.security.ICredentials;
import com.stratio.deep.commons.extractor.utils.ExtractorConstants;
package com.stratio.connector.deep.connection;





/**
 * Created by dgomez on 18/09/14.
 */

@RunWith(PowerMockRunner.class)
public class ConnectionHandlerTest {

    private static final String CLUSTER_NAME = "cluster_name";
    private DeepConnectionHandler connectionHandler = null;
    @Mock
    private IConfiguration iConfiguration;

    @Before
    public void before() throws Exception {

        iConfiguration = mock(IConfiguration.class);
        connectionHandler = new DeepConnectionHandler(iConfiguration);
    }

    /**
     * Method: createConnection(String clusterName, Connection connection)
     */
    @Test
    public void testCreateConnection() throws Exception {

        ICredentials credentials = mock(ICredentials.class);
        Map<String, String> options = new HashMap<>();
        options.put(ExtractorConstants.HOST, "127.0.0.1");
        options.put(ExtractorConstants.HOSTS, "127.0.0.1 , 127.0.0.2");
        options.put(ExtractorConstants.PORT, "PORT");
        options.put(DeepConnectorConstants.EXTRACTOR_IMPL_CLASS, "PORT");

        ConnectorClusterConfig config = new ConnectorClusterConfig(new ClusterName(CLUSTER_NAME), options, options);
        config.setDataStoreName(new DataStoreName("cassandra"));

        DeepConnection connection = mock(DeepConnection.class);
        whenNew(DeepConnection.class).withArguments(credentials, config).thenReturn(connection);

        connectionHandler.createConnection(credentials, config);

        Map<String, DeepConnection> mapConnection = (Map<String, DeepConnection>) Whitebox.getInternalState(
                connectionHandler, "connections");

        DeepConnection recoveredConnection = mapConnection.get(CLUSTER_NAME);

// Path: src/main/java/com/stratio/connector/deep/configuration/DeepConnectorConstants.java
// public final class DeepConnectorConstants {
// 	private DeepConnectorConstants(){
// 
// 	}
// 
// 	public static final String HDFS = "hdfs";
// 	public static final String SPARK_MASTER = "spark.master";
// 	public static final String SPARK_HOME = "spark.home";
// 	public static final String SPARK_JARS = "spark.jars";
// 	public static final String CLUSTER_PREFIX_CONSTANT = "cluster";
// 	public static final String IMPL_CLASS_SUFIX_CONSTANT = ".implClass";
// 	public static final String EXTRACTOR_IMPL_CLASS = "extractorImplClass";
// 	public static final String DEEP_CONNECTOR_JOB_CONSTANT = "DeepConnectorJob";
// 
// 	public static final int DEFAULT_RESULT_SIZE = 10000;
// 	public static final String PROPERTY_DEFAULT_LIMIT = "DefaultLimit";
//     public static final String SPARK_EXECUTOR_MEMORY = "spark.executor.memory";
//     public static final String SPARK_DRIVER_MEMORY = "spark.driver.memory";
//     public static final String  SPARK_TASK_CPUS = "spark.task.cpus";
//     public static final String  SPARK_DEFAULT_PARALELISM = "spark.default.parallelism";
//     public static final String  SPARK_CORES_MAX = "spark.cores.max";
//     public static final String  SPARK_DRIVER_RESULTSIZE = "spark.driver.maxResultSize";
// 
// 
// 
// 
// }


// Path: src/test/java/com/stratio/connector/deep/connection/ConnectionHandlerTest.java
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.powermock.api.mockito.PowerMockito.whenNew;
import java.util.HashMap;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.internal.util.reflection.Whitebox;
import org.powermock.modules.junit4.PowerMockRunner;
import com.stratio.connector.deep.configuration.DeepConnectorConstants;
import com.stratio.crossdata.common.connector.ConnectorClusterConfig;
import com.stratio.crossdata.common.connector.IConfiguration;
import com.stratio.crossdata.common.data.ClusterName;
import com.stratio.crossdata.common.data.DataStoreName;
import com.stratio.crossdata.common.security.ICredentials;
import com.stratio.deep.commons.extractor.utils.ExtractorConstants;

package com.stratio.connector.deep.connection;





/**
 * Created by dgomez on 18/09/14.
 */

@RunWith(PowerMockRunner.class)
public class ConnectionHandlerTest {

    private static final String CLUSTER_NAME = "cluster_name";
    private DeepConnectionHandler connectionHandler = null;
    @Mock
    private IConfiguration iConfiguration;

    @Before
    public void before() throws Exception {

        iConfiguration = mock(IConfiguration.class);
        connectionHandler = new DeepConnectionHandler(iConfiguration);
    }

    /**
     * Method: createConnection(String clusterName, Connection connection)
     */
    @Test
    public void testCreateConnection() throws Exception {

        ICredentials credentials = mock(ICredentials.class);
        Map<String, String> options = new HashMap<>();
        options.put(ExtractorConstants.HOST, "127.0.0.1");
        options.put(ExtractorConstants.HOSTS, "127.0.0.1 , 127.0.0.2");
        options.put(ExtractorConstants.PORT, "PORT");
        options.put(DeepConnectorConstants.EXTRACTOR_IMPL_CLASS, "PORT");

        ConnectorClusterConfig config = new ConnectorClusterConfig(new ClusterName(CLUSTER_NAME), options, options);
        config.setDataStoreName(new DataStoreName("cassandra"));

        DeepConnection connection = mock(DeepConnection.class);
        whenNew(DeepConnection.class).withArguments(credentials, config).thenReturn(connection);

        connectionHandler.createConnection(credentials, config);

        Map<String, DeepConnection> mapConnection = (Map<String, DeepConnection>) Whitebox.getInternalState(
                connectionHandler, "connections");

        DeepConnection recoveredConnection = mapConnection.get(CLUSTER_NAME);

        assertNotNull("The connection is not null", recoveredConnection);