DATAREST-995 - Fixed detection of collection append operations for JSON Patch requests.

We previously erroneously looked for a ~ in a JSON Pointer to indicate collection append in e.g. an add operation. We now also support the actually correct - keeping the original behavior for now to not break clients that currently make use of it.
This commit is contained in:
Oliver Gierke
2017-02-08 17:48:34 +01:00
parent ea482e0577
commit 4e2edd2d37
3 changed files with 19 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 the original author or authors.
* Copyright 2014-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
*/
package org.springframework.data.rest.webmvc.json.patch;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import java.util.ArrayList;
@@ -73,4 +74,14 @@ public class AddOperationTests {
assertEquals("C", todos.get(3).getDescription());
assertFalse(todos.get(3).isComplete());
}
@Test // DATAREST-995
public void addsItemsToNestedList() {
Todo todo = new Todo(1L, "description", false);
new AddOperation("/items/-", "Some text.").perform(todo, Todo.class);
assertThat(todo.getItems().get(0), is("Some text."));
}
}