Search in sources :

Example 1 with SingleCollectionMongoDbProperties

use of org.apereo.cas.configuration.model.support.mongo.SingleCollectionMongoDbProperties in project cas by apereo.

the class MongoDbConnectionFactoryTests method verifyPackages.

@Test
public void verifyPackages() {
    val props = new SingleCollectionMongoDbProperties();
    props.setHost("localhost,localhost");
    props.setPort(27017);
    props.setUserId("root");
    props.setPassword("password");
    props.setDatabaseName("audit");
    props.setAuthenticationDatabaseName("admin");
    val factory = new MongoDbConnectionFactory(new StringToWriteConcernConverter()) {

        @Override
        protected Collection<String> getMappingBasePackages() {
            return List.of(SampleDocument.class.getPackageName());
        }
    };
    val template = factory.buildMongoTemplate(props);
    assertNotNull(template);
}
Also used : lombok.val(lombok.val) MongoDbConnectionFactory(org.apereo.cas.mongo.MongoDbConnectionFactory) StringToWriteConcernConverter(org.springframework.data.mongodb.config.StringToWriteConcernConverter) SingleCollectionMongoDbProperties(org.apereo.cas.configuration.model.support.mongo.SingleCollectionMongoDbProperties) Test(org.junit.jupiter.api.Test)

Example 2 with SingleCollectionMongoDbProperties

use of org.apereo.cas.configuration.model.support.mongo.SingleCollectionMongoDbProperties in project cas by apereo.

the class MongoDbConnectionFactoryTests method verifyClient.

@Test
public void verifyClient() {
    val props = new SingleCollectionMongoDbProperties();
    props.setClientUri(URI);
    val factory = new MongoDbConnectionFactory();
    val client = factory.buildMongoDbClient(props);
    assertNotNull(client);
}
Also used : lombok.val(lombok.val) MongoDbConnectionFactory(org.apereo.cas.mongo.MongoDbConnectionFactory) SingleCollectionMongoDbProperties(org.apereo.cas.configuration.model.support.mongo.SingleCollectionMongoDbProperties) Test(org.junit.jupiter.api.Test)

Example 3 with SingleCollectionMongoDbProperties

use of org.apereo.cas.configuration.model.support.mongo.SingleCollectionMongoDbProperties in project cas by apereo.

the class MongoDbConnectionFactoryTests method verifyProps.

@Test
public void verifyProps() {
    val factory = new MongoDbConnectionFactory();
    val props = new SingleCollectionMongoDbProperties();
    props.setClientUri(URI);
    val template = factory.buildMongoTemplate(props);
    assertNotNull(template);
    factory.createCollection(template, getClass().getSimpleName(), true);
}
Also used : lombok.val(lombok.val) MongoDbConnectionFactory(org.apereo.cas.mongo.MongoDbConnectionFactory) SingleCollectionMongoDbProperties(org.apereo.cas.configuration.model.support.mongo.SingleCollectionMongoDbProperties) Test(org.junit.jupiter.api.Test)

Aggregations

lombok.val (lombok.val)3 SingleCollectionMongoDbProperties (org.apereo.cas.configuration.model.support.mongo.SingleCollectionMongoDbProperties)3 MongoDbConnectionFactory (org.apereo.cas.mongo.MongoDbConnectionFactory)3 Test (org.junit.jupiter.api.Test)3 StringToWriteConcernConverter (org.springframework.data.mongodb.config.StringToWriteConcernConverter)1