DATAMONGO-2055 - Polishing.

Move test to UpdateMapperUnitTests.

Original pull request: #600.
This commit is contained in:
Mark Paluch
2018-08-15 15:53:23 +02:00
parent b9d72060af
commit 3981a8ac92
2 changed files with 14 additions and 7 deletions

View File

@@ -289,6 +289,20 @@ public class UpdateMapperUnitTests {
assertThat(getAsDBObject(push, "key").containsField("$each"), is(true));
}
@Test // DATAMONGO-943, DATAMONGO-2055
public void updatePushEachAtNegativePositionWorksCorrectly() {
Update update = new Update().push("key").atPosition(-2).each(Arrays.asList("Arya", "Arry", "Weasel"));
DBObject mappedObject = mapper.getMappedObject(update.getUpdateObject(), context.getPersistentEntity(Object.class));
DBObject push = getAsDBObject(mappedObject, "$push");
DBObject key = getAsDBObject(push, "key");
assertThat(key.containsField("$position"), is(true));
assertThat((Integer) key.get("$position"), is(-2));
}
@Test // DATAMONGO-943
public void updatePushEachAtPositionWorksCorrectlyWhenGivenPositionFirst() {

View File

@@ -399,13 +399,6 @@ public class UpdateTests {
equalTo(new BasicDBObjectBuilder().add("$bit", new BasicDBObject("key", new BasicDBObject("xor", 10L))).get()));
}
@Test // DATAMONGO-943, // DATAMONGO-2055
public void pushShouldAllowNegativePosition() {
assertThat(new Update().push("foo").atPosition(-1).each("booh").toString()).isEqualTo(
"{ \"$push\" : { \"foo\" : { \"$java\" : { \"$position\" : { \"$java\" : { \"$position\" : -1} }, \"$each\" : { \"$java\" : { \"$each\" : [ \"booh\"]} } } } } }");
}
@Test // DATAMONGO-1346
public void registersMultiplePullAllClauses() {