@Test void testHealthy() { var client = mock(MongoClient.class); var iterable = mock(MongoIterable.class); var cursor = mock(MongoCursor.class); when(client.listDatabaseNames()).thenReturn(iterable); when(iterable.iterator()).thenReturn(cursor); when(cursor.hasNext()).thenReturn(true); MongoDbHealthCheck healthCheck = new MongoDbHealthCheck(client); assertTrue(healthCheck.check()::isHealthy); }
@Override protected Result check() { LOG.info("Checking health of MongoDB..."); return mongoClient.listDatabaseNames().iterator().hasNext() ? Result.healthy() : Result.unhealthy("No databases in MongoDB"); }
MongoDbHealthCheck extends DatabaseHealthCheck { @Override protected Result check() { LOG.info("Checking health of MongoDB..."); return mongoClient.listDatabaseNames().iterator().hasNext() ? Result.healthy() : Result.unhealthy("No databases in MongoDB"); } }
MongoDbHealthCheck extends DatabaseHealthCheck { @Override protected Result check() { LOG.info("Checking health of MongoDB..."); return mongoClient.listDatabaseNames().iterator().hasNext() ? Result.healthy() : Result.unhealthy("No databases in MongoDB"); } @Inject  MongoDbHealthCheck(MongoClient mongoClient); }
MongoDbHealthCheck extends DatabaseHealthCheck { @Override protected Result check() { LOG.info("Checking health of MongoDB..."); return mongoClient.listDatabaseNames().iterator().hasNext() ? Result.healthy() : Result.unhealthy("No databases in MongoDB"); } @Inject  MongoDbHealthCheck(MongoClient mongoClient);  }
MongoDbHealthCheck extends DatabaseHealthCheck { @Override protected Result check() { LOG.info("Checking health of MongoDB..."); return mongoClient.listDatabaseNames().iterator().hasNext() ? Result.healthy() : Result.unhealthy("No databases in MongoDB"); } @Inject  MongoDbHealthCheck(MongoClient mongoClient);   }