Package fr.gouv.vitam.common.mongo
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 Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddCollectionToBePurged
(String collectionName) protected void
after()
void
close()
static String
static int
com.mongodb.client.MongoClient
com.mongodb.client.MongoCollection<org.bson.Document>
getMongoCollection
(String collectionName) <TDocument>
com.mongodb.client.MongoCollection<TDocument>getMongoCollection
(String collectionName, Class<TDocument> clazz) com.mongodb.client.MongoDatabase
void
void
handleAfter
(Set<String> collections) void
Used when annotated @ClassRuleMethods inherited from class org.junit.rules.ExternalResource
apply, before
-
Field Details
-
VITAM_DB
- See Also:
-
MONGO_HOST
- See Also:
-
VITAM_SEQUENCE
- See Also:
-
COUNTER
- See Also:
-
ID
- See Also:
-
-
Constructor Details
-
MongoRule
public MongoRule(com.mongodb.MongoClientSettings.Builder mongoClientSettingsBuilder, String... collectionsToBePurged) -
MongoRule
-
-
Method Details
-
getDatabaseName
-
after
protected void after()- Overrides:
after
in classorg.junit.rules.ExternalResource
-
addCollectionToBePurged
-
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
-
handleAfter
-
close
public void close()
-