Search in sources :

Example 21 with ResultSummary

use of org.neo4j.driver.summary.ResultSummary 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

ResultSummary (org.neo4j.driver.summary.ResultSummary)21 Test (org.junit.Test)8 Driver (org.neo4j.driver.Driver)7 Test (org.junit.jupiter.api.Test)6 Value (org.neo4j.driver.Value)6 BoltResult (org.neo4j.shell.state.BoltResult)6 ListBoltResult (org.neo4j.shell.state.ListBoltResult)6 Record (org.neo4j.driver.Record)5 ProfiledPlan (org.neo4j.driver.summary.ProfiledPlan)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 Result (org.neo4j.driver.Result)4 Health (org.springframework.boot.actuate.health.Health)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 SessionConfig (org.neo4j.driver.SessionConfig)3 SessionExpiredException (org.neo4j.driver.exceptions.SessionExpiredException)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 BDDMockito.given (org.mockito.BDDMockito.given)2 BDDMockito.then (org.mockito.BDDMockito.then)2