Package org.mongojack

Class MongoDBTestBase

    • Field Detail

      • mongo

        protected com.mongodb.client.MongoClient mongo
      • db

        protected com.mongodb.client.MongoDatabase db
      • uuidRepresentation

        protected org.bson.UuidRepresentation uuidRepresentation
    • Constructor Detail

      • MongoDBTestBase

        public MongoDBTestBase()
    • Method Detail

      • startDb

        @BeforeAll
        public static void startDb()
      • connectToDb

        @BeforeEach
        public void connectToDb()
      • disconnectFromDb

        @AfterEach
        public void disconnectFromDb()
      • getMongoCollection

        protected <T> com.mongodb.client.MongoCollection<T> getMongoCollection​(String name,
                                                                               Class<T> documentClass)
        Get a collection with the given name, and store it, so that it will be dropped in clean up
        Parameters:
        name - The name of the collection
        Returns:
        The collection
      • getMongoCollection

        protected <T> com.mongodb.client.MongoCollection<T> getMongoCollection​(Class<T> documentClass)
        Get a collection with a random name. Should grant some degree of isolation from tests running in parallel.
        Returns:
        The collection
      • configure

        protected <T> org.mongojack.JacksonMongoCollection<T> configure​(org.mongojack.JacksonMongoCollection<T> collection)
      • getCollection

        protected <T> org.mongojack.JacksonMongoCollection<T> getCollection​(Class<T> type)
      • getCollection

        protected <T> org.mongojack.JacksonMongoCollection<T> getCollection​(Class<T> type,
                                                                            org.mongojack.JacksonMongoCollection.JacksonMongoCollectionBuilder builder)
      • getCollectionWithView

        protected <T> org.mongojack.JacksonMongoCollection<T> getCollectionWithView​(Class<T> type,
                                                                                    Class<?> view)
      • getCollection

        protected <T> org.mongojack.JacksonMongoCollection<T> getCollection​(Class<T> type,
                                                                            String collectionName)
      • getCollection

        protected <T> org.mongojack.JacksonMongoCollection<T> getCollection​(Class<T> type,
                                                                            com.fasterxml.jackson.databind.ObjectMapper mapper)
      • getUnderlyingCollection

        protected com.mongodb.client.MongoCollection<org.bson.Document> getUnderlyingCollection​(org.mongojack.JacksonMongoCollection<?> coll)