### Question:
Neo4jHealthCheck extends NamedHealthCheck { @Override protected Result check() throws Exception { int count = 0; try (Transaction tx = graphDb.beginTx()) { count = size(graphDb.getAllNodes()); tx.success(); } if (count > 0) { return Result.healthy(); } else { return Result.unhealthy("There are no nodes in the graph."); } } @Inject  Neo4jHealthCheck(GraphDatabaseService graphDb); @Override String getName();  }### Answer:
@Test public void whenNoNodes_unhealty() throws Exception { GraphDatabaseService graphDb = new TestGraphDatabaseFactory().newImpermanentDatabase(); Neo4jHealthCheck healthCheck = new Neo4jHealthCheck(graphDb); assertThat(healthCheck.check().isHealthy(), is(false)); graphDb.shutdown(); }
@Test public void whenNodes_healty() throws Exception { GraphDatabaseService graphDb = new TestGraphDatabaseFactory().newImpermanentDatabase(); Neo4jHealthCheck healthCheck = new Neo4jHealthCheck(graphDb); try (Transaction tx = graphDb.beginTx()) { graphDb.createNode(); tx.success(); } assertThat(healthCheck.check().isHealthy(), is(true)); graphDb.shutdown(); }