### Question:
AddOperation extends PatchOperation { @Override <T> void perform(Object targetObject, Class<T> type) { addValue(targetObject, evaluateValueFromTarget(targetObject, type)); } AddOperation(String path, Object value);   }### Answer:
@Test public void addBooleanPropertyValue() throws Exception { List<Todo> todos = new ArrayList<Todo>(); todos.add(new Todo(1L, "A", false)); todos.add(new Todo(2L, "B", false)); todos.add(new Todo(3L, "C", false)); AddOperation add = new AddOperation("/1/complete", true); add.perform(todos, Todo.class); assertTrue(todos.get(1).isComplete()); }
@Test public void addStringPropertyValue() throws Exception { List<Todo> todos = new ArrayList<Todo>(); todos.add(new Todo(1L, "A", false)); todos.add(new Todo(2L, "B", false)); todos.add(new Todo(3L, "C", false)); AddOperation add = new AddOperation("/1/description", "BBB"); add.perform(todos, Todo.class); assertEquals("BBB", todos.get(1).getDescription()); }
@Test public void addItemToList() throws Exception { List<Todo> todos = new ArrayList<Todo>(); todos.add(new Todo(1L, "A", false)); todos.add(new Todo(2L, "B", false)); todos.add(new Todo(3L, "C", false)); AddOperation add = new AddOperation("/1", new Todo(null, "D", true)); add.perform(todos, Todo.class); assertEquals(4, todos.size()); assertEquals("A", todos.get(0).getDescription()); assertFalse(todos.get(0).isComplete()); assertEquals("D", todos.get(1).getDescription()); assertTrue(todos.get(1).isComplete()); assertEquals("B", todos.get(2).getDescription()); assertFalse(todos.get(2).isComplete()); assertEquals("C", todos.get(3).getDescription()); assertFalse(todos.get(3).isComplete()); }