use of org.neo4j.driver.Result in project neo4j by neo4j.
the class BoltStateHandler method getPing.
private ThrowingAction<CommandException> getPing() {
return () -> {
try {
Result run = session.run("CALL db.ping()");
ResultSummary summary = run.consume();
BoltStateHandler.this.protocolVersion = summary.server().protocolVersion();
updateActualDbName(summary);
} catch (ClientException e) {
// In older versions there is no db.ping procedure, use legacy method.
if (procedureNotFound(e)) {
Result run = session.run(isSystemDb() ? "CALL db.indexes()" : "RETURN 1");
ResultSummary summary = run.consume();
BoltStateHandler.this.protocolVersion = summary.server().protocolVersion();
updateActualDbName(summary);
} else {
throw e;
}
}
};
}
use of org.neo4j.driver.Result in project neo4j by neo4j.
the class TableOutputFormatterTest method formatCollections.
@Test
public void formatCollections() {
// GIVEN
Result result = mockResult(asList("a", "b", "c"), singletonMap("a", 42), asList(12, 13), singletonMap("a", asList(14, 15)));
// WHEN
String table = formatResult(result);
// THEN
assertThat(table, containsString("| {a: 42} | [12, 13] | {a: [14, 15]} |"));
}
use of org.neo4j.driver.Result in project neo4j by neo4j.
the class TableOutputFormatterTest method truncateContent.
@Test
public void truncateContent() {
// GIVEN
Result result = mockResult(asList("c1"), "a", "bb", "ccc", "dddd", "eeeee");
// WHEN
ToStringLinePrinter printer = new ToStringLinePrinter();
new TableOutputFormatter(false, 2).formatAndCount(new ListBoltResult(result.list(), result.consume()), printer);
String table = printer.result();
// THEN
assertThat(table, is(String.join(NEWLINE, "+------+", "| c1 |", "+------+", "| \"a\" |", "| \"bb\" |", "| \"cc… |", "| \"dd… |", "| \"ee… |", "+------+", NEWLINE)));
}
use of org.neo4j.driver.Result in project neo4j by neo4j.
the class TableOutputFormatterTest method basicTable.
@Test
public void basicTable() {
// GIVEN
Result result = mockResult(asList("c1", "c2"), "a", 42);
// WHEN
String table = formatResult(result);
// THEN
assertThat(table, containsString("| c1 | c2 |"));
assertThat(table, containsString("| \"a\" | 42 |"));
}
use of org.neo4j.driver.Result in project neo4j by neo4j.
the class TableOutputFormatterTest method wrapStringContent.
@Test
public void wrapStringContent() {
// GIVEN
Result result = mockResult(asList("c1"), "a", "bb", "ccc", "dddd", "eeeee");
// WHEN
ToStringLinePrinter printer = new ToStringLinePrinter();
new TableOutputFormatter(true, 2).formatAndCount(new ListBoltResult(result.list(), result.consume()), printer);
String table = printer.result();
// THEN
assertThat(table, is(String.join(NEWLINE, "+------+", "| c1 |", "+------+", "| \"a\" |", "| \"bb\" |", "| \"ccc |", "\\ \" |", "| \"ddd |", "\\ d\" |", "| \"eee |", "\\ ee\" |", "+------+", NEWLINE)));
}
Aggregations