diff --git a/main/src/com/google/refine/operations/column/ColumnRenameOperation.java b/main/src/com/google/refine/operations/column/ColumnRenameOperation.java index 1b843fe6f..7b3739e97 100644 --- a/main/src/com/google/refine/operations/column/ColumnRenameOperation.java +++ b/main/src/com/google/refine/operations/column/ColumnRenameOperation.java @@ -33,6 +33,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package com.google.refine.operations.column; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.refine.history.Change; import com.google.refine.history.HistoryEntry; @@ -44,8 +45,11 @@ public class ColumnRenameOperation extends AbstractOperation { final protected String _oldColumnName; final protected String _newColumnName; + @JsonCreator public ColumnRenameOperation( + @JsonProperty("oldColumnName") String oldColumnName, + @JsonProperty("newColumnName") String newColumnName ) { _oldColumnName = oldColumnName; diff --git a/main/tests/server/src/com/google/refine/tests/operations/column/ColumnRenameOperationTests.java b/main/tests/server/src/com/google/refine/tests/operations/column/ColumnRenameOperationTests.java index b75a8ebb5..7801cdb49 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/column/ColumnRenameOperationTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/column/ColumnRenameOperationTests.java @@ -1,14 +1,14 @@ package com.google.refine.tests.operations.column; -import org.json.JSONException; -import org.json.JSONObject; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; +import com.google.refine.model.AbstractOperation; import com.google.refine.operations.OperationRegistry; import com.google.refine.operations.column.ColumnRenameOperation; import com.google.refine.tests.RefineTest; import com.google.refine.tests.util.TestUtils; +import com.google.refine.util.ParsingUtilities; public class ColumnRenameOperationTests extends RefineTest { @@ -19,15 +19,12 @@ public class ColumnRenameOperationTests extends RefineTest { } @Test - public void serializeColumnRenameOperation() throws JSONException, Exception { + public void serializeColumnRenameOperation() throws Exception { String json = "{\"op\":\"core/column-rename\"," + "\"description\":\"Rename column old name to new name\"," + "\"oldColumnName\":\"old name\"," + "\"newColumnName\":\"new name\"}"; - JSONObject obj = new JSONObject(json); - TestUtils.isSerializedTo(new ColumnRenameOperation( - obj.getString("oldColumnName"), - obj.getString("newColumnName") - ), json); + AbstractOperation op = ParsingUtilities.mapper.readValue(json, AbstractOperation.class); + TestUtils.isSerializedTo(op, json); } }