Search in sources :

Example 6 with AggregationDefinition

use of org.springframework.data.mongodb.core.QueryOperations.AggregationDefinition in project spring-data-mongodb by spring-projects.

the class QueryOperationsUnitTests method createAggregationContextUsesStrictlyTypedContextForTypedAggregationsWhenRequested.

// GH-3542
@Test
void createAggregationContextUsesStrictlyTypedContextForTypedAggregationsWhenRequested() {
    Aggregation aggregation = Aggregation.newAggregation(Person.class, Aggregation.project("name")).withOptions(STRICT_MAPPING);
    AggregationDefinition ctx = queryOperations.createAggregation(aggregation, (Class<?>) null);
    assertThat(ctx.getAggregationOperationContext()).isInstanceOf(TypeBasedAggregationOperationContext.class);
}
Also used : Aggregation(org.springframework.data.mongodb.core.aggregation.Aggregation) AggregationDefinition(org.springframework.data.mongodb.core.QueryOperations.AggregationDefinition) Test(org.junit.jupiter.api.Test)

Example 7 with AggregationDefinition

use of org.springframework.data.mongodb.core.QueryOperations.AggregationDefinition in project spring-data-mongodb by spring-projects.

the class QueryOperationsUnitTests method createAggregationContextUsesRelaxedOneForUntypedAggregationsWhenNoInputTypeProvided.

// GH-3542
@Test
void createAggregationContextUsesRelaxedOneForUntypedAggregationsWhenNoInputTypeProvided() {
    Aggregation aggregation = Aggregation.newAggregation(Aggregation.project("name"));
    AggregationDefinition ctx = queryOperations.createAggregation(aggregation, (Class<?>) null);
    assertThat(ctx.getAggregationOperationContext()).isInstanceOf(RelaxedTypeBasedAggregationOperationContext.class);
}
Also used : Aggregation(org.springframework.data.mongodb.core.aggregation.Aggregation) AggregationDefinition(org.springframework.data.mongodb.core.QueryOperations.AggregationDefinition) Test(org.junit.jupiter.api.Test)

Aggregations

AggregationDefinition (org.springframework.data.mongodb.core.QueryOperations.AggregationDefinition)7 Aggregation (org.springframework.data.mongodb.core.aggregation.Aggregation)6 Test (org.junit.jupiter.api.Test)5 ClientSessionOptions (com.mongodb.ClientSessionOptions)1 MongoException (com.mongodb.MongoException)1 ReadPreference (com.mongodb.ReadPreference)1 WriteConcern (com.mongodb.WriteConcern)1 AggregateIterable (com.mongodb.client.AggregateIterable)1 ClientSession (com.mongodb.client.ClientSession)1 DistinctIterable (com.mongodb.client.DistinctIterable)1 FindIterable (com.mongodb.client.FindIterable)1 MapReduceIterable (com.mongodb.client.MapReduceIterable)1 MongoClient (com.mongodb.client.MongoClient)1 MongoCollection (com.mongodb.client.MongoCollection)1 MongoCursor (com.mongodb.client.MongoCursor)1 MongoDatabase (com.mongodb.client.MongoDatabase)1 MongoIterable (com.mongodb.client.MongoIterable)1 com.mongodb.client.model (com.mongodb.client.model)1 DeleteResult (com.mongodb.client.result.DeleteResult)1 UpdateResult (com.mongodb.client.result.UpdateResult)1