use of org.neo4j.test.BatchTransaction in project neo4j by neo4j.
the class CreateAndLoadDenseNodeIT method createDbIfNecessary.
private void createDbIfNecessary() {
if (!new File(dbRule.getStoreDir(), "neostore").exists()) {
db = dbRule.getGraphDatabaseAPI();
try (BatchTransaction tx = beginBatchTx(db)) {
Node node = db.createNode();
createRelationships(tx, node, MyRelTypes.TEST, INCOMING, 1);
createRelationships(tx, node, MyRelTypes.TEST, OUTGOING, 3_000_000);
createRelationships(tx, node, MyRelTypes.TEST2, OUTGOING, 5);
createRelationships(tx, node, MyRelTypes.TEST2, BOTH, 5);
createRelationships(tx, node, MyRelTypes.TEST_TRAVERSAL, OUTGOING, 2_000_000);
createRelationships(tx, node, MyRelTypes.TEST_TRAVERSAL, INCOMING, 2);
} finally {
dbRule.shutdownAndKeepStore();
}
}
}
use of org.neo4j.test.BatchTransaction in project neo4j by neo4j.
the class BatchTransactionTest method shouldUseProgressListener.
@Test
public void shouldUseProgressListener() throws Exception {
// GIVEN
Transaction transaction = mock(Transaction.class);
GraphDatabaseService db = mock(GraphDatabaseService.class);
when(db.beginTx()).thenReturn(transaction);
ProgressListener progress = mock(ProgressListener.class);
BatchTransaction tx = beginBatchTx(db).withIntermediarySize(10).withProgress(progress);
// WHEN
tx.increment();
tx.increment(9);
// THEN
verify(db, times(2)).beginTx();
verify(transaction, times(1)).close();
verify(progress, times(1)).add(1);
verify(progress, times(1)).add(9);
}
Aggregations