Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit ffe4c33
Author: Justin Lee <[email protected]>
Date:   Fri Jan 13 10:15:23 2017 -0500

    rearrange the tests a bit

commit 97dcaf1
Author: Daniel Breitlauch <[email protected]>
Date:   Wed Jan 11 16:02:07 2017 +0100

    always translate according to annotation + unit test to verify

fixes MorphiaOrg#1124
fixes MorphiaOrg#1123
  • Loading branch information
Justin Lee committed Jan 13, 2017
1 parent 957a1c7 commit f571dad
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,9 @@ private void resolve() {
field = resolveField(segment);

if (field != null) {
if (!field.isMap()) {
translate(field.getNameToStore());
} else {
if (hasNext()) {
next(); // consume the map key segment
}
translate(field.getNameToStore());
if (field.isMap() && hasNext()) {
next(); // consume the map key segment
}
} else {
if (validateNames) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.mongodb.morphia.annotations.Embedded;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;
import org.mongodb.morphia.annotations.Property;
import org.mongodb.morphia.query.Query;
import org.mongodb.morphia.query.UpdateOperations;

Expand Down Expand Up @@ -169,6 +170,7 @@ public String toString() {
public static class Grade {
private int marks;

@Property("d")
private Map<String, String> data;

public Grade() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,13 @@ public void maps() {
MappedClass mappedClass = mapper.getMappedClass(Student.class);

PathTarget pathTarget = new PathTarget(mapper, mappedClass, "grades.$.data.name");
Assert.assertEquals("grades.$.data.name", pathTarget.translatedPath());
Assert.assertEquals("grades.$.d.name", pathTarget.translatedPath());
Assert.assertEquals(mapper.getMappedClass(Grade.class).getMappedFieldByJavaField("data"), pathTarget.getTarget());

pathTarget = new PathTarget(mapper, mappedClass, "grades.$.d.name");
Assert.assertEquals("grades.$.d.name", pathTarget.translatedPath());
Assert.assertEquals(mapper.getMappedClass(Grade.class).getMappedField("d"), pathTarget.getTarget());

pathTarget = new PathTarget(mapper, mapper.getMappedClass(Article.class), "translations");
Assert.assertEquals("translations", pathTarget.translatedPath());
}
Expand Down

0 comments on commit f571dad

Please sign in to comment.