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 java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
database
protected static long
DEFAULT_TIMEOUT_MS
static de.flapdoodle.embed.mongo.distribution.Version.Main
DEFAULT_VERSION
protected java.lang.String
mongoDbUrlOverride
protected java.lang.String
password
protected boolean
scripting
protected java.lang.Long
timeoutInMillis
protected java.lang.String
username
protected de.flapdoodle.embed.mongo.distribution.IFeatureAwareVersion
version
static de.flapdoodle.embed.mongo.distribution.Version.Main
WINDOWS_VERSION
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract T
build()
protected de.flapdoodle.embed.mongo.distribution.IFeatureAwareVersion
determineMongoDbVersion()
MongoDb.Builder<T>
enableScripting()
Allows to enable scripting using JavaScript, which is disabled by default.protected long
getTimeoutMs()
MongoDb.Builder<T>
withDatabase(java.lang.String database)
Configure the database that can be used to connect to the MongoDB instance.MongoDb.Builder<T>
withPassword(java.lang.String password)
Configure the password that can be used to connect to the MongoDB instance.MongoDb.Builder<T>
withTimeoutInMillis(long timeoutInMillis)
Configures the timeout for database startup, the default value is one minute (DEFAULT_TIMEOUT_MS
).MongoDb.Builder<T>
withUsername(java.lang.String username)
Configure the username that can be used to connect to the MongoDB instance.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
).
-
-
-
Field Detail
-
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 java.lang.String mongoDbUrlOverride
-
version
protected de.flapdoodle.embed.mongo.distribution.IFeatureAwareVersion version
-
timeoutInMillis
protected java.lang.Long timeoutInMillis
-
username
protected java.lang.String username
-
password
protected java.lang.String password
-
database
protected java.lang.String database
-
scripting
protected boolean scripting
-
-
Method Detail
-
withUsername
public MongoDb.Builder<T> withUsername(java.lang.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(java.lang.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(java.lang.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()
-
-