Class MongoDb.Builder<T extends MongoDb>

java.lang.Object
org.sdase.commons.server.mongo.testing.MongoDb.Builder<T>
Direct Known Subclasses:
MongoDbClassExtension.Builder
Enclosing interface:
MongoDb

public abstract static class MongoDb.Builder<T extends MongoDb> extends Object
  • Field Details

    • DEFAULT_VERSION

      public static final de.flapdoodle.embed.mongo.distribution.Version.Main DEFAULT_VERSION
    • WINDOWS_VERSION

      public static final de.flapdoodle.embed.mongo.distribution.Version.Main WINDOWS_VERSION
    • DEFAULT_TIMEOUT_MS

      protected static final long DEFAULT_TIMEOUT_MS
    • mongoDbUrlOverride

      protected String mongoDbUrlOverride
    • version

      protected de.flapdoodle.embed.mongo.distribution.IFeatureAwareVersion version
    • timeoutInMillis

      protected Long timeoutInMillis
    • username

      protected String username
    • password

      protected String password
    • database

      protected String database
    • scripting

      protected boolean scripting
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • withUsername

      public MongoDb.Builder<T> withUsername(String username)
      Configure the username that can be used to connect to the MongoDB instance.
      Parameters:
      username - the username
      Returns:
      a builder instance for further configuration
    • withPassword

      public MongoDb.Builder<T> withPassword(String password)
      Configure the password that can be used to connect to the MongoDB instance.
      Parameters:
      password - the password
      Returns:
      a builder instance for further configuration
    • withDatabase

      public MongoDb.Builder<T> withDatabase(String database)
      Configure the database that can be used to connect to the MongoDB instance.
      Parameters:
      database - the database
      Returns:
      a builder instance for further configuration
    • withVersion

      public MongoDb.Builder<T> withVersion(de.flapdoodle.embed.mongo.distribution.IFeatureAwareVersion version)
      Configure the MongoDB version to start, by default the latest production version is used (DEFAULT_VERSION).
      Parameters:
      version - the version
      Returns:
      a builder instance for further configuration
    • withTimeoutInMillis

      public MongoDb.Builder<T> withTimeoutInMillis(long timeoutInMillis)
      Configures the timeout for database startup, the default value is one minute (DEFAULT_TIMEOUT_MS).
      Parameters:
      timeoutInMillis - the timeout in milliseconds
      Returns:
      a builder instance for further configuration
    • enableScripting

      public MongoDb.Builder<T> enableScripting()
      Allows to enable scripting using JavaScript, which is disabled by default. Avoid this option, as it expose your application to security risks.
      Returns:
      a builder instance for further configuration
    • determineMongoDbVersion

      protected de.flapdoodle.embed.mongo.distribution.IFeatureAwareVersion determineMongoDbVersion()
    • getTimeoutMs

      protected long getTimeoutMs()
    • build

      public abstract T build()