Class MongoRule

java.lang.Object
org.junit.rules.ExternalResource
fr.gouv.vitam.common.mongo.MongoRule
All Implemented Interfaces:
org.junit.rules.TestRule

public class MongoRule extends org.junit.rules.ExternalResource
Launch a single instance of Mongo database, drop collection after each test
  • Field Details

  • Constructor Details

    • MongoRule

      public MongoRule(com.mongodb.MongoClientSettings.Builder mongoClientSettingsBuilder, String... collectionsToBePurged)
    • MongoRule

      public MongoRule(String dbName, com.mongodb.MongoClientSettings.Builder mongoClientSettingsBuilder, String... collectionsToBePurged)
  • Method Details

    • getDatabaseName

      public static String getDatabaseName()
    • after

      protected void after()
      Overrides:
      after in class org.junit.rules.ExternalResource
    • addCollectionToBePurged

      public MongoRule addCollectionToBePurged(String collectionName)
    • handleAfterClass

      public void handleAfterClass()
      Used when annotated @ClassRule
    • handleAfter

      public void handleAfter()
    • getDataBasePort

      public static int getDataBasePort()
    • getMongoClient

      public com.mongodb.client.MongoClient getMongoClient()
    • getMongoDatabase

      public com.mongodb.client.MongoDatabase getMongoDatabase()
    • getMongoCollection

      public com.mongodb.client.MongoCollection<org.bson.Document> getMongoCollection(String collectionName)
    • getMongoCollection

      public <TDocument> com.mongodb.client.MongoCollection<TDocument> getMongoCollection(String collectionName, Class<TDocument> clazz)
    • handleAfter

      public void handleAfter(Set<String> collections)
    • close

      public void close()