Search in sources :

Example 1 with StringToWriteConcernConverter

use of org.springframework.data.mongodb.config.StringToWriteConcernConverter 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)

Aggregations

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