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:
@@ -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."));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user