use of org.neo4j.graphdb.GraphDatabaseService in project neo4j by neo4j.
the class SchemaIndexProviderApprovalTest method init.
@BeforeClass
public static void init() {
GraphDatabaseService db = new TestGraphDatabaseFactory().newImpermanentDatabase();
for (TestValue value : TestValue.values()) {
createNode(db, PROPERTY_KEY, value.value);
}
noIndexRun = runFindByLabelAndProperty(db);
createIndex(db, label(LABEL), PROPERTY_KEY);
indexRun = runFindByLabelAndProperty(db);
db.shutdown();
}
use of org.neo4j.graphdb.GraphDatabaseService in project neo4j by neo4j.
the class SchemaConstraintProviderApprovalTest method init.
@BeforeClass
public static void init() {
GraphDatabaseService db = new TestGraphDatabaseFactory().newImpermanentDatabase();
for (TestValue value : TestValue.values()) {
createNode(db, PROPERTY_KEY, value.value);
}
noIndexRun = runFindByLabelAndProperty(db);
createConstraint(db, label(LABEL), PROPERTY_KEY);
constraintRun = runFindByLabelAndProperty(db);
db.shutdown();
}
use of org.neo4j.graphdb.GraphDatabaseService in project neo4j by neo4j.
the class NodeCountsTest method shouldNotSeeNodeCountsOfOtherTransaction.
@Test
public void shouldNotSeeNodeCountsOfOtherTransaction() throws Exception {
// given
GraphDatabaseService graphDb = db.getGraphDatabaseAPI();
final Barrier.Control barrier = new Barrier.Control();
long before = numberOfNodes();
Future<Long> done = threading.execute(new NamedFunction<GraphDatabaseService, Long>("create-nodes") {
@Override
public Long apply(GraphDatabaseService graphDb) {
try (Transaction tx = graphDb.beginTx()) {
graphDb.createNode();
graphDb.createNode();
barrier.reached();
long whatThisThreadSees = countsForNode();
tx.success();
return whatThisThreadSees;
}
}
}, graphDb);
barrier.await();
// when
long during = numberOfNodes();
barrier.release();
long whatOtherThreadSees = done.get();
long after = numberOfNodes();
// then
assertEquals(0, before);
assertEquals(0, during);
assertEquals(after, whatOtherThreadSees);
assertEquals(2, after);
}
use of org.neo4j.graphdb.GraphDatabaseService in project neo4j by neo4j.
the class NodeCountsTest method shouldReportNumberOfNodes.
@Test
public void shouldReportNumberOfNodes() throws Exception {
// given
GraphDatabaseService graphDb = db.getGraphDatabaseAPI();
try (Transaction tx = graphDb.beginTx()) {
graphDb.createNode();
graphDb.createNode();
tx.success();
}
// when
long nodeCount = numberOfNodes();
// then
assertEquals(2, nodeCount);
}
use of org.neo4j.graphdb.GraphDatabaseService in project neo4j by neo4j.
the class NodeCountsTest method shouldReportAccurateNumberOfNodesAfterDeletion.
@Test
public void shouldReportAccurateNumberOfNodesAfterDeletion() throws Exception {
// given
GraphDatabaseService graphDb = db.getGraphDatabaseAPI();
Node one;
try (Transaction tx = graphDb.beginTx()) {
one = graphDb.createNode();
graphDb.createNode();
tx.success();
}
try (Transaction tx = graphDb.beginTx()) {
one.delete();
tx.success();
}
// when
long nodeCount = numberOfNodes();
// then
assertEquals(1, nodeCount);
}
Aggregations