use of org.neo4j.driver.summary.ResultSummary in project spring-boot by spring-projects.
the class Neo4jHealthIndicatorTests method neo4jIsUpWithEmptyDatabaseName.
@Test
void neo4jIsUpWithEmptyDatabaseName() {
ResultSummary resultSummary = ResultSummaryMock.createResultSummary("My Home", "");
Driver driver = mockDriver(resultSummary, "4711", "some edition");
Health health = new Neo4jHealthIndicator(driver).health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails()).containsEntry("server", "4711@My Home");
assertThat(health.getDetails()).doesNotContainKey("database");
assertThat(health.getDetails()).containsEntry("edition", "some edition");
}
use of org.neo4j.driver.summary.ResultSummary in project spring-boot by spring-projects.
the class Neo4jHealthIndicatorTests method neo4jIsUp.
@Test
void neo4jIsUp() {
ResultSummary resultSummary = ResultSummaryMock.createResultSummary("My Home", "test");
Driver driver = mockDriver(resultSummary, "4711", "ultimate collectors edition");
Health health = new Neo4jHealthIndicator(driver).health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails()).containsEntry("server", "4711@My Home");
assertThat(health.getDetails()).containsEntry("database", "test");
assertThat(health.getDetails()).containsEntry("edition", "ultimate collectors edition");
}
use of org.neo4j.driver.summary.ResultSummary 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;
}
use of org.neo4j.driver.summary.ResultSummary in project spring-boot by spring-projects.
the class Neo4jReactiveHealthIndicatorTests method neo4jIsUpWithOneSessionExpiredException.
@Test
void neo4jIsUpWithOneSessionExpiredException() {
ResultSummary resultSummary = ResultSummaryMock.createResultSummary("My Home", "");
RxSession session = mock(RxSession.class);
RxResult statementResult = mockStatementResult(resultSummary, "4711", "some edition");
AtomicInteger count = new AtomicInteger();
given(session.run(anyString())).will((invocation) -> {
if (count.compareAndSet(0, 1)) {
throw new SessionExpiredException("Session expired");
}
return statementResult;
});
Driver driver = mock(Driver.class);
given(driver.rxSession(any(SessionConfig.class))).willReturn(session);
Neo4jReactiveHealthIndicator healthIndicator = new Neo4jReactiveHealthIndicator(driver);
healthIndicator.health().as(StepVerifier::create).consumeNextWith((health) -> {
assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails()).containsEntry("server", "4711@My Home");
assertThat(health.getDetails()).containsEntry("edition", "some edition");
}).verifyComplete();
then(session).should(times(2)).close();
}
use of org.neo4j.driver.summary.ResultSummary in project spring-boot by spring-projects.
the class Neo4jHealthIndicator method runHealthCheckQuery.
private void runHealthCheckQuery(Health.Builder builder) {
// all possible workloads
try (Session session = this.driver.session(DEFAULT_SESSION_CONFIG)) {
Result result = session.run(CYPHER);
Record record = result.single();
ResultSummary resultSummary = result.consume();
this.healthDetailsHandler.addHealthDetails(builder, new Neo4jHealthDetails(record, resultSummary));
}
}
Aggregations