Skip to content

Commit 05c451a

Browse files
committed
Add IT for nested queries using Session#run()
1 parent efc5b6d commit 05c451a

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

driver/src/test/java/org/neo4j/driver/v1/integration/SessionIT.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,6 +1343,38 @@ public void shouldPropagateTransactionRollbackErrorWhenClosed() throws Exception
13431343
testTransactionCloseErrorPropagationWhenSessionClosed( "rollback_error.script", false, "Unable to rollback" );
13441344
}
13451345

1346+
@Test
1347+
public void shouldSupportNestedQueries()
1348+
{
1349+
try ( Session session = neo4j.driver().session() )
1350+
{
1351+
// populate db with test data
1352+
session.run( "UNWIND range(1, 100) AS x CREATE (:Property {id: x})" ).consume();
1353+
session.run( "UNWIND range(1, 10) AS x CREATE (:Resource {id: x})" ).consume();
1354+
1355+
int seenProperties = 0;
1356+
int seenResources = 0;
1357+
1358+
// read properties and resources using a single session
1359+
StatementResult properties = session.run( "MATCH (p:Property) RETURN p" );
1360+
while ( properties.hasNext() )
1361+
{
1362+
assertNotNull( properties.next() );
1363+
seenProperties++;
1364+
1365+
StatementResult resources = session.run( "MATCH (r:Resource) RETURN r" );
1366+
while ( resources.hasNext() )
1367+
{
1368+
assertNotNull( resources.next() );
1369+
seenResources++;
1370+
}
1371+
}
1372+
1373+
assertEquals( 100, seenProperties );
1374+
assertEquals( 1000, seenResources );
1375+
}
1376+
}
1377+
13461378
private void testExecuteReadTx( AccessMode sessionMode )
13471379
{
13481380
Driver driver = neo4j.driver();

0 commit comments

Comments
 (0)