Search in sources :

Example 21 with ListBoltResult

use of org.neo4j.shell.state.ListBoltResult 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)));
}
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 22 with ListBoltResult

use of org.neo4j.shell.state.ListBoltResult 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 23 with ListBoltResult

use of org.neo4j.shell.state.ListBoltResult in project neo4j by neo4j.

the class TableOutputFormatterTest method prettyPrintRelationships.

@Test
public void prettyPrintRelationships() {
    // given
    List<String> keys = asList("rel");
    Map<String, Value> propertiesAsMap = new HashMap<>();
    propertiesAsMap.put("prop1", Values.value("prop1_value"));
    propertiesAsMap.put("prop2", Values.value("prop2_value"));
    RelationshipValue relationship = new RelationshipValue(new InternalRelationship(1, 1, 2, "RELATIONSHIP_TYPE", propertiesAsMap));
    Record record = new InternalRecord(keys, new Value[] { relationship });
    // when
    String actual = verbosePrinter.format(new ListBoltResult(asList(record), mock(ResultSummary.class)));
    // then
    assertThat(actual, containsString("| [:RELATIONSHIP_TYPE {prop2: \"prop2_value\", prop1: \"prop1_value\"}] |"));
}
Also used : InternalRecord(org.neo4j.driver.internal.InternalRecord) InternalRelationship(org.neo4j.driver.internal.InternalRelationship) ListBoltResult(org.neo4j.shell.state.ListBoltResult) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) 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) InternalRecord(org.neo4j.driver.internal.InternalRecord) Record(org.neo4j.driver.Record) StringContains.containsString(org.hamcrest.core.StringContains.containsString) RelationshipValue(org.neo4j.driver.internal.value.RelationshipValue) Test(org.junit.Test)

Example 24 with ListBoltResult

use of org.neo4j.shell.state.ListBoltResult in project neo4j by neo4j.

the class TableOutputFormatterTest method prettyPrintPoint.

@Test
public void prettyPrintPoint() {
    // given
    List<String> keys = asList("p1", "p2");
    Value point2d = new PointValue(new InternalPoint2D(4326, 42.78, 56.7));
    Value point3d = new PointValue(new InternalPoint3D(4326, 1.7, 26.79, 34.23));
    Record record = new InternalRecord(keys, new Value[] { point2d, point3d });
    // when
    String actual = verbosePrinter.format(new ListBoltResult(asList(record), mock(ResultSummary.class)));
    // then
    assertThat(actual, containsString("| point({srid:4326, x:42.78, y:56.7}) |"));
    assertThat(actual, containsString("| point({srid:4326, x:1.7, y:26.79, z:34.23}) |"));
}
Also used : InternalRecord(org.neo4j.driver.internal.InternalRecord) ListBoltResult(org.neo4j.shell.state.ListBoltResult) PointValue(org.neo4j.driver.internal.value.PointValue) 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) InternalPoint3D(org.neo4j.driver.internal.InternalPoint3D) InternalRecord(org.neo4j.driver.internal.InternalRecord) Record(org.neo4j.driver.Record) StringContains.containsString(org.hamcrest.core.StringContains.containsString) InternalPoint2D(org.neo4j.driver.internal.InternalPoint2D) Test(org.junit.Test)

Example 25 with ListBoltResult

use of org.neo4j.shell.state.ListBoltResult in project neo4j by neo4j.

the class TableOutputFormatterTest method prettyPrintDuration.

@Test
public void prettyPrintDuration() {
    // given
    List<String> keys = asList("d");
    Value duration = new DurationValue(new InternalIsoDuration(1, 2, 3, 4));
    Record record = new InternalRecord(keys, new Value[] { duration });
    // when
    String actual = verbosePrinter.format(new ListBoltResult(asList(record), mock(ResultSummary.class)));
    // then
    assertThat(actual, containsString("| P1M2DT3.000000004S |"));
}
Also used : InternalRecord(org.neo4j.driver.internal.InternalRecord) ListBoltResult(org.neo4j.shell.state.ListBoltResult) DurationValue(org.neo4j.driver.internal.value.DurationValue) 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) InternalRecord(org.neo4j.driver.internal.InternalRecord) Record(org.neo4j.driver.Record) StringContains.containsString(org.hamcrest.core.StringContains.containsString) InternalIsoDuration(org.neo4j.driver.internal.InternalIsoDuration) Test(org.junit.Test)

Aggregations

ListBoltResult (org.neo4j.shell.state.ListBoltResult)26 Test (org.junit.Test)24 Value (org.neo4j.driver.Value)20 BoltResult (org.neo4j.shell.state.BoltResult)18 Record (org.neo4j.driver.Record)16 ResultSummary (org.neo4j.driver.summary.ResultSummary)14 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)12 StringContains.containsString (org.hamcrest.core.StringContains.containsString)12 DurationValue (org.neo4j.driver.internal.value.DurationValue)8 NodeValue (org.neo4j.driver.internal.value.NodeValue)8 PathValue (org.neo4j.driver.internal.value.PathValue)8 PointValue (org.neo4j.driver.internal.value.PointValue)8 RelationshipValue (org.neo4j.driver.internal.value.RelationshipValue)8 HashMap (java.util.HashMap)7 InternalRecord (org.neo4j.driver.internal.InternalRecord)7 Node (org.neo4j.driver.types.Node)6 Relationship (org.neo4j.driver.types.Relationship)6 Matchers.anyObject (org.mockito.Matchers.anyObject)4 Result (org.neo4j.driver.Result)4 ProfiledPlan (org.neo4j.driver.summary.ProfiledPlan)4