Search in sources :

Example 16 with BoltResult

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

the class PrettyPrinterTest method prettyPrintProfileInformation.

@Test
public void prettyPrintProfileInformation() {
    // given
    ResultSummary resultSummary = mock(ResultSummary.class);
    ProfiledPlan plan = mock(ProfiledPlan.class);
    when(plan.dbHits()).thenReturn(1000L);
    when(plan.records()).thenReturn(20L);
    when(resultSummary.hasPlan()).thenReturn(true);
    when(resultSummary.hasProfile()).thenReturn(true);
    when(resultSummary.plan()).thenReturn(plan);
    when(resultSummary.profile()).thenReturn(plan);
    when(resultSummary.resultAvailableAfter(anyObject())).thenReturn(5L);
    when(resultSummary.resultConsumedAfter(anyObject())).thenReturn(7L);
    when(resultSummary.queryType()).thenReturn(QueryType.READ_ONLY);
    Map<String, Value> argumentMap = Values.parameters("Version", "3.1", "Planner", "COST", "Runtime", "INTERPRETED", "GlobalMemory", 10).asMap(v -> v);
    when(plan.arguments()).thenReturn(argumentMap);
    BoltResult result = new ListBoltResult(Collections.emptyList(), resultSummary);
    // when
    String actual = plainPrinter.format(result);
    // then
    String expected = "Plan: \"PROFILE\"\n" + "Statement: \"READ_ONLY\"\n" + "Version: \"3.1\"\n" + "Planner: \"COST\"\n" + "Runtime: \"INTERPRETED\"\n" + "Time: 12\n" + "Rows: 20\n" + "DbHits: 1000\n" + "Memory (Bytes): 10";
    Stream.of(expected.split("\n")).forEach(e -> assertThat(actual, containsString(e)));
}
Also used : ProfiledPlan(org.neo4j.driver.summary.ProfiledPlan) ListBoltResult(org.neo4j.shell.state.ListBoltResult) ResultSummary(org.neo4j.driver.summary.ResultSummary) Value(org.neo4j.driver.Value) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) BoltResult(org.neo4j.shell.state.BoltResult) ListBoltResult(org.neo4j.shell.state.ListBoltResult) Test(org.junit.Test)

Aggregations

BoltResult (org.neo4j.shell.state.BoltResult)16 ListBoltResult (org.neo4j.shell.state.ListBoltResult)16 Test (org.junit.Test)15 Value (org.neo4j.driver.Value)14 ResultSummary (org.neo4j.driver.summary.ResultSummary)14 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)12 Record (org.neo4j.driver.Record)10 Node (org.neo4j.driver.types.Node)5 Relationship (org.neo4j.driver.types.Relationship)5 HashMap (java.util.HashMap)4 Matchers.anyObject (org.mockito.Matchers.anyObject)4 ProfiledPlan (org.neo4j.driver.summary.ProfiledPlan)4 Path (org.neo4j.driver.types.Path)3 Mockito.anyObject (org.mockito.Mockito.anyObject)2 StringContains.containsString (org.hamcrest.core.StringContains.containsString)1 Driver (org.neo4j.driver.Driver)1 Session (org.neo4j.driver.Session)1 DurationValue (org.neo4j.driver.internal.value.DurationValue)1 NodeValue (org.neo4j.driver.internal.value.NodeValue)1 PathValue (org.neo4j.driver.internal.value.PathValue)1