From 5cf58d874b7492cf3df0cb87ab1862c51cb577ed Mon Sep 17 00:00:00 2001 From: Antonin Delpeuch Date: Fri, 2 Nov 2018 15:06:54 +0000 Subject: [PATCH] Fix deserialization of MassEditOperation --- .../refine/operations/cell/MassEditOperation.java | 13 +++++++++++-- .../tests/operations/cell/MassOperationTests.java | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/main/src/com/google/refine/operations/cell/MassEditOperation.java b/main/src/com/google/refine/operations/cell/MassEditOperation.java index fdd99d376..593912b42 100644 --- a/main/src/com/google/refine/operations/cell/MassEditOperation.java +++ b/main/src/com/google/refine/operations/cell/MassEditOperation.java @@ -77,7 +77,7 @@ public class MassEditOperation extends EngineDependentMassCellOperation { boolean fromError, Serializable to) { this.from = from; - this.fromBlank = fromBlank; + this.fromBlank = fromBlank || (from.size() == 1 && from.get(0).length() == 0); this.fromError = fromError; this.to = to; } @@ -103,7 +103,16 @@ public class MassEditOperation extends EngineDependentMassCellOperation { } } - public MassEditOperation(EngineConfig engineConfig, String columnName, String expression, List edits) { + @JsonCreator + public MassEditOperation( + @JsonProperty("engineConfig") + EngineConfig engineConfig, + @JsonProperty("columnName") + String columnName, + @JsonProperty("expression") + String expression, + @JsonProperty("edits") + List edits) { super(engineConfig, columnName, true); _expression = expression; _edits = edits; diff --git a/main/tests/server/src/com/google/refine/tests/operations/cell/MassOperationTests.java b/main/tests/server/src/com/google/refine/tests/operations/cell/MassOperationTests.java index 01497bd5d..d604fedc3 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/cell/MassOperationTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/cell/MassOperationTests.java @@ -93,7 +93,7 @@ public class MassOperationTests extends RefineTest { public void testReconstructEditDate() throws Exception { editsString = "[{\"from\":[\"2018-10-04T00:00:00Z\"],\"to\":\"newString\",\"type\":\"text\"}]"; - editList = ParsingUtilities.mapper.readValue(ParsingUtilities.evaluateJsonStringToArray(editsString).toString(), new TypeReference>() {}); + editList = ParsingUtilities.mapper.readValue(editsString, new TypeReference>() {}); Assert.assertEquals(editList.get(0).from.get(0), "2018-10-04T00:00:00Z"); Assert.assertEquals(editList.get(0).to,"newString" ); @@ -105,7 +105,7 @@ public class MassOperationTests extends RefineTest { public void testReconstructEditEmpty() throws Exception { editsString = "[{\"from\":[\"\"],\"to\":\"newString\",\"type\":\"text\"}]"; - editList = ParsingUtilities.mapper.readValue(ParsingUtilities.evaluateJsonStringToArray(editsString).toString(), new TypeReference>() {}); + editList = ParsingUtilities.mapper.readValue(editsString, new TypeReference>() {}); Assert.assertEquals(editList.get(0).from.size(), 1); Assert.assertEquals(editList.get(0).from.get(0), "");