DATAREST-885 - Polishing.
Formatting. Copyright ranges.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2014-2016 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.
|
||||
@@ -165,7 +165,9 @@ public abstract class PatchOperation {
|
||||
* otherwise.
|
||||
*/
|
||||
protected <T> Object evaluateValueFromTarget(Object targetObject, Class<T> entityType) {
|
||||
return value instanceof LateObjectEvaluator ? ((LateObjectEvaluator) value).evaluate(spelExpression.getValueType(targetObject)) : value;
|
||||
|
||||
return value instanceof LateObjectEvaluator
|
||||
? ((LateObjectEvaluator) value).evaluate(spelExpression.getValueType(targetObject)) : value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,9 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.rest.webmvc.json.patch;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -35,27 +33,13 @@ public class ReplaceOperationTest {
|
||||
todos.add(new Todo(1L, "A", false));
|
||||
todos.add(new Todo(2L, "B", false));
|
||||
todos.add(new Todo(3L, "C", false));
|
||||
|
||||
|
||||
ReplaceOperation replace = new ReplaceOperation("/1/complete", true);
|
||||
replace.perform(todos, Todo.class);
|
||||
|
||||
|
||||
assertTrue(todos.get(1).isComplete());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void replaceObjectPropertyValue() throws Exception {
|
||||
// initial Todo list
|
||||
Todo todo = new Todo(1L, "A", false);
|
||||
|
||||
ReplaceOperation replace = new ReplaceOperation("/type", new JsonLateObjectEvaluator(new ObjectMapper().readTree("{\"value\":\"new\"}")));
|
||||
replace.perform(todo, Todo.class);
|
||||
|
||||
assertNotNull(todo.getType());
|
||||
assertNotNull(todo.getType().getValue());
|
||||
assertTrue(todo.getType().getValue().equals("new"));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void replaceTextPropertyValue() throws Exception {
|
||||
// initial Todo list
|
||||
@@ -63,7 +47,7 @@ public class ReplaceOperationTest {
|
||||
todos.add(new Todo(1L, "A", false));
|
||||
todos.add(new Todo(2L, "B", false));
|
||||
todos.add(new Todo(3L, "C", false));
|
||||
|
||||
|
||||
ReplaceOperation replace = new ReplaceOperation("/1/description", "BBB");
|
||||
replace.perform(todos, Todo.class);
|
||||
|
||||
@@ -77,11 +61,27 @@ public class ReplaceOperationTest {
|
||||
todos.add(new Todo(1L, "A", false));
|
||||
todos.add(new Todo(2L, "B", false));
|
||||
todos.add(new Todo(3L, "C", false));
|
||||
|
||||
|
||||
ReplaceOperation replace = new ReplaceOperation("/1/description", 22);
|
||||
replace.perform(todos, Todo.class);
|
||||
|
||||
assertEquals("22", todos.get(1).getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-885
|
||||
*/
|
||||
@Test
|
||||
public void replaceObjectPropertyValue() throws Exception {
|
||||
|
||||
Todo todo = new Todo(1L, "A", false);
|
||||
|
||||
ReplaceOperation replace = new ReplaceOperation("/type",
|
||||
new JsonLateObjectEvaluator(new ObjectMapper().readTree("{ \"value\" : \"new\" }")));
|
||||
replace.perform(todo, Todo.class);
|
||||
|
||||
assertNotNull(todo.getType());
|
||||
assertNotNull(todo.getType().getValue());
|
||||
assertTrue(todo.getType().getValue().equals("new"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2014-2016 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.
|
||||
@@ -23,6 +23,7 @@ import lombok.NoArgsConstructor;
|
||||
* @author Roy Clarkson
|
||||
* @author Craig Walls
|
||||
* @author Mathias Düsterhöft
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@@ -34,6 +35,7 @@ class Todo {
|
||||
private TodoType type = new TodoType();
|
||||
|
||||
public Todo(Long id, String description, boolean complete) {
|
||||
|
||||
this.id = id;
|
||||
this.description = description;
|
||||
this.complete = complete;
|
||||
|
||||
@@ -1,18 +1,31 @@
|
||||
/*
|
||||
* Copyright 2016 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.rest.webmvc.json.patch;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author Mathias Düsterhöft
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@Embeddable
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TodoType {
|
||||
private String value = "none";
|
||||
private String value = "none";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user