From a120ce2bb1401c4839e39a4ba7843489878e4e4f Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Thu, 10 Oct 2013 13:23:38 +0200 Subject: [PATCH] DATAMONGO-776 - Improvement in TypeBasedAggregationOperationContext. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TypeBasedAggregationOperationContext's getReference(…) doesn't use a PropertyPath anymore to avoid running the camel case property resolution. --- .../aggregation/TypeBasedAggregationOperationContext.java | 5 ++--- .../TypeBasedAggregationOperationContextUnitTests.java | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/TypeBasedAggregationOperationContext.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/TypeBasedAggregationOperationContext.java index 7441b8958..1ed1e9ff4 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/TypeBasedAggregationOperationContext.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/TypeBasedAggregationOperationContext.java @@ -88,11 +88,10 @@ public class TypeBasedAggregationOperationContext implements AggregationOperatio */ @Override public FieldReference getReference(String name) { - PropertyPath path = PropertyPath.from(name, type); - PersistentPropertyPath propertyPath = mappingContext.getPersistentPropertyPath(path); + PersistentPropertyPath propertyPath = mappingContext.getPersistentPropertyPath(name, type); - return getReferenceFor(field(path.getLeafProperty().getSegment(), + return getReferenceFor(field(propertyPath.getLeafProperty().getName(), propertyPath.toDotPath(MongoPersistentProperty.PropertyToFieldNameConverter.INSTANCE))); } diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/TypeBasedAggregationOperationContextUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/TypeBasedAggregationOperationContextUnitTests.java index 6da5fdd68..68c69793b 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/TypeBasedAggregationOperationContextUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/TypeBasedAggregationOperationContextUnitTests.java @@ -23,7 +23,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; -import org.springframework.data.mapping.PropertyReferenceException; +import org.springframework.data.mapping.model.MappingException; import org.springframework.data.mongodb.MongoDbFactory; import org.springframework.data.mongodb.core.convert.MappingMongoConverter; import org.springframework.data.mongodb.core.convert.QueryMapper; @@ -56,7 +56,7 @@ public class TypeBasedAggregationOperationContextUnitTests { assertThat(getContext(Foo.class).getReference("bar"), is(notNullValue())); } - @Test(expected = PropertyReferenceException.class) + @Test(expected = MappingException.class) public void rejectsInvalidFieldReference() { getContext(Foo.class).getReference("foo"); }