@Override public ResourceIterable<Node> getAllNodes() { return database.getAllNodes(); }
private void deleteAllNodesAndRelationships() { Iterable<Node> allNodes = db.getAllNodes(); for ( Node n : allNodes ) { Iterable<Relationship> relationships = n.getRelationships(); for ( Relationship rel : relationships ) { rel.delete(); } n.delete(); } }
private int createSimpleDatabase( final GraphDatabaseAPI graph ) { final int numberOfNodes = 10; new Transactor( graph, () -> { for ( int i = 0; i < numberOfNodes; i++ ) { graph.createNode(); } for ( Node n1 : graph.getAllNodes() ) { for ( Node n2 : graph.getAllNodes() ) { if ( n1.equals( n2 ) ) { continue; } n1.createRelationshipTo( n2, RelationshipType.withName( "REL" ) ); } } } ).execute(); return numberOfNodes; } }
@Test public void getAllNodesIteratorShouldPickUpHigherIdsThanHighIdWhenStarted() throws Exception { // GIVEN { Transaction tx = db.beginTx(); db.createNode(); db.createNode(); tx.success(); tx.close(); } // WHEN iterator is started Transaction transaction = db.beginTx(); Iterator<Node> allNodes = db.getAllNodes().iterator(); allNodes.next(); // and WHEN another node is then added Thread thread = new Thread( () -> { Transaction newTx = db.beginTx(); assertThat( newTx, not( instanceOf( PlaceboTransaction.class ) ) ); db.createNode(); newTx.success(); newTx.close(); } ); thread.start(); thread.join(); // THEN the new node is picked up by the iterator assertThat( addToCollection( allNodes, new ArrayList<>() ).size(), is( 2 ) ); transaction.close(); }
for ( Node node : newDb.getAllNodes() )
@After public void clean() throws Exception { try ( Transaction tx = graphDatabaseAPI.beginTx() ) { KernelTransaction ktx = ktx(); if ( index.type() == UNIQUE ) { ktx.schemaWrite().constraintDrop( ConstraintDescriptorFactory.uniqueForSchema( index.schema() ) ); } else { ktx.schemaWrite().indexDrop( index ); } tx.success(); } try ( Transaction tx = graphDatabaseAPI.beginTx() ) { for ( Node node : graphDatabaseAPI.getAllNodes() ) { node.delete(); } tx.success(); } }
assertEquals( 2, Iterables.count( db.getAllNodes() ) );
@Override public ResourceIterable<Node> getAllNodes() { return database.getAllNodes(); }
@Override public ResourceIterable<Node> getAllNodes() { return nodes( actual.getAllNodes() ); }