Search in sources :

Example 26 with Result

use of org.neo4j.driver.Result in project neo4j by neo4j.

the class TableOutputFormatterTest method wrapNumberContentWithLongSize.

@Test
public void wrapNumberContentWithLongSize() {
    // GIVEN
    Result result = mockResult(asList("c1"), 345, 12, 978623, 132456798, 9223372036854775807L);
    // 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                  |", "+---------------------+", "| 345                 |", "| 12                  |", "| 978623              |", "| 132456798           |", "| 9223372036854775807 |", "+---------------------+", NEWLINE)));
}
Also used : ListBoltResult(org.neo4j.shell.state.ListBoltResult) StringContains.containsString(org.hamcrest.core.StringContains.containsString) BoltResult(org.neo4j.shell.state.BoltResult) ListBoltResult(org.neo4j.shell.state.ListBoltResult) Result(org.neo4j.driver.Result) Test(org.junit.Test)

Example 27 with Result

use of org.neo4j.driver.Result in project neo4j by neo4j.

the class TableOutputFormatterTest method fiveRowsWithNumbersNotAllSampled.

@Test
public void fiveRowsWithNumbersNotAllSampled() {
    // GIVEN
    Result result = mockResult(asList("c1", "c2"), "a", 42, "b", 43, "c", 44, "d", 45, "e", 46);
    // WHEN
    String table = formatResult(result);
    // THEN
    assertThat(table, containsString("| \"a\" | 42 |"));
    assertThat(table, containsString("| \"b\" | 43 |"));
    assertThat(table, containsString("| \"c\" | 44 |"));
    assertThat(table, containsString("| \"d\" | 45 |"));
    assertThat(table, containsString("| \"e\" | 46 |"));
}
Also used : StringContains.containsString(org.hamcrest.core.StringContains.containsString) BoltResult(org.neo4j.shell.state.BoltResult) ListBoltResult(org.neo4j.shell.state.ListBoltResult) Result(org.neo4j.driver.Result) Test(org.junit.Test)

Example 28 with Result

use of org.neo4j.driver.Result in project neo4j by neo4j.

the class TableOutputFormatterTest method formatEntities.

@Test
public void formatEntities() {
    // GIVEN
    Map<String, Value> properties = singletonMap("name", Values.value("Mark"));
    Map<String, Value> relProperties = singletonMap("since", Values.value(2016));
    InternalNode node = new InternalNode(12, asList("Person"), properties);
    InternalRelationship relationship = new InternalRelationship(24, 12, 12, "TEST", relProperties);
    Result result = mockResult(asList("a", "b", "c"), node, relationship, new InternalPath(node, relationship, node));
    // WHEN
    String table = formatResult(result);
    // THEN
    assertThat(table, containsString("| (:Person {name: \"Mark\"}) | [:TEST {since: 2016}] |"));
    assertThat(table, containsString("| (:Person {name: \"Mark\"})-[:TEST {since: 2016}]->(:Person {name: \"Mark\"}) |"));
}
Also used : InternalRelationship(org.neo4j.driver.internal.InternalRelationship) InternalPath(org.neo4j.driver.internal.InternalPath) Value(org.neo4j.driver.Value) RelationshipValue(org.neo4j.driver.internal.value.RelationshipValue) NodeValue(org.neo4j.driver.internal.value.NodeValue) DurationValue(org.neo4j.driver.internal.value.DurationValue) PathValue(org.neo4j.driver.internal.value.PathValue) PointValue(org.neo4j.driver.internal.value.PointValue) StringContains.containsString(org.hamcrest.core.StringContains.containsString) InternalNode(org.neo4j.driver.internal.InternalNode) BoltResult(org.neo4j.shell.state.BoltResult) ListBoltResult(org.neo4j.shell.state.ListBoltResult) Result(org.neo4j.driver.Result) Test(org.junit.Test)

Example 29 with Result

use of org.neo4j.driver.Result in project neo4j by neo4j.

the class TableOutputFormatterTest method twoRowsWithNumbersAllSampled.

@Test
public void twoRowsWithNumbersAllSampled() {
    // GIVEN
    Result result = mockResult(asList("c1", "c2"), "a", 42, "b", 43);
    // WHEN
    String table = formatResult(result);
    // THEN
    assertThat(table, containsString("| \"a\" | 42 |"));
    assertThat(table, containsString("| \"b\" | 43 |"));
}
Also used : StringContains.containsString(org.hamcrest.core.StringContains.containsString) BoltResult(org.neo4j.shell.state.BoltResult) ListBoltResult(org.neo4j.shell.state.ListBoltResult) Result(org.neo4j.driver.Result) Test(org.junit.Test)

Aggregations

Result (org.neo4j.driver.Result)29 Test (org.junit.Test)19 Session (org.neo4j.driver.Session)16 Driver (org.neo4j.driver.Driver)13 StringContains.containsString (org.hamcrest.core.StringContains.containsString)8 BoltResult (org.neo4j.shell.state.BoltResult)8 ListBoltResult (org.neo4j.shell.state.ListBoltResult)8 FakeDriver (org.neo4j.shell.test.bolt.FakeDriver)8 FakeSession (org.neo4j.shell.test.bolt.FakeSession)8 Record (org.neo4j.driver.Record)7 SessionConfig (org.neo4j.driver.SessionConfig)5 ClientException (org.neo4j.driver.exceptions.ClientException)5 SessionExpiredException (org.neo4j.driver.exceptions.SessionExpiredException)5 Query (org.neo4j.driver.Query)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Test (org.junit.jupiter.api.Test)3 Value (org.neo4j.driver.Value)3 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2