Skip to content

Commit 3981a8a

Browse files
committed
DATAMONGO-2055 - Polishing.
Move test to UpdateMapperUnitTests. Original pull request: #600.
1 parent b9d7206 commit 3981a8a

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/UpdateMapperUnitTests.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,20 @@ public void updatePushEachAtPositionWorksCorrectlyWhenGivenPositiveIndexParamete
289289
assertThat(getAsDBObject(push, "key").containsField("$each"), is(true));
290290
}
291291

292+
@Test // DATAMONGO-943, DATAMONGO-2055
293+
public void updatePushEachAtNegativePositionWorksCorrectly() {
294+
295+
Update update = new Update().push("key").atPosition(-2).each(Arrays.asList("Arya", "Arry", "Weasel"));
296+
297+
DBObject mappedObject = mapper.getMappedObject(update.getUpdateObject(), context.getPersistentEntity(Object.class));
298+
299+
DBObject push = getAsDBObject(mappedObject, "$push");
300+
DBObject key = getAsDBObject(push, "key");
301+
302+
assertThat(key.containsField("$position"), is(true));
303+
assertThat((Integer) key.get("$position"), is(-2));
304+
}
305+
292306
@Test // DATAMONGO-943
293307
public void updatePushEachAtPositionWorksCorrectlyWhenGivenPositionFirst() {
294308

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/query/UpdateTests.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -399,13 +399,6 @@ public void getUpdateObjectShouldReturnCorrectRepresentationForBitwiseXor() {
399399
equalTo(new BasicDBObjectBuilder().add("$bit", new BasicDBObject("key", new BasicDBObject("xor", 10L))).get()));
400400
}
401401

402-
@Test // DATAMONGO-943, // DATAMONGO-2055
403-
public void pushShouldAllowNegativePosition() {
404-
405-
assertThat(new Update().push("foo").atPosition(-1).each("booh").toString()).isEqualTo(
406-
"{ \"$push\" : { \"foo\" : { \"$java\" : { \"$position\" : { \"$java\" : { \"$position\" : -1} }, \"$each\" : { \"$java\" : { \"$each\" : [ \"booh\"]} } } } } }");
407-
}
408-
409402
@Test // DATAMONGO-1346
410403
public void registersMultiplePullAllClauses() {
411404

0 commit comments

Comments
 (0)