Skip to content

Commit 9098d50

Browse files
committed
DATAMONGO-2055 - Polishing.
Move test to UpdateMapperUnitTests. Original pull request: #600.
1 parent 861c827 commit 9098d50

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
@@ -277,6 +277,20 @@ public void updatePushEachAtPositionWorksCorrectlyWhenGivenPositiveIndexParamete
277277
assertThat(getAsDocument(push, "key")).containsKey("$each");
278278
}
279279

280+
@Test // DATAMONGO-943, DATAMONGO-2055
281+
public void updatePushEachAtNegativePositionWorksCorrectly() {
282+
283+
Update update = new Update().push("key").atPosition(-2).each(Arrays.asList("Arya", "Arry", "Weasel"));
284+
285+
Document mappedObject = mapper.getMappedObject(update.getUpdateObject(), context.getPersistentEntity(Object.class));
286+
287+
Document push = getAsDocument(mappedObject, "$push");
288+
Document key = getAsDocument(push, "key");
289+
290+
assertThat(key.containsKey("$position")).isTrue();
291+
assertThat(key.get("$position")).isEqualTo(-2);
292+
}
293+
280294
@Test // DATAMONGO-943
281295
public void updatePushEachAtPositionWorksCorrectlyWhenGivenPositionFirst() {
282296

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
@@ -390,13 +390,6 @@ public void getUpdateObjectShouldReturnCorrectRepresentationForBitwiseXor() {
390390
.isEqualTo(new Document().append("$bit", new Document("key", new Document("xor", 10L))));
391391
}
392392

393-
@Test // DATAMONGO-943, // DATAMONGO-2055
394-
public void pushShouldAllowNegativePosition() {
395-
396-
assertThat(new Update().push("foo").atPosition(-1).each("booh").toString()).isEqualTo(
397-
"{ \"$push\" : { \"foo\" : { \"$java\" : { \"$position\" : { \"$java\" : { \"$position\" : -1} }, \"$each\" : { \"$java\" : { \"$each\" : [ \"booh\"]} } } } } }");
398-
}
399-
400393
@Test // DATAMONGO-1346
401394
public void registersMultiplePullAllClauses() {
402395

0 commit comments

Comments
 (0)