Search in sources :

Example 1 with ServerInfo

use of org.neo4j.driver.summary.ServerInfo in project spring-boot by spring-projects.

the class Neo4jHealthDetailsHandler method addHealthDetails.

/**
 * Add health details for the specified {@link ResultSummary} and {@code edition}.
 * @param builder the {@link Builder} to use
 * @param healthDetails the health details of the server
 */
void addHealthDetails(Builder builder, Neo4jHealthDetails healthDetails) {
    ResultSummary summary = healthDetails.getSummary();
    ServerInfo serverInfo = summary.server();
    builder.up().withDetail("server", healthDetails.getVersion() + "@" + serverInfo.address()).withDetail("edition", healthDetails.getEdition());
    DatabaseInfo databaseInfo = summary.database();
    if (StringUtils.hasText(databaseInfo.name())) {
        builder.withDetail("database", databaseInfo.name());
    }
}
Also used : DatabaseInfo(org.neo4j.driver.summary.DatabaseInfo) ServerInfo(org.neo4j.driver.summary.ServerInfo) ResultSummary(org.neo4j.driver.summary.ResultSummary)

Example 2 with ServerInfo

use of org.neo4j.driver.summary.ServerInfo in project spring-boot by spring-projects.

the class ResultSummaryMock method createResultSummary.

static ResultSummary createResultSummary(String serverAddress, String databaseName) {
    ServerInfo serverInfo = mock(ServerInfo.class);
    given(serverInfo.address()).willReturn(serverAddress);
    DatabaseInfo databaseInfo = mock(DatabaseInfo.class);
    given(databaseInfo.name()).willReturn(databaseName);
    ResultSummary resultSummary = mock(ResultSummary.class);
    given(resultSummary.server()).willReturn(serverInfo);
    given(resultSummary.database()).willReturn(databaseInfo);
    return resultSummary;
}
Also used : DatabaseInfo(org.neo4j.driver.summary.DatabaseInfo) ServerInfo(org.neo4j.driver.summary.ServerInfo) ResultSummary(org.neo4j.driver.summary.ResultSummary)

Example 3 with ServerInfo

use of org.neo4j.driver.summary.ServerInfo in project neo4j by neo4j.

the class BoltStateHandlerTest method stubResultSummaryInAnOpenSession.

private Driver stubResultSummaryInAnOpenSession(Result resultMock, Session sessionMock, String protocolVersion, String databaseName) {
    Driver driverMock = mock(Driver.class);
    ResultSummary resultSummary = mock(ResultSummary.class);
    ServerInfo serverInfo = mock(ServerInfo.class);
    DatabaseInfo databaseInfo = mock(DatabaseInfo.class);
    when(resultSummary.server()).thenReturn(serverInfo);
    when(serverInfo.protocolVersion()).thenReturn(protocolVersion);
    when(resultMock.consume()).thenReturn(resultSummary);
    when(resultSummary.database()).thenReturn(databaseInfo);
    when(databaseInfo.name()).thenReturn(databaseName);
    when(sessionMock.isOpen()).thenReturn(true);
    when(sessionMock.run("CALL db.ping()")).thenReturn(resultMock);
    when(sessionMock.run(anyString(), any(Value.class))).thenReturn(resultMock);
    when(driverMock.session(any())).thenReturn(sessionMock);
    return driverMock;
}
Also used : DatabaseInfo(org.neo4j.driver.summary.DatabaseInfo) ServerInfo(org.neo4j.driver.summary.ServerInfo) ResultSummary(org.neo4j.driver.summary.ResultSummary) Value(org.neo4j.driver.Value) Driver(org.neo4j.driver.Driver) FakeDriver(org.neo4j.shell.test.bolt.FakeDriver)

Aggregations

DatabaseInfo (org.neo4j.driver.summary.DatabaseInfo)3 ResultSummary (org.neo4j.driver.summary.ResultSummary)3 ServerInfo (org.neo4j.driver.summary.ServerInfo)3 Driver (org.neo4j.driver.Driver)1 Value (org.neo4j.driver.Value)1 FakeDriver (org.neo4j.shell.test.bolt.FakeDriver)1