Added setter for properties in the Neo4JItemReader
This commit is contained in:
@@ -85,6 +85,15 @@ InitializingBean {
|
||||
setName(ClassUtils.getShortName(Neo4jItemReader.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional parameters to be used in the cypher query.
|
||||
*
|
||||
* @param parameterValues the parameter values to be used in the cypher query
|
||||
*/
|
||||
public void setParameterValues(Map<String, Object> parameterValues) {
|
||||
this.parameterValues = parameterValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* The start segment of the cypher query. START is prepended
|
||||
* to the statement provided and should <em>not</em> be
|
||||
|
||||
@@ -15,19 +15,6 @@
|
||||
*/
|
||||
package org.springframework.batch.item.data;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.data.neo4j.conversion.DefaultConverter;
|
||||
import org.springframework.data.neo4j.conversion.Result;
|
||||
import org.springframework.data.neo4j.conversion.ResultConverter;
|
||||
import org.springframework.data.neo4j.template.Neo4jOperations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -35,6 +22,21 @@ import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.isNull;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import org.springframework.data.neo4j.conversion.DefaultConverter;
|
||||
import org.springframework.data.neo4j.conversion.Result;
|
||||
import org.springframework.data.neo4j.conversion.ResultConverter;
|
||||
import org.springframework.data.neo4j.template.Neo4jOperations;
|
||||
|
||||
public class Neo4jItemReaderTests {
|
||||
|
||||
private Neo4jItemReader<String> reader;
|
||||
@@ -173,6 +175,25 @@ public class Neo4jItemReaderTests {
|
||||
reader.afterPropertiesSet();
|
||||
when(template.query("START n=node(*) MATCH n -- m WHERE has(n.name) RETURN m ORDER BY n.age SKIP 0 LIMIT 50", null)).thenReturn(result);
|
||||
when(result.to(String.class)).thenReturn(endResult);
|
||||
when(endResult.iterator()).thenReturn(new ArrayList<String>() {{
|
||||
add(new String());
|
||||
}}.iterator());
|
||||
|
||||
assertTrue(reader.doPageRead().hasNext());
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Test
|
||||
public void testResultsWithMatchAndWhereWithParameters() throws Exception {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("foo", "bar");
|
||||
reader.setParameterValues(params);
|
||||
reader.setMatchStatement("n -- m");
|
||||
reader.setWhereStatement("has(n.name)");
|
||||
reader.setReturnStatement("m");
|
||||
reader.afterPropertiesSet();
|
||||
when(template.query("START n=node(*) MATCH n -- m WHERE has(n.name) RETURN m ORDER BY n.age SKIP 0 LIMIT 50", params)).thenReturn(result);
|
||||
when(result.to(String.class)).thenReturn(endResult);
|
||||
when(endResult.iterator()).thenReturn(new ArrayList<String>(){{
|
||||
add(new String());
|
||||
}}.iterator());
|
||||
|
||||
Reference in New Issue
Block a user