Search in sources :

Example 6 with PersonPojoStringId

use of org.springframework.data.mongodb.core.mapping.PersonPojoStringId in project spring-data-mongodb by spring-projects.

the class ApplicationContextEventTests method publishesAfterConvertEventForFindQueriesUsingProjections.

// DATAMONGO-1823
@Test
public void publishesAfterConvertEventForFindQueriesUsingProjections() {
    PersonPojoStringId entity = new PersonPojoStringId("1", "Text");
    template.insert(entity);
    template.query(PersonPojoStringId.class).matching(query(where("id").is(entity.getId()))).all();
    assertThat(listener.onAfterLoadEvents).hasSize(1);
    assertThat(listener.onAfterLoadEvents.get(0).getCollectionName()).isEqualTo(COLLECTION_NAME);
    assertThat(listener.onBeforeConvertEvents).hasSize(1);
    assertThat(listener.onBeforeConvertEvents.get(0).getCollectionName()).isEqualTo(COLLECTION_NAME);
    assertThat(listener.onAfterConvertEvents).hasSize(1);
    assertThat(listener.onAfterConvertEvents.get(0).getCollectionName()).isEqualTo(COLLECTION_NAME);
}
Also used : PersonPojoStringId(org.springframework.data.mongodb.core.mapping.PersonPojoStringId) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)6 PersonPojoStringId (org.springframework.data.mongodb.core.mapping.PersonPojoStringId)6 ObjectId (org.bson.types.ObjectId)1 Document (org.springframework.data.mongodb.core.mapping.Document)1