@Test public void givenShellClientWhenOpenFileThenExecuteFileCommands() { // Given // an empty database // When StartClient.main(new String[] {"-file", getClass().getResource("/testshell.txt").getFile()}); // Then try (Transaction tx = db.getGraphDatabaseService().beginTx()) { assertThat( (String) db.getGraphDatabaseService().getNodeById(0).getProperty("foo"), equalTo("bar")); tx.success(); } }
private Neo4jMatchers.Deferred<Label> labels(final Node myNode) { return new Neo4jMatchers.Deferred<Label>(dbRule.getGraphDatabaseService()) { @Override protected Iterable<Label> manifest() { return myNode.getLabels(); } }; }
@SuppressWarnings("unused") private int iterateThroughPagedTraverser(PagedTraverser traversalPager) { try (Transaction transaction = dbRule.getGraphDatabaseService().beginTx()) { int count = 0; for (List<Path> paths : traversalPager) { count++; } transaction.success(); return count; } }
@Test public void givenShellClientWhenReadFromStdinThenExecutePipedCommands() throws IOException { // Given // an empty database // When InputStream realStdin = System.in; try { System.setIn(new ByteArrayInputStream("CREATE (n {foo:'bar'});".getBytes())); StartClient.main(new String[] {"-file", "-"}); } finally { System.setIn(realStdin); } // Then try (Transaction tx = db.getGraphDatabaseService().beginTx()) { assertThat( (String) db.getGraphDatabaseService().getNodeById(0).getProperty("foo"), equalTo("bar")); tx.success(); } }
@Before public void clearDb() throws Throwable { createLinkedList(LIST_LENGTH, dbRule.getGraphDatabaseService()); }