Search in sources :

Example 1 with MongoConverter

use of org.springframework.data.mongodb.core.convert.MongoConverter in project spring-data-mongodb by spring-projects.

the class PartTreeMongoQueryUnitTests method setUp.

@Before
public void setUp() {
    mappingContext = new MongoMappingContext();
    DbRefResolver dbRefResolver = new DefaultDbRefResolver(mock(MongoDbFactory.class));
    MongoConverter converter = new MappingMongoConverter(dbRefResolver, mappingContext);
    doReturn(converter).when(mongoOperationsMock).getConverter();
    doReturn(findOperationMock).when(mongoOperationsMock).query(any());
}
Also used : MongoDbFactory(org.springframework.data.mongodb.MongoDbFactory) MongoMappingContext(org.springframework.data.mongodb.core.mapping.MongoMappingContext) DefaultDbRefResolver(org.springframework.data.mongodb.core.convert.DefaultDbRefResolver) MappingMongoConverter(org.springframework.data.mongodb.core.convert.MappingMongoConverter) DbRefResolver(org.springframework.data.mongodb.core.convert.DbRefResolver) DefaultDbRefResolver(org.springframework.data.mongodb.core.convert.DefaultDbRefResolver) MongoConverter(org.springframework.data.mongodb.core.convert.MongoConverter) MappingMongoConverter(org.springframework.data.mongodb.core.convert.MappingMongoConverter) Before(org.junit.Before)

Example 2 with MongoConverter

use of org.springframework.data.mongodb.core.convert.MongoConverter in project spring-data-mongodb by spring-projects.

the class MongoNamespaceTests method testThirdGridFsTemplateFactory.

// DATAMONGO-823
@Test
public void testThirdGridFsTemplateFactory() {
    assertTrue(ctx.containsBean("thirdGridFsTemplate"));
    GridFsOperations operations = (GridFsOperations) ctx.getBean("thirdGridFsTemplate");
    MongoDbFactory dbf = (MongoDbFactory) getField(operations, "dbFactory");
    assertEquals("database", getField(dbf, "databaseName"));
    assertEquals("bucketString", getField(operations, "bucket"));
    MongoConverter converter = (MongoConverter) getField(operations, "converter");
    assertNotNull(converter);
}
Also used : MongoDbFactory(org.springframework.data.mongodb.MongoDbFactory) MongoConverter(org.springframework.data.mongodb.core.convert.MongoConverter) GridFsOperations(org.springframework.data.mongodb.gridfs.GridFsOperations) Test(org.junit.Test)

Example 3 with MongoConverter

use of org.springframework.data.mongodb.core.convert.MongoConverter in project spring-data-mongodb by spring-projects.

the class MongoNamespaceTests method testSecondGridFsTemplateFactory.

// DATAMONGO-628
@Test
public void testSecondGridFsTemplateFactory() {
    assertTrue(ctx.containsBean("secondGridFsTemplate"));
    GridFsOperations operations = (GridFsOperations) ctx.getBean("secondGridFsTemplate");
    MongoDbFactory dbf = (MongoDbFactory) getField(operations, "dbFactory");
    assertEquals("database", getField(dbf, "databaseName"));
    assertEquals(null, getField(operations, "bucket"));
    MongoConverter converter = (MongoConverter) getField(operations, "converter");
    assertNotNull(converter);
}
Also used : MongoDbFactory(org.springframework.data.mongodb.MongoDbFactory) MongoConverter(org.springframework.data.mongodb.core.convert.MongoConverter) GridFsOperations(org.springframework.data.mongodb.gridfs.GridFsOperations) Test(org.junit.Test)

Example 4 with MongoConverter

use of org.springframework.data.mongodb.core.convert.MongoConverter in project spring-data-mongodb by spring-projects.

the class MongoNamespaceTests method testMongoTemplateFactory.

// DATAMONGO-140
@Test
public void testMongoTemplateFactory() {
    assertTrue(ctx.containsBean("mongoTemplate"));
    MongoOperations operations = (MongoOperations) ctx.getBean("mongoTemplate");
    MongoDbFactory dbf = (MongoDbFactory) getField(operations, "mongoDbFactory");
    assertEquals("database", getField(dbf, "databaseName"));
    MongoConverter converter = (MongoConverter) getField(operations, "mongoConverter");
    assertNotNull(converter);
}
Also used : MongoDbFactory(org.springframework.data.mongodb.MongoDbFactory) MongoOperations(org.springframework.data.mongodb.core.MongoOperations) MongoConverter(org.springframework.data.mongodb.core.convert.MongoConverter) Test(org.junit.Test)

Example 5 with MongoConverter

use of org.springframework.data.mongodb.core.convert.MongoConverter in project spring-data-mongodb by spring-projects.

the class MongoNamespaceTests method testGridFsTemplateFactory.

// DATAMONGO-628
@Test
public void testGridFsTemplateFactory() {
    assertTrue(ctx.containsBean("gridFsTemplate"));
    GridFsOperations operations = (GridFsOperations) ctx.getBean("gridFsTemplate");
    MongoDbFactory dbf = (MongoDbFactory) getField(operations, "dbFactory");
    assertEquals("database", getField(dbf, "databaseName"));
    MongoConverter converter = (MongoConverter) getField(operations, "converter");
    assertNotNull(converter);
}
Also used : MongoDbFactory(org.springframework.data.mongodb.MongoDbFactory) MongoConverter(org.springframework.data.mongodb.core.convert.MongoConverter) GridFsOperations(org.springframework.data.mongodb.gridfs.GridFsOperations) Test(org.junit.Test)

Aggregations

MongoDbFactory (org.springframework.data.mongodb.MongoDbFactory)5 MongoConverter (org.springframework.data.mongodb.core.convert.MongoConverter)5 Test (org.junit.Test)4 GridFsOperations (org.springframework.data.mongodb.gridfs.GridFsOperations)3 Before (org.junit.Before)1 MongoOperations (org.springframework.data.mongodb.core.MongoOperations)1 DbRefResolver (org.springframework.data.mongodb.core.convert.DbRefResolver)1 DefaultDbRefResolver (org.springframework.data.mongodb.core.convert.DefaultDbRefResolver)1 MappingMongoConverter (org.springframework.data.mongodb.core.convert.MappingMongoConverter)1 MongoMappingContext (org.springframework.data.mongodb.core.mapping.MongoMappingContext)1