use of org.neo4j.harness.junit.Neo4jRule in project neo4j by neo4j.
the class JUnitRuleTest method shouldRuleWorkWithExsitingDirectory.
@Test
public void shouldRuleWorkWithExsitingDirectory() {
// given
GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder(testDirectory.directory()).newGraphDatabase();
try {
db.execute("CREATE ()");
} finally {
db.shutdown();
}
// When a rule with an pre-populated graph db directory is used
final Neo4jRule ruleWithDirectory = new Neo4jRule(testDirectory.directory()).copyFrom(testDirectory.directory());
ruleWithDirectory.apply(new Statement() {
@Override
public void evaluate() throws Throwable {
// Then the database is not empty
Result result = ruleWithDirectory.getGraphDatabaseService().execute("match (n) return count(n) as " + "count");
List<Object> column = Iterators.asList(result.columnAs("count"));
assertEquals(1, column.size());
assertEquals(1, column.get(0));
}
}, null);
}
Aggregations