Search in sources :

Example 1 with LinePrinter

use of org.neo4j.shell.prettyprint.LinePrinter in project neo4j by neo4j.

the class CypherShellTest method executeShouldPrintResult.

@Test
public void executeShouldPrintResult() throws CommandException {
    Driver mockedDriver = mock(Driver.class);
    Session session = mock(Session.class);
    BoltResult result = mock(ListBoltResult.class);
    BoltStateHandler boltStateHandler = mock(BoltStateHandler.class);
    when(boltStateHandler.isConnected()).thenReturn(true);
    when(boltStateHandler.runCypher(anyString(), anyMap())).thenReturn(Optional.of(result));
    doAnswer(a -> {
        ((LinePrinter) a.getArguments()[1]).printOut("999");
        return null;
    }).when(mockedPrettyPrinter).format(any(BoltResult.class), anyObject());
    when(mockedDriver.session()).thenReturn(session);
    OfflineTestShell shell = new OfflineTestShell(logger, boltStateHandler, mockedPrettyPrinter);
    shell.execute("RETURN 999");
    verify(logger).printOut(contains("999"));
}
Also used : BoltStateHandler(org.neo4j.shell.state.BoltStateHandler) Driver(org.neo4j.driver.Driver) BoltResult(org.neo4j.shell.state.BoltResult) ListBoltResult(org.neo4j.shell.state.ListBoltResult) Session(org.neo4j.driver.Session) LinePrinter(org.neo4j.shell.prettyprint.LinePrinter) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Driver (org.neo4j.driver.Driver)1 Session (org.neo4j.driver.Session)1 LinePrinter (org.neo4j.shell.prettyprint.LinePrinter)1 BoltResult (org.neo4j.shell.state.BoltResult)1 BoltStateHandler (org.neo4j.shell.state.BoltStateHandler)1 ListBoltResult (org.neo4j.shell.state.ListBoltResult)1