// Path: src/main/java/org/apache/flink/mapping/neo4j/Neo4JSerializationMappingStrategy.java
// public class Neo4JSerializationMappingStrategy<T, M extends SerializationMapper<T>> implements Serializable {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	/**
// 	 * The templated cypher query that will be executed on Neo4J
// 	 */
// 	private String templateStatement;
// 
// 	/**
// 	 * 
// 	 */
// 	private M mapper;
// 
// 	/**
// 	 * 
// 	 * @param templateStatement the cypher statement template
// 	 * @param mapper an actual SerializationMapper implementation
// 	 */
// 	public Neo4JSerializationMappingStrategy(final String templateStatement, M mapper) {
// 		this.templateStatement = templateStatement;
// 		this.mapper = mapper;
// 	}
// 
// 	/**
// 	 * 
// 	 * @return the cypher statement template
// 	 */
// 	public Statement getStatement() {
// 		return new Statement(templateStatement);
// 	}
// 
// 	/**
// 	 * Maps a single result record into a T object
// 	 * 
// 	 * @param record a record that will be returned by the cypher query
// 	 * @return an object of type T
// 	 */
// 	public T map(Record record) {
// 		return this.mapper.serialize(record.asMap());
// 	}
// }
// 
// Path: src/test/java/org/apache/flink/mapping/neo4j/SerializationMapperTest.java
// class TupleSerializationMapper implements SerializationMapper<Tuple2<String, Integer>> {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	@Override
// 	public Tuple2<String, Integer> serialize(Map<String, Object> record) {
// 		Tuple2<String, Integer> tuple = new Tuple2<String, Integer>();
// 
// 		tuple.f0 = record.get("i.description").toString();
// 		tuple.f1 = Integer.valueOf(record.get("i.id").toString());
// 
// 		return tuple;
// 	}
// }


import java.util.HashMap;
import java.util.Map;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.mapping.neo4j.Neo4JSerializationMappingStrategy;
import org.apache.flink.mapping.neo4j.SerializationMapperTest.TupleSerializationMapper;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.neo4j.driver.v1.Record;
package org.apache.flink.mapping.neo4j;



public class Neo4JSerializationMappingStrategyTest {

	final SerializationMapperTest.TupleSerializationMapper serializationMapper = new SerializationMapperTest().new TupleSerializationMapper();

	class Neo4JSourceMappingStrategyTuple extends
			Neo4JSerializationMappingStrategy<Tuple2<String, Integer>, SerializationMapperTest.TupleSerializationMapper> {

		private static final long serialVersionUID = 1L;

		public Neo4JSourceMappingStrategyTuple(String templateStatement, TupleSerializationMapper mapper) {
			super(templateStatement, mapper);
		}
	}

	@Test
	public void testMappingStrategy() {
		String templateStatement = "MATCH (i:Item) return i.id, i.description";

		Neo4JSerializationMappingStrategy<Tuple2<String, Integer>, SerializationMapperTest.TupleSerializationMapper> sourceMappingStrategy = new Neo4JSourceMappingStrategyTuple(
				templateStatement, serializationMapper);

		Assert.assertNotNull(sourceMappingStrategy.getStatement());

		Map<String, Object> result = new HashMap<String, Object>();
		result.put("i.id", new Integer(1));
		result.put("i.description", "an item");

		Record record = Mockito.mock(Record.class);
		Mockito.when(record.asMap()).thenAnswer(new Answer<Map<String, Object>>() {

			@Override
			public Map<String, Object> answer(InvocationOnMock invocation) throws Throwable {
				Map<String, Object> map = new HashMap<String, Object>();
				map.put("i.id", new Integer(1));
// Path: src/main/java/org/apache/flink/mapping/neo4j/Neo4JSerializationMappingStrategy.java
// public class Neo4JSerializationMappingStrategy<T, M extends SerializationMapper<T>> implements Serializable {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	/**
// 	 * The templated cypher query that will be executed on Neo4J
// 	 */
// 	private String templateStatement;
// 
// 	/**
// 	 * 
// 	 */
// 	private M mapper;
// 
// 	/**
// 	 * 
// 	 * @param templateStatement the cypher statement template
// 	 * @param mapper an actual SerializationMapper implementation
// 	 */
// 	public Neo4JSerializationMappingStrategy(final String templateStatement, M mapper) {
// 		this.templateStatement = templateStatement;
// 		this.mapper = mapper;
// 	}
// 
// 	/**
// 	 * 
// 	 * @return the cypher statement template
// 	 */
// 	public Statement getStatement() {
// 		return new Statement(templateStatement);
// 	}
// 
// 	/**
// 	 * Maps a single result record into a T object
// 	 * 
// 	 * @param record a record that will be returned by the cypher query
// 	 * @return an object of type T
// 	 */
// 	public T map(Record record) {
// 		return this.mapper.serialize(record.asMap());
// 	}
// }
// 
// Path: src/test/java/org/apache/flink/mapping/neo4j/SerializationMapperTest.java
// class TupleSerializationMapper implements SerializationMapper<Tuple2<String, Integer>> {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	@Override
// 	public Tuple2<String, Integer> serialize(Map<String, Object> record) {
// 		Tuple2<String, Integer> tuple = new Tuple2<String, Integer>();
// 
// 		tuple.f0 = record.get("i.description").toString();
// 		tuple.f1 = Integer.valueOf(record.get("i.id").toString());
// 
// 		return tuple;
// 	}
// }


// Path: src/test/java/org/apache/flink/mapping/neo4j/Neo4JSerializationMappingStrategyTest.java
import java.util.HashMap;
import java.util.Map;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.mapping.neo4j.Neo4JSerializationMappingStrategy;
import org.apache.flink.mapping.neo4j.SerializationMapperTest.TupleSerializationMapper;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.neo4j.driver.v1.Record;

package org.apache.flink.mapping.neo4j;



public class Neo4JSerializationMappingStrategyTest {

	final SerializationMapperTest.TupleSerializationMapper serializationMapper = new SerializationMapperTest().new TupleSerializationMapper();

	class Neo4JSourceMappingStrategyTuple extends
			Neo4JSerializationMappingStrategy<Tuple2<String, Integer>, SerializationMapperTest.TupleSerializationMapper> {

		private static final long serialVersionUID = 1L;

		public Neo4JSourceMappingStrategyTuple(String templateStatement, TupleSerializationMapper mapper) {
			super(templateStatement, mapper);
		}
	}

	@Test
	public void testMappingStrategy() {
		String templateStatement = "MATCH (i:Item) return i.id, i.description";

		Neo4JSerializationMappingStrategy<Tuple2<String, Integer>, SerializationMapperTest.TupleSerializationMapper> sourceMappingStrategy = new Neo4JSourceMappingStrategyTuple(
				templateStatement, serializationMapper);

		Assert.assertNotNull(sourceMappingStrategy.getStatement());

		Map<String, Object> result = new HashMap<String, Object>();
		result.put("i.id", new Integer(1));
		result.put("i.description", "an item");

		Record record = Mockito.mock(Record.class);
		Mockito.when(record.asMap()).thenAnswer(new Answer<Map<String, Object>>() {

			@Override
			public Map<String, Object> answer(InvocationOnMock invocation) throws Throwable {
				Map<String, Object> map = new HashMap<String, Object>();
				map.put("i.id", new Integer(1));
				map.put("i.description", "an item");