use of org.neo4j.cypher.internal.javacompat.ExecutionResult in project neo4j by neo4j.
the class ExportTest method testEscapingOfRelationshipStringPropertyValue.
@Test
public void testEscapingOfRelationshipStringPropertyValue() throws Exception {
Node n = gdb.createNode();
final Relationship rel = n.createRelationshipTo(n, RelationshipType.withName("REL"));
rel.setProperty("name", "Brutus \"Brutal\" Howell");
final ExecutionResult result = result("rel", rel);
final SubGraph graph = CypherResultSubGraph.from(result, gdb, true);
assertEquals("create (_0)" + lineSeparator() + "create (_0)-[:`REL` {`name`:\"Brutus \\\"Brutal\\\" Howell\"}]->(_0)" + lineSeparator() + ";" + lineSeparator(), doExportGraph(graph));
}
use of org.neo4j.cypher.internal.javacompat.ExecutionResult in project neo4j by neo4j.
the class ExportTest method result.
@SuppressWarnings("unchecked")
private ExecutionResult result(String column, Object value) {
ExecutionResult result = Mockito.mock(ExecutionResult.class);
Mockito.when(result.columns()).thenReturn(asList(column));
final Iterator<Map<String, Object>> inner = asList(singletonMap(column, value)).iterator();
final ResourceIterator<Map<String, Object>> iterator = new ResourceIterator<Map<String, Object>>() {
@Override
public void close() {
}
@Override
public boolean hasNext() {
return inner.hasNext();
}
@Override
public Map<String, Object> next() {
return inner.next();
}
@Override
public void remove() {
inner.remove();
}
};
Mockito.when(result.iterator()).thenReturn(iterator);
Mockito.when(result.hasNext()).thenAnswer(new Answer<Boolean>() {
@Override
public Boolean answer(InvocationOnMock invocation) throws Throwable {
return iterator.hasNext();
}
});
Mockito.when(result.next()).thenAnswer(new Answer<Map<String, Object>>() {
@Override
public Map<String, Object> answer(InvocationOnMock invocation) throws Throwable {
return iterator.next();
}
});
return result;
}
use of org.neo4j.cypher.internal.javacompat.ExecutionResult in project neo4j by neo4j.
the class ExportTest method testSingleNodeWithProperties.
@Test
public void testSingleNodeWithProperties() throws Exception {
Node n = gdb.createNode();
n.setProperty("name", "Node1");
n.setProperty("age", 42);
final ExecutionResult result = result("node", n);
final SubGraph graph = CypherResultSubGraph.from(result, gdb, false);
assertEquals("create (_" + n.getId() + " {`age`:42, `name`:\"Node1\"})" + lineSeparator() + ";" + lineSeparator(), doExportGraph(graph));
}
use of org.neo4j.cypher.internal.javacompat.ExecutionResult in project neo4j by neo4j.
the class ExportTest method testExportIndexesViaCypherResult.
@Test
public void testExportIndexesViaCypherResult() throws Exception {
final Label label = Label.label("Foo");
gdb.schema().indexFor(label).on("bar").create();
gdb.schema().indexFor(label).on("bar2").create();
commitAndStartNewTransactionAfterSchemaChanges();
Node n = gdb.createNode(label);
final ExecutionResult result = result("node", n);
final SubGraph graph = CypherResultSubGraph.from(result, gdb, true);
assertEquals("create index on :`Foo`(`bar2`);" + lineSeparator() + "create index on :`Foo`(`bar`);" + lineSeparator() + "create (_0:`Foo`)" + lineSeparator() + ";" + lineSeparator(), doExportGraph(graph));
}
use of org.neo4j.cypher.internal.javacompat.ExecutionResult in project neo4j by neo4j.
the class ExportTest method testFromRelCypherResult.
@Test
public void testFromRelCypherResult() throws Exception {
Node n = gdb.createNode();
final Relationship rel = n.createRelationshipTo(n, RelationshipType.withName("REL"));
final ExecutionResult result = result("rel", rel);
final SubGraph graph = CypherResultSubGraph.from(result, gdb, true);
assertEquals("create (_0)" + lineSeparator() + "create (_0)-[:`REL`]->(_0)" + lineSeparator() + ";" + lineSeparator(), doExportGraph(graph));
}
Aggregations