@Override
  public synchronized void cleanupAll() {
    LOG.info("Attempting to cleanup MongoDB manager.");

    boolean producedError = false;

    // First, delete the database if it was not given as a static argument
    try {
      if (!usingStaticDatabase) {
        mongoClient.getDatabase(databaseName).drop();
      }
    } catch (Exception e) {
      LOG.error("Failed to delete MongoDB database {}.", databaseName, e);
      producedError = true;
    }

    // Next, try to close the MongoDB client connection
    try {
      mongoClient.close();
    } catch (Exception e) {
      LOG.error("Failed to delete MongoDB client.", e);
      producedError = true;
    }

    // Throw Exception at the end if there were any errors
    if (producedError) {
      throw new MongoDBResourceManagerException(
          "Failed to delete resources. Check above for errors.");
    }

    super.cleanupAll();

    LOG.info("MongoDB manager successfully cleaned up.");
  }
@Test
  public void testCleanupAllShouldThrowErrorWhenMongoClientFailsToClose() {
    doThrow(RuntimeException.class).when(mongoClient).close();

    assertThrows(MongoDBResourceManagerException.class, () -> testManager.cleanupAll());
  }