From 8ad81978b0401fdb6ce1ec9c9757c1ee05b74db6 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Wed, 8 Feb 2017 19:58:47 +0100 Subject: [PATCH] DATAREST-995 - Removed support for ~ to reference a last collection element in JSON Patch. Completely removed the support for ~ in favor of the previously introduced support for the correct indicator -. --- .../data/rest/webmvc/json/patch/PathToSpEL.java | 2 +- .../rest/webmvc/json/patch/CopyOperationTests.java | 10 +++++----- .../rest/webmvc/json/patch/MoveOperationTests.java | 10 +++++----- .../data/rest/webmvc/json/patch/PathToSpelTests.java | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/patch/PathToSpEL.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/patch/PathToSpEL.java index 2a231cda3..d688a4b03 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/patch/PathToSpEL.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/patch/PathToSpEL.java @@ -31,7 +31,7 @@ import org.springframework.expression.spel.standard.SpelExpressionParser; public class PathToSpEL { private static final SpelExpressionParser SPEL_EXPRESSION_PARSER = new SpelExpressionParser(); - static final List APPEND_CHARACTERS = Arrays.asList("-", "~"); + static final List APPEND_CHARACTERS = Arrays.asList("-"); /** * Converts a patch path to an {@link Expression}. diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/patch/CopyOperationTests.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/patch/CopyOperationTests.java index c0785876c..61a01b4be 100644 --- a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/patch/CopyOperationTests.java +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/patch/CopyOperationTests.java @@ -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. @@ -121,14 +121,14 @@ public class CopyOperationTests { } @Test - public void copyListElementToEndOfList_usingTilde() throws Exception { + public void copyListElementToEndOfList_usingDash() throws Exception { List todos = new ArrayList(); todos.add(new Todo(1L, "A", true)); todos.add(new Todo(2L, "B", false)); todos.add(new Todo(3L, "C", false)); - CopyOperation copy = new CopyOperation("/~", "/0"); + CopyOperation copy = new CopyOperation("/-", "/0"); copy.perform(todos, Todo.class); assertEquals(4, todos.size()); @@ -137,14 +137,14 @@ public class CopyOperationTests { } @Test - public void copyListElementFromEndOfList_usingTilde() throws Exception { + public void copyListElementFromEndOfList_usingDash() throws Exception { List todos = new ArrayList(); todos.add(new Todo(1L, "A", true)); todos.add(new Todo(2L, "B", false)); todos.add(new Todo(3L, "C", false)); - CopyOperation copy = new CopyOperation("/0", "/~"); + CopyOperation copy = new CopyOperation("/0", "/-"); copy.perform(todos, Todo.class); assertEquals(4, todos.size()); diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/patch/MoveOperationTests.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/patch/MoveOperationTests.java index d1e5b2ebf..041149c5e 100644 --- a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/patch/MoveOperationTests.java +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/patch/MoveOperationTests.java @@ -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. @@ -135,7 +135,7 @@ public class MoveOperationTests { } @Test - public void moveListElementToBeginningOfList_usingTilde() throws Exception { + public void moveListElementToBeginningOfList_usingDash() throws Exception { List todos = new ArrayList(); todos.add(new Todo(1L, "A", true)); @@ -149,13 +149,13 @@ public class MoveOperationTests { expected.add(new Todo(3L, "C", false)); expected.add(new Todo(4L, "E", false)); - MoveOperation move = new MoveOperation("/1", "/~"); + MoveOperation move = new MoveOperation("/1", "/-"); move.perform(todos, Todo.class); assertEquals(expected, todos); } @Test - public void moveListElementToEndOfList_usingTilde() throws Exception { + public void moveListElementToEndOfList_usingDash() throws Exception { List todos = new ArrayList(); todos.add(new Todo(1L, "A", true)); @@ -169,7 +169,7 @@ public class MoveOperationTests { expected.add(new Todo(4L, "E", false)); expected.add(new Todo(2L, "G", false)); - MoveOperation move = new MoveOperation("/~", "/1"); + MoveOperation move = new MoveOperation("/-", "/1"); move.perform(todos, Todo.class); assertEquals(expected, todos); } diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/patch/PathToSpelTests.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/patch/PathToSpelTests.java index c6e8debf4..70dd0a522 100644 --- a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/patch/PathToSpelTests.java +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/patch/PathToSpelTests.java @@ -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. @@ -39,9 +39,9 @@ public class PathToSpelTests { } @Test - public void listTilde() { + public void accessesLastCollectionElementWithDash() { - Expression expr = PathToSpEL.pathToExpression("/~/description"); + Expression expr = PathToSpEL.pathToExpression("/-/description"); List todos = new ArrayList(); todos.add(new Todo(1L, "A", false));