Search in sources :

Example 1 with MongoDbConfigProperties

use of org.eclipse.hono.deviceregistry.mongodb.config.MongoDbConfigProperties in project hono by eclipse.

the class MongoDbTestUtils method getCredentialsDao.

/**
 * Creates a new Credentials DAO.
 *
 * @param vertx The vert.x instance to run on.
 * @param dbName The name of the database to connect to.
 * @return The DAO.
 * @throws NullPointerException if any of the parameters are {@code null}.
 */
public static MongoDbBasedCredentialsDao getCredentialsDao(final Vertx vertx, final String dbName) {
    final JsonObject mongoDbConfig = new MongoDbConfigProperties().setConnectionString(MONGO_DB_CONTAINER.getReplicaSetUrl(dbName)).getMongoClientConfig();
    LOG.info("creating Mongo DB client for credentials DAO using config:{}{}]", System.lineSeparator(), mongoDbConfig.encodePrettily());
    return new MongoDbBasedCredentialsDao(getMongoClient(vertx, mongoDbConfig), "credentials", null, null);
}
Also used : MongoDbConfigProperties(org.eclipse.hono.deviceregistry.mongodb.config.MongoDbConfigProperties) JsonObject(io.vertx.core.json.JsonObject) MongoDbBasedCredentialsDao(org.eclipse.hono.deviceregistry.mongodb.model.MongoDbBasedCredentialsDao)

Example 2 with MongoDbConfigProperties

use of org.eclipse.hono.deviceregistry.mongodb.config.MongoDbConfigProperties in project hono by eclipse.

the class MongoDbTestUtils method getMongoClient.

/**
 * Creates a new vert.x Mongo DB client.
 *
 * @param vertx The vert.x instance to run on.
 * @param dbName The name of the database to connect to.
 * @return The client.
 * @throws NullPointerException if any of the parameters are {@code null}.
 */
public static MongoClient getMongoClient(final Vertx vertx, final String dbName) {
    Objects.requireNonNull(vertx);
    Objects.requireNonNull(dbName);
    final JsonObject mongoDbConfig = new MongoDbConfigProperties().setConnectionString(MONGO_DB_CONTAINER.getReplicaSetUrl(dbName)).getMongoClientConfig();
    return getMongoClient(vertx, mongoDbConfig);
}
Also used : MongoDbConfigProperties(org.eclipse.hono.deviceregistry.mongodb.config.MongoDbConfigProperties) JsonObject(io.vertx.core.json.JsonObject)

Example 3 with MongoDbConfigProperties

use of org.eclipse.hono.deviceregistry.mongodb.config.MongoDbConfigProperties in project hono by eclipse.

the class MongoDbTestUtils method getTenantDao.

/**
 * Creates a new Tenant DAO.
 *
 * @param vertx The vert.x instance to run on.
 * @param dbName The name of the database to connect to.
 * @return The DAO.
 * @throws NullPointerException if any of the parameters are {@code null}.
 */
public static MongoDbBasedTenantDao getTenantDao(final Vertx vertx, final String dbName) {
    final JsonObject mongoDbConfig = new MongoDbConfigProperties().setConnectionString(MONGO_DB_CONTAINER.getReplicaSetUrl(dbName)).getMongoClientConfig();
    LOG.info("creating Mongo DB client for tenant DAO using config:{}{}]", System.lineSeparator(), mongoDbConfig.encodePrettily());
    return new MongoDbBasedTenantDao(getMongoClient(vertx, mongoDbConfig), "tenants", null);
}
Also used : MongoDbConfigProperties(org.eclipse.hono.deviceregistry.mongodb.config.MongoDbConfigProperties) JsonObject(io.vertx.core.json.JsonObject) MongoDbBasedTenantDao(org.eclipse.hono.deviceregistry.mongodb.model.MongoDbBasedTenantDao)

Example 4 with MongoDbConfigProperties

use of org.eclipse.hono.deviceregistry.mongodb.config.MongoDbConfigProperties in project hono by eclipse.

the class MongoDbTestUtils method getDeviceDao.

/**
 * Creates a new Device DAO.
 *
 * @param vertx The vert.x instance to run on.
 * @param dbName The name of the database to connect to.
 * @return The DAO.
 * @throws NullPointerException if any of the parameters are {@code null}.
 */
public static MongoDbBasedDeviceDao getDeviceDao(final Vertx vertx, final String dbName) {
    final JsonObject mongoDbConfig = new MongoDbConfigProperties().setConnectionString(MONGO_DB_CONTAINER.getReplicaSetUrl(dbName)).getMongoClientConfig();
    LOG.info("creating Mongo DB client for device DAO using config:{}{}]", System.lineSeparator(), mongoDbConfig.encodePrettily());
    return new MongoDbBasedDeviceDao(getMongoClient(vertx, mongoDbConfig), "devices", null);
}
Also used : MongoDbConfigProperties(org.eclipse.hono.deviceregistry.mongodb.config.MongoDbConfigProperties) MongoDbBasedDeviceDao(org.eclipse.hono.deviceregistry.mongodb.model.MongoDbBasedDeviceDao) JsonObject(io.vertx.core.json.JsonObject)

Aggregations

JsonObject (io.vertx.core.json.JsonObject)4 MongoDbConfigProperties (org.eclipse.hono.deviceregistry.mongodb.config.MongoDbConfigProperties)4 MongoDbBasedCredentialsDao (org.eclipse.hono.deviceregistry.mongodb.model.MongoDbBasedCredentialsDao)1 MongoDbBasedDeviceDao (org.eclipse.hono.deviceregistry.mongodb.model.MongoDbBasedDeviceDao)1 MongoDbBasedTenantDao (org.eclipse.hono.deviceregistry.mongodb.model.MongoDbBasedTenantDao)1