From d012ea7f8d22ede640aef7af7d003fe4d9ed49f5 Mon Sep 17 00:00:00 2001 From: Antonin Delpeuch Date: Mon, 22 Oct 2018 14:18:17 +0100 Subject: [PATCH] Remove reconstruct method on operations --- .../operations/EngineDependentMassCellOperation.java | 3 +++ .../refine/operations/cell/BlankDownOperation.java | 8 -------- .../refine/operations/cell/FillDownOperation.java | 8 -------- .../operations/cell/KeyValueColumnizeOperation.java | 8 -------- .../refine/operations/cell/MassEditOperation.java | 7 ------- .../operations/cell/MultiValuedCellJoinOperation.java | 7 ------- .../cell/MultiValuedCellSplitOperation.java | 6 ------ .../operations/cell/TextTransformOperation.java | 8 -------- .../cell/TransposeColumnsIntoRowsOperation.java | 7 ------- .../cell/TransposeRowsIntoColumnsOperation.java | 7 ------- .../column/ColumnAdditionByFetchingURLsOperation.java | 6 ------ .../operations/column/ColumnAdditionOperation.java | 9 --------- .../refine/operations/column/ColumnMoveOperation.java | 9 --------- .../operations/column/ColumnRemovalOperation.java | 9 --------- .../operations/column/ColumnRenameOperation.java | 9 --------- .../operations/column/ColumnReorderOperation.java | 7 ------- .../operations/column/ColumnSplitOperation.java | 8 -------- .../refine/operations/recon/ExtendDataOperation.java | 7 ------- .../recon/ReconClearSimilarCellsOperation.java | 9 --------- .../recon/ReconCopyAcrossColumnsOperation.java | 9 --------- .../recon/ReconDiscardJudgmentsOperation.java | 9 --------- .../recon/ReconJudgeSimilarCellsOperation.java | 11 +---------- .../operations/recon/ReconMarkNewTopicsOperation.java | 9 --------- .../recon/ReconMatchBestCandidatesOperation.java | 8 -------- .../recon/ReconMatchSpecificTopicOperation.java | 8 -------- .../refine/operations/recon/ReconOperation.java | 5 ----- .../recon/ReconUseValuesAsIdentifiersOperation.java | 8 -------- .../refine/operations/row/DenormalizeOperation.java | 6 ------ .../refine/operations/row/RowFlagOperation.java | 8 -------- .../refine/operations/row/RowRemovalOperation.java | 11 +---------- .../refine/operations/row/RowReorderOperation.java | 10 +--------- .../refine/operations/row/RowStarOperation.java | 11 +---------- .../tests/model/changes/DataExtensionChangeTest.java | 10 +++------- .../refine/tests/operations/cell/BlankDownTests.java | 5 ++--- .../refine/tests/operations/cell/FillDownTests.java | 5 +++-- .../operations/cell/JoinMultiValuedCellsTests.java | 4 ++-- .../tests/operations/cell/KeyValueColumnizeTests.java | 5 +++-- .../tests/operations/cell/MassOperationTests.java | 6 +----- .../operations/cell/SplitMultiValuedCellsTests.java | 6 +++--- .../refine/tests/operations/cell/TransposeTests.java | 8 ++------ .../ColumnAdditionByFetchingURLsOperationTests.java | 5 +++-- .../column/ColumnAdditionOperationTests.java | 8 ++------ .../operations/column/ColumnMoveOperationTests.java | 8 ++------ .../column/ColumnRemovalOperationTests.java | 8 ++------ .../operations/column/ColumnRenameOperationTests.java | 10 +++++----- .../operations/column/ColumnSplitOperationTests.java | 11 +++-------- .../operations/recon/ExtendDataOperationTests.java | 5 +++-- .../recon/ReconClearSimilarCellsOperationTests.java | 8 ++------ .../recon/ReconCopyAcrossColumnsOperationTests.java | 8 ++------ .../recon/ReconDiscardJudgmentsOperationTests.java | 8 ++------ .../recon/ReconJudgeSimilarCellsOperationTests.java | 6 ++---- .../operations/recon/ReconJudgeSimilarCellsTests.java | 6 +++--- .../recon/ReconMarkNewTopicsOperationTests.java | 8 ++------ .../recon/ReconMatchBestCandidatesOperationTests.java | 8 ++------ .../recon/ReconMatchSpecificTopicOperationTests.java | 8 ++------ .../tests/operations/recon/ReconOperationTests.java | 6 +++--- .../recon/ReconUseValuesAsIdsOperationTests.java | 6 +++--- .../operations/row/DenormalizeOperationTests.java | 3 +-- .../tests/operations/row/RowFlagOperationTests.java | 4 ++-- .../operations/row/RowRemovalOperationTests.java | 4 ++-- .../operations/row/RowReorderOperationTests.java | 3 ++- .../tests/operations/row/RowStarOperationTests.java | 5 +++-- 62 files changed, 79 insertions(+), 371 deletions(-) diff --git a/main/src/com/google/refine/operations/EngineDependentMassCellOperation.java b/main/src/com/google/refine/operations/EngineDependentMassCellOperation.java index 1ebbe8bec..daf02378e 100644 --- a/main/src/com/google/refine/operations/EngineDependentMassCellOperation.java +++ b/main/src/com/google/refine/operations/EngineDependentMassCellOperation.java @@ -36,6 +36,7 @@ package com.google.refine.operations; import java.util.ArrayList; import java.util.List; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.refine.browsing.Engine; @@ -50,7 +51,9 @@ import com.google.refine.model.changes.CellChange; import com.google.refine.model.changes.MassCellChange; abstract public class EngineDependentMassCellOperation extends EngineDependentOperation { + @JsonIgnore final protected String _columnName; + @JsonIgnore final protected boolean _updateRowContextDependencies; protected EngineDependentMassCellOperation( diff --git a/main/src/com/google/refine/operations/cell/BlankDownOperation.java b/main/src/com/google/refine/operations/cell/BlankDownOperation.java index 4ed6c4fd6..f022f28af 100644 --- a/main/src/com/google/refine/operations/cell/BlankDownOperation.java +++ b/main/src/com/google/refine/operations/cell/BlankDownOperation.java @@ -35,8 +35,6 @@ package com.google.refine.operations.cell; import java.util.List; -import org.json.JSONObject; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; @@ -44,21 +42,15 @@ import com.google.refine.browsing.Engine.Mode; import com.google.refine.browsing.EngineConfig; import com.google.refine.browsing.RowVisitor; import com.google.refine.expr.ExpressionUtils; -import com.google.refine.model.AbstractOperation; import com.google.refine.model.Cell; import com.google.refine.model.Column; import com.google.refine.model.Project; import com.google.refine.model.Row; import com.google.refine.model.changes.CellChange; import com.google.refine.operations.EngineDependentMassCellOperation; -import com.google.refine.util.ParsingUtilities; public class BlankDownOperation extends EngineDependentMassCellOperation { - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception { - return ParsingUtilities.mapper.readValue(obj.toString(), BlankDownOperation.class); - } - @JsonCreator public BlankDownOperation( @JsonProperty("engineConfig") diff --git a/main/src/com/google/refine/operations/cell/FillDownOperation.java b/main/src/com/google/refine/operations/cell/FillDownOperation.java index b672f9558..b3a47ca60 100644 --- a/main/src/com/google/refine/operations/cell/FillDownOperation.java +++ b/main/src/com/google/refine/operations/cell/FillDownOperation.java @@ -35,8 +35,6 @@ package com.google.refine.operations.cell; import java.util.List; -import org.json.JSONObject; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; @@ -45,21 +43,15 @@ import com.google.refine.browsing.Engine.Mode; import com.google.refine.browsing.EngineConfig; import com.google.refine.browsing.RowVisitor; import com.google.refine.expr.ExpressionUtils; -import com.google.refine.model.AbstractOperation; import com.google.refine.model.Cell; import com.google.refine.model.Column; import com.google.refine.model.Project; import com.google.refine.model.Row; import com.google.refine.model.changes.CellChange; import com.google.refine.operations.EngineDependentMassCellOperation; -import com.google.refine.util.ParsingUtilities; public class FillDownOperation extends EngineDependentMassCellOperation { - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception { - return ParsingUtilities.mapper.readValue(obj.toString(), FillDownOperation.class); - } - @JsonCreator public FillDownOperation( @JsonProperty("engineConfig") diff --git a/main/src/com/google/refine/operations/cell/KeyValueColumnizeOperation.java b/main/src/com/google/refine/operations/cell/KeyValueColumnizeOperation.java index cfb9398f5..bc04f38d9 100644 --- a/main/src/com/google/refine/operations/cell/KeyValueColumnizeOperation.java +++ b/main/src/com/google/refine/operations/cell/KeyValueColumnizeOperation.java @@ -33,14 +33,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package com.google.refine.operations.cell; -import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.json.JSONObject; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; @@ -52,17 +49,12 @@ import com.google.refine.model.Column; import com.google.refine.model.Project; import com.google.refine.model.Row; import com.google.refine.model.changes.MassRowColumnChange; -import com.google.refine.util.ParsingUtilities; public class KeyValueColumnizeOperation extends AbstractOperation { final protected String _keyColumnName; final protected String _valueColumnName; final protected String _noteColumnName; - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException { - return ParsingUtilities.mapper.readValue(obj.toString(), KeyValueColumnizeOperation.class); - } - @JsonCreator public KeyValueColumnizeOperation( @JsonProperty("keyColumnName") diff --git a/main/src/com/google/refine/operations/cell/MassEditOperation.java b/main/src/com/google/refine/operations/cell/MassEditOperation.java index 50f800834..fdd99d376 100644 --- a/main/src/com/google/refine/operations/cell/MassEditOperation.java +++ b/main/src/com/google/refine/operations/cell/MassEditOperation.java @@ -40,8 +40,6 @@ import java.util.List; import java.util.Map; import java.util.Properties; -import org.json.JSONObject; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; @@ -50,7 +48,6 @@ import com.google.refine.browsing.RowVisitor; import com.google.refine.expr.Evaluable; import com.google.refine.expr.ExpressionUtils; import com.google.refine.expr.MetaParser; -import com.google.refine.model.AbstractOperation; import com.google.refine.model.Cell; import com.google.refine.model.Column; import com.google.refine.model.Project; @@ -106,10 +103,6 @@ public class MassEditOperation extends EngineDependentMassCellOperation { } } - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception { - return ParsingUtilities.mapper.readValue(obj.toString(), MassEditOperation.class); - } - public MassEditOperation(EngineConfig engineConfig, String columnName, String expression, List edits) { super(engineConfig, columnName, true); _expression = expression; diff --git a/main/src/com/google/refine/operations/cell/MultiValuedCellJoinOperation.java b/main/src/com/google/refine/operations/cell/MultiValuedCellJoinOperation.java index 9f24bfb3d..88ef3aeff 100644 --- a/main/src/com/google/refine/operations/cell/MultiValuedCellJoinOperation.java +++ b/main/src/com/google/refine/operations/cell/MultiValuedCellJoinOperation.java @@ -36,8 +36,6 @@ package com.google.refine.operations.cell; import java.util.ArrayList; import java.util.List; -import org.json.JSONObject; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; @@ -49,17 +47,12 @@ import com.google.refine.model.Column; import com.google.refine.model.Project; import com.google.refine.model.Row; import com.google.refine.model.changes.MassRowChange; -import com.google.refine.util.ParsingUtilities; public class MultiValuedCellJoinOperation extends AbstractOperation { final protected String _columnName; final protected String _keyColumnName; final protected String _separator; - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception { - return ParsingUtilities.mapper.readValue(obj.toString(), MultiValuedCellJoinOperation.class); - } - @JsonCreator public MultiValuedCellJoinOperation( @JsonProperty("columnName") diff --git a/main/src/com/google/refine/operations/cell/MultiValuedCellSplitOperation.java b/main/src/com/google/refine/operations/cell/MultiValuedCellSplitOperation.java index d0b66d123..fbb3a9006 100644 --- a/main/src/com/google/refine/operations/cell/MultiValuedCellSplitOperation.java +++ b/main/src/com/google/refine/operations/cell/MultiValuedCellSplitOperation.java @@ -38,7 +38,6 @@ import java.util.List; import java.util.regex.Pattern; import org.apache.commons.lang3.StringUtils; -import org.json.JSONObject; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonInclude; @@ -52,7 +51,6 @@ import com.google.refine.model.Column; import com.google.refine.model.Project; import com.google.refine.model.Row; import com.google.refine.model.changes.MassRowChange; -import com.google.refine.util.ParsingUtilities; public class MultiValuedCellSplitOperation extends AbstractOperation { final protected String _columnName; @@ -63,10 +61,6 @@ public class MultiValuedCellSplitOperation extends AbstractOperation { final protected int[] _fieldLengths; - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception { - return ParsingUtilities.mapper.readValue(obj.toString(), MultiValuedCellSplitOperation.class); - } - @JsonCreator public static MultiValuedCellSplitOperation deserialize( @JsonProperty("columnName") diff --git a/main/src/com/google/refine/operations/cell/TextTransformOperation.java b/main/src/com/google/refine/operations/cell/TextTransformOperation.java index c1cc816b5..bdedef2cc 100644 --- a/main/src/com/google/refine/operations/cell/TextTransformOperation.java +++ b/main/src/com/google/refine/operations/cell/TextTransformOperation.java @@ -37,8 +37,6 @@ import java.io.Serializable; import java.util.List; import java.util.Properties; -import org.json.JSONObject; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; @@ -48,7 +46,6 @@ import com.google.refine.expr.Evaluable; import com.google.refine.expr.ExpressionUtils; import com.google.refine.expr.MetaParser; import com.google.refine.expr.WrappedCell; -import com.google.refine.model.AbstractOperation; import com.google.refine.model.Cell; import com.google.refine.model.Column; import com.google.refine.model.Project; @@ -56,7 +53,6 @@ import com.google.refine.model.Row; import com.google.refine.model.changes.CellChange; import com.google.refine.operations.EngineDependentMassCellOperation; import com.google.refine.operations.OnError; -import com.google.refine.util.ParsingUtilities; public class TextTransformOperation extends EngineDependentMassCellOperation { @JsonProperty("expression") @@ -68,10 +64,6 @@ public class TextTransformOperation extends EngineDependentMassCellOperation { @JsonProperty("repeatCount") final protected int _repeatCount; - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception { - return ParsingUtilities.mapper.readValue(obj.toString(), TextTransformOperation.class); - } - static public OnError stringToOnError(String s) { if ("set-to-blank".equalsIgnoreCase(s)) { return OnError.SetToBlank; diff --git a/main/src/com/google/refine/operations/cell/TransposeColumnsIntoRowsOperation.java b/main/src/com/google/refine/operations/cell/TransposeColumnsIntoRowsOperation.java index 0f7c44690..c9e416d76 100644 --- a/main/src/com/google/refine/operations/cell/TransposeColumnsIntoRowsOperation.java +++ b/main/src/com/google/refine/operations/cell/TransposeColumnsIntoRowsOperation.java @@ -36,8 +36,6 @@ package com.google.refine.operations.cell; import java.util.ArrayList; import java.util.List; -import org.json.JSONObject; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; @@ -51,7 +49,6 @@ import com.google.refine.model.Column; import com.google.refine.model.Project; import com.google.refine.model.Row; import com.google.refine.model.changes.MassRowColumnChange; -import com.google.refine.util.ParsingUtilities; public class TransposeColumnsIntoRowsOperation extends AbstractOperation { @JsonProperty("startColumnName") @@ -82,10 +79,6 @@ public class TransposeColumnsIntoRowsOperation extends AbstractOperation { return _combinedColumnName == null ? null : _prependColumnName; } - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception { - return ParsingUtilities.mapper.readValue(obj.toString(), TransposeColumnsIntoRowsOperation.class); - } - @JsonCreator static public TransposeColumnsIntoRowsOperation deserialize( @JsonProperty("combinedColumnName") diff --git a/main/src/com/google/refine/operations/cell/TransposeRowsIntoColumnsOperation.java b/main/src/com/google/refine/operations/cell/TransposeRowsIntoColumnsOperation.java index 97f886074..bcfa612a1 100644 --- a/main/src/com/google/refine/operations/cell/TransposeRowsIntoColumnsOperation.java +++ b/main/src/com/google/refine/operations/cell/TransposeRowsIntoColumnsOperation.java @@ -36,8 +36,6 @@ package com.google.refine.operations.cell; import java.util.ArrayList; import java.util.List; -import org.json.JSONObject; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; @@ -48,16 +46,11 @@ import com.google.refine.model.Column; import com.google.refine.model.Project; import com.google.refine.model.Row; import com.google.refine.model.changes.MassRowColumnChange; -import com.google.refine.util.ParsingUtilities; public class TransposeRowsIntoColumnsOperation extends AbstractOperation { final protected String _columnName; final protected int _rowCount; - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception { - return ParsingUtilities.mapper.readValue(obj.toString(), TransposeRowsIntoColumnsOperation.class); - } - @JsonCreator public TransposeRowsIntoColumnsOperation( @JsonProperty("columnName") diff --git a/main/src/com/google/refine/operations/column/ColumnAdditionByFetchingURLsOperation.java b/main/src/com/google/refine/operations/column/ColumnAdditionByFetchingURLsOperation.java index daec11954..4e920f435 100644 --- a/main/src/com/google/refine/operations/column/ColumnAdditionByFetchingURLsOperation.java +++ b/main/src/com/google/refine/operations/column/ColumnAdditionByFetchingURLsOperation.java @@ -46,7 +46,6 @@ import java.util.Properties; import java.util.concurrent.TimeUnit; import org.json.JSONException; -import org.json.JSONObject; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; @@ -65,7 +64,6 @@ import com.google.refine.expr.ExpressionUtils; import com.google.refine.expr.MetaParser; import com.google.refine.expr.WrappedCell; import com.google.refine.history.HistoryEntry; -import com.google.refine.model.AbstractOperation; import com.google.refine.model.Cell; import com.google.refine.model.Column; import com.google.refine.model.Project; @@ -107,10 +105,6 @@ public class ColumnAdditionByFetchingURLsOperation extends EngineDependentOperat final protected boolean _cacheResponses; final protected List _httpHeadersJson; - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception { - return ParsingUtilities.mapper.readValue(obj.toString(), ColumnAdditionByFetchingURLsOperation.class); - } - @JsonCreator public ColumnAdditionByFetchingURLsOperation( @JsonProperty("engineConfig") diff --git a/main/src/com/google/refine/operations/column/ColumnAdditionOperation.java b/main/src/com/google/refine/operations/column/ColumnAdditionOperation.java index e32034361..6e58835e5 100644 --- a/main/src/com/google/refine/operations/column/ColumnAdditionOperation.java +++ b/main/src/com/google/refine/operations/column/ColumnAdditionOperation.java @@ -33,14 +33,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package com.google.refine.operations.column; -import java.io.IOException; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.Properties; -import org.json.JSONObject; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; @@ -54,7 +51,6 @@ import com.google.refine.expr.MetaParser; import com.google.refine.expr.WrappedCell; import com.google.refine.history.Change; import com.google.refine.history.HistoryEntry; -import com.google.refine.model.AbstractOperation; import com.google.refine.model.Cell; import com.google.refine.model.Column; import com.google.refine.model.Project; @@ -63,7 +59,6 @@ import com.google.refine.model.changes.CellAtRow; import com.google.refine.model.changes.ColumnAdditionChange; import com.google.refine.operations.EngineDependentOperation; import com.google.refine.operations.OnError; -import com.google.refine.util.ParsingUtilities; public class ColumnAdditionOperation extends EngineDependentOperation { final protected String _baseColumnName; @@ -73,10 +68,6 @@ public class ColumnAdditionOperation extends EngineDependentOperation { final protected String _newColumnName; final protected int _columnInsertIndex; - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException { - return ParsingUtilities.mapper.readValue(obj.toString(), ColumnAdditionOperation.class); - } - @JsonCreator public ColumnAdditionOperation( @JsonProperty("engineConfig") diff --git a/main/src/com/google/refine/operations/column/ColumnMoveOperation.java b/main/src/com/google/refine/operations/column/ColumnMoveOperation.java index ed764a731..fd0842f53 100644 --- a/main/src/com/google/refine/operations/column/ColumnMoveOperation.java +++ b/main/src/com/google/refine/operations/column/ColumnMoveOperation.java @@ -33,10 +33,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package com.google.refine.operations.column; -import java.io.IOException; - -import org.json.JSONObject; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; @@ -45,16 +41,11 @@ import com.google.refine.history.HistoryEntry; import com.google.refine.model.AbstractOperation; import com.google.refine.model.Project; import com.google.refine.model.changes.ColumnMoveChange; -import com.google.refine.util.ParsingUtilities; public class ColumnMoveOperation extends AbstractOperation { final protected String _columnName; final protected int _index; - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException { - return ParsingUtilities.mapper.readValue(obj.toString(), ColumnMoveOperation.class); - } - @JsonCreator public ColumnMoveOperation( @JsonProperty("columnName") diff --git a/main/src/com/google/refine/operations/column/ColumnRemovalOperation.java b/main/src/com/google/refine/operations/column/ColumnRemovalOperation.java index 2d90a32ae..7449345bc 100644 --- a/main/src/com/google/refine/operations/column/ColumnRemovalOperation.java +++ b/main/src/com/google/refine/operations/column/ColumnRemovalOperation.java @@ -33,10 +33,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package com.google.refine.operations.column; -import java.io.IOException; - -import org.json.JSONObject; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; @@ -46,15 +42,10 @@ import com.google.refine.model.AbstractOperation; import com.google.refine.model.Column; import com.google.refine.model.Project; import com.google.refine.model.changes.ColumnRemovalChange; -import com.google.refine.util.ParsingUtilities; public class ColumnRemovalOperation extends AbstractOperation { final protected String _columnName; - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException { - return ParsingUtilities.mapper.readValue(obj.toString(), ColumnRemovalOperation.class); - } - @JsonCreator public ColumnRemovalOperation( @JsonProperty("columnName") diff --git a/main/src/com/google/refine/operations/column/ColumnRenameOperation.java b/main/src/com/google/refine/operations/column/ColumnRenameOperation.java index d76f928a7..6359d6324 100644 --- a/main/src/com/google/refine/operations/column/ColumnRenameOperation.java +++ b/main/src/com/google/refine/operations/column/ColumnRenameOperation.java @@ -33,8 +33,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package com.google.refine.operations.column; -import org.json.JSONObject; - import com.fasterxml.jackson.annotation.JsonProperty; import com.google.refine.history.Change; @@ -47,13 +45,6 @@ public class ColumnRenameOperation extends AbstractOperation { final protected String _oldColumnName; final protected String _newColumnName; - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception { - return new ColumnRenameOperation( - obj.getString("oldColumnName"), - obj.getString("newColumnName") - ); - } - public ColumnRenameOperation( String oldColumnName, String newColumnName diff --git a/main/src/com/google/refine/operations/column/ColumnReorderOperation.java b/main/src/com/google/refine/operations/column/ColumnReorderOperation.java index 4202d2341..032a8f7b9 100644 --- a/main/src/com/google/refine/operations/column/ColumnReorderOperation.java +++ b/main/src/com/google/refine/operations/column/ColumnReorderOperation.java @@ -35,8 +35,6 @@ package com.google.refine.operations.column; import java.util.List; -import org.json.JSONObject; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; @@ -44,13 +42,8 @@ import com.google.refine.history.HistoryEntry; import com.google.refine.model.AbstractOperation; import com.google.refine.model.Project; import com.google.refine.model.changes.ColumnReorderChange; -import com.google.refine.util.ParsingUtilities; public class ColumnReorderOperation extends AbstractOperation { - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception { - return ParsingUtilities.mapper.readValue(obj.toString(), ColumnReorderOperation.class); - } - final protected List _columnNames; @JsonCreator diff --git a/main/src/com/google/refine/operations/column/ColumnSplitOperation.java b/main/src/com/google/refine/operations/column/ColumnSplitOperation.java index 1ac7388d1..6f55b7a47 100644 --- a/main/src/com/google/refine/operations/column/ColumnSplitOperation.java +++ b/main/src/com/google/refine/operations/column/ColumnSplitOperation.java @@ -33,14 +33,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package com.google.refine.operations.column; -import java.io.IOException; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; import org.apache.commons.lang3.StringUtils; -import org.json.JSONObject; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonInclude; @@ -55,13 +53,11 @@ import com.google.refine.expr.ExpressionUtils; import com.google.refine.history.Change; import com.google.refine.history.HistoryEntry; import com.google.refine.importers.ImporterUtilities; -import com.google.refine.model.AbstractOperation; import com.google.refine.model.Column; import com.google.refine.model.Project; import com.google.refine.model.Row; import com.google.refine.model.changes.ColumnSplitChange; import com.google.refine.operations.EngineDependentOperation; -import com.google.refine.util.ParsingUtilities; public class ColumnSplitOperation extends EngineDependentOperation { final protected String _columnName; @@ -75,10 +71,6 @@ public class ColumnSplitOperation extends EngineDependentOperation { final protected int[] _fieldLengths; - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException { - return ParsingUtilities.mapper.readValue(obj.toString(), ColumnSplitOperation.class); - } - @JsonCreator public static ColumnSplitOperation deserialize( @JsonProperty("engineConfig") diff --git a/main/src/com/google/refine/operations/recon/ExtendDataOperation.java b/main/src/com/google/refine/operations/recon/ExtendDataOperation.java index e0aa039e4..adcd26861 100644 --- a/main/src/com/google/refine/operations/recon/ExtendDataOperation.java +++ b/main/src/com/google/refine/operations/recon/ExtendDataOperation.java @@ -42,7 +42,6 @@ import java.util.Properties; import java.util.Set; import org.json.JSONException; -import org.json.JSONObject; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; @@ -52,7 +51,6 @@ import com.google.refine.browsing.EngineConfig; import com.google.refine.browsing.FilteredRows; import com.google.refine.browsing.RowVisitor; import com.google.refine.history.HistoryEntry; -import com.google.refine.model.AbstractOperation; import com.google.refine.model.Cell; import com.google.refine.model.Column; import com.google.refine.model.Project; @@ -68,7 +66,6 @@ import com.google.refine.model.recon.ReconciledDataExtensionJob.DataExtensionCon import com.google.refine.operations.EngineDependentOperation; import com.google.refine.process.LongRunningProcess; import com.google.refine.process.Process; -import com.google.refine.util.ParsingUtilities; public class ExtendDataOperation extends EngineDependentOperation { @JsonProperty("baseColumnName") @@ -85,10 +82,6 @@ public class ExtendDataOperation extends EngineDependentOperation { final protected int _columnInsertIndex; - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception { - return ParsingUtilities.mapper.readValue(obj.toString(), ExtendDataOperation.class); - } - @JsonCreator public ExtendDataOperation( @JsonProperty("engineConfig") diff --git a/main/src/com/google/refine/operations/recon/ReconClearSimilarCellsOperation.java b/main/src/com/google/refine/operations/recon/ReconClearSimilarCellsOperation.java index c342878d8..673e5e49d 100644 --- a/main/src/com/google/refine/operations/recon/ReconClearSimilarCellsOperation.java +++ b/main/src/com/google/refine/operations/recon/ReconClearSimilarCellsOperation.java @@ -33,18 +33,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package com.google.refine.operations.recon; -import java.io.IOException; import java.util.List; -import org.json.JSONObject; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.refine.browsing.EngineConfig; import com.google.refine.browsing.RowVisitor; import com.google.refine.history.Change; -import com.google.refine.model.AbstractOperation; import com.google.refine.model.Cell; import com.google.refine.model.Column; import com.google.refine.model.Project; @@ -52,15 +48,10 @@ import com.google.refine.model.Row; import com.google.refine.model.changes.CellChange; import com.google.refine.model.changes.ReconChange; import com.google.refine.operations.EngineDependentMassCellOperation; -import com.google.refine.util.ParsingUtilities; public class ReconClearSimilarCellsOperation extends EngineDependentMassCellOperation { final protected String _similarValue; - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException { - return ParsingUtilities.mapper.readValue(obj.toString(), ReconClearSimilarCellsOperation.class); - } - @JsonCreator public ReconClearSimilarCellsOperation( @JsonProperty("engineConfig") diff --git a/main/src/com/google/refine/operations/recon/ReconCopyAcrossColumnsOperation.java b/main/src/com/google/refine/operations/recon/ReconCopyAcrossColumnsOperation.java index ddbcda50d..6b9f89aa9 100644 --- a/main/src/com/google/refine/operations/recon/ReconCopyAcrossColumnsOperation.java +++ b/main/src/com/google/refine/operations/recon/ReconCopyAcrossColumnsOperation.java @@ -33,7 +33,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package com.google.refine.operations.recon; -import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -42,7 +41,6 @@ import java.util.Map; import java.util.Set; import org.apache.commons.lang3.StringUtils; -import org.json.JSONObject; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; @@ -52,7 +50,6 @@ import com.google.refine.browsing.EngineConfig; import com.google.refine.browsing.FilteredRows; import com.google.refine.browsing.RowVisitor; import com.google.refine.history.HistoryEntry; -import com.google.refine.model.AbstractOperation; import com.google.refine.model.Cell; import com.google.refine.model.Column; import com.google.refine.model.Project; @@ -62,8 +59,6 @@ import com.google.refine.model.Row; import com.google.refine.model.changes.CellChange; import com.google.refine.model.changes.MassChange; import com.google.refine.operations.EngineDependentOperation; -import com.google.refine.util.JSONUtilities; -import com.google.refine.util.ParsingUtilities; public class ReconCopyAcrossColumnsOperation extends EngineDependentOperation { final protected String _fromColumnName; @@ -71,10 +66,6 @@ public class ReconCopyAcrossColumnsOperation extends EngineDependentOperation { final protected String[] _judgments; final protected boolean _applyToJudgedCells; - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException { - return ParsingUtilities.mapper.readValue(obj.toString(), ReconCopyAcrossColumnsOperation.class); - } - @JsonCreator public ReconCopyAcrossColumnsOperation( @JsonProperty("engineConfig") diff --git a/main/src/com/google/refine/operations/recon/ReconDiscardJudgmentsOperation.java b/main/src/com/google/refine/operations/recon/ReconDiscardJudgmentsOperation.java index e58fa16f6..c5e538e2e 100644 --- a/main/src/com/google/refine/operations/recon/ReconDiscardJudgmentsOperation.java +++ b/main/src/com/google/refine/operations/recon/ReconDiscardJudgmentsOperation.java @@ -33,20 +33,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package com.google.refine.operations.recon; -import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.json.JSONObject; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.refine.browsing.EngineConfig; import com.google.refine.browsing.RowVisitor; import com.google.refine.history.Change; -import com.google.refine.model.AbstractOperation; import com.google.refine.model.Cell; import com.google.refine.model.Column; import com.google.refine.model.Project; @@ -56,15 +52,10 @@ import com.google.refine.model.Row; import com.google.refine.model.changes.CellChange; import com.google.refine.model.changes.ReconChange; import com.google.refine.operations.EngineDependentMassCellOperation; -import com.google.refine.util.ParsingUtilities; public class ReconDiscardJudgmentsOperation extends EngineDependentMassCellOperation { final protected boolean _clearData; - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException { - return ParsingUtilities.mapper.readValue(obj.toString(), ReconDiscardJudgmentsOperation.class); - } - @JsonCreator public ReconDiscardJudgmentsOperation( @JsonProperty("engineConfig") diff --git a/main/src/com/google/refine/operations/recon/ReconJudgeSimilarCellsOperation.java b/main/src/com/google/refine/operations/recon/ReconJudgeSimilarCellsOperation.java index 561fffcce..5068334b4 100644 --- a/main/src/com/google/refine/operations/recon/ReconJudgeSimilarCellsOperation.java +++ b/main/src/com/google/refine/operations/recon/ReconJudgeSimilarCellsOperation.java @@ -33,13 +33,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package com.google.refine.operations.recon; - import java.io.IOException; -import java.util.HashMap; + import java.util.HashMap; import java.util.List; import java.util.Map; -import org.json.JSONObject; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; @@ -49,7 +46,6 @@ import com.google.refine.browsing.EngineConfig; import com.google.refine.browsing.RowVisitor; import com.google.refine.expr.ExpressionUtils; import com.google.refine.history.Change; -import com.google.refine.model.AbstractOperation; import com.google.refine.model.Cell; import com.google.refine.model.Column; import com.google.refine.model.Project; @@ -61,7 +57,6 @@ import com.google.refine.model.changes.CellChange; import com.google.refine.model.changes.ReconChange; import com.google.refine.model.recon.ReconConfig; import com.google.refine.operations.EngineDependentMassCellOperation; -import com.google.refine.util.ParsingUtilities; public class ReconJudgeSimilarCellsOperation extends EngineDependentMassCellOperation { final protected String _similarValue; @@ -69,10 +64,6 @@ public class ReconJudgeSimilarCellsOperation extends EngineDependentMassCellOper final protected ReconCandidate _match; final protected boolean _shareNewTopics; - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException { - return ParsingUtilities.mapper.readValue(obj.toString(), ReconJudgeSimilarCellsOperation.class); - } - @JsonCreator public ReconJudgeSimilarCellsOperation( @JsonProperty("engineConfig") diff --git a/main/src/com/google/refine/operations/recon/ReconMarkNewTopicsOperation.java b/main/src/com/google/refine/operations/recon/ReconMarkNewTopicsOperation.java index 549f5cee2..ac0eb1989 100644 --- a/main/src/com/google/refine/operations/recon/ReconMarkNewTopicsOperation.java +++ b/main/src/com/google/refine/operations/recon/ReconMarkNewTopicsOperation.java @@ -33,20 +33,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package com.google.refine.operations.recon; -import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.json.JSONObject; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.refine.browsing.EngineConfig; import com.google.refine.browsing.RowVisitor; import com.google.refine.history.Change; -import com.google.refine.model.AbstractOperation; import com.google.refine.model.Cell; import com.google.refine.model.Column; import com.google.refine.model.Project; @@ -57,15 +53,10 @@ import com.google.refine.model.changes.CellChange; import com.google.refine.model.changes.ReconChange; import com.google.refine.model.recon.ReconConfig; import com.google.refine.operations.EngineDependentMassCellOperation; -import com.google.refine.util.ParsingUtilities; public class ReconMarkNewTopicsOperation extends EngineDependentMassCellOperation { final protected boolean _shareNewTopics; - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException { - return ParsingUtilities.mapper.readValue(obj.toString(), ReconMarkNewTopicsOperation.class); - } - @JsonCreator public ReconMarkNewTopicsOperation( @JsonProperty("engineConfig") diff --git a/main/src/com/google/refine/operations/recon/ReconMatchBestCandidatesOperation.java b/main/src/com/google/refine/operations/recon/ReconMatchBestCandidatesOperation.java index 46aaf45d9..17dd06184 100644 --- a/main/src/com/google/refine/operations/recon/ReconMatchBestCandidatesOperation.java +++ b/main/src/com/google/refine/operations/recon/ReconMatchBestCandidatesOperation.java @@ -37,15 +37,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.json.JSONObject; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.refine.browsing.EngineConfig; import com.google.refine.browsing.RowVisitor; import com.google.refine.history.Change; -import com.google.refine.model.AbstractOperation; import com.google.refine.model.Cell; import com.google.refine.model.Column; import com.google.refine.model.Project; @@ -56,13 +53,8 @@ import com.google.refine.model.Row; import com.google.refine.model.changes.CellChange; import com.google.refine.model.changes.ReconChange; import com.google.refine.operations.EngineDependentMassCellOperation; -import com.google.refine.util.ParsingUtilities; public class ReconMatchBestCandidatesOperation extends EngineDependentMassCellOperation { - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception { - return ParsingUtilities.mapper.readValue(obj.toString(), ReconMatchBestCandidatesOperation.class); - } - @JsonCreator public ReconMatchBestCandidatesOperation( @JsonProperty("engineConfig") diff --git a/main/src/com/google/refine/operations/recon/ReconMatchSpecificTopicOperation.java b/main/src/com/google/refine/operations/recon/ReconMatchSpecificTopicOperation.java index 709146811..918a71d4d 100644 --- a/main/src/com/google/refine/operations/recon/ReconMatchSpecificTopicOperation.java +++ b/main/src/com/google/refine/operations/recon/ReconMatchSpecificTopicOperation.java @@ -37,8 +37,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.json.JSONObject; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; @@ -46,7 +44,6 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.google.refine.browsing.EngineConfig; import com.google.refine.browsing.RowVisitor; import com.google.refine.history.Change; -import com.google.refine.model.AbstractOperation; import com.google.refine.model.Cell; import com.google.refine.model.Column; import com.google.refine.model.Project; @@ -57,7 +54,6 @@ import com.google.refine.model.Row; import com.google.refine.model.changes.CellChange; import com.google.refine.model.changes.ReconChange; import com.google.refine.operations.EngineDependentMassCellOperation; -import com.google.refine.util.ParsingUtilities; public class ReconMatchSpecificTopicOperation extends EngineDependentMassCellOperation { @@ -91,10 +87,6 @@ public class ReconMatchSpecificTopicOperation extends EngineDependentMassCellOpe @JsonProperty("schemaSpace") final protected String schemaSpace; - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception { - return ParsingUtilities.mapper.readValue(obj.toString(), ReconMatchSpecificTopicOperation.class); - } - @JsonCreator public ReconMatchSpecificTopicOperation( @JsonProperty("engineConfig") diff --git a/main/src/com/google/refine/operations/recon/ReconOperation.java b/main/src/com/google/refine/operations/recon/ReconOperation.java index 92bd12b12..b9218f145 100644 --- a/main/src/com/google/refine/operations/recon/ReconOperation.java +++ b/main/src/com/google/refine/operations/recon/ReconOperation.java @@ -40,7 +40,6 @@ import java.util.List; import java.util.Map; import java.util.Properties; -import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -76,10 +75,6 @@ public class ReconOperation extends EngineDependentOperation { final protected String _columnName; final protected ReconConfig _reconConfig; - static public ReconOperation reconstruct(Project project, JSONObject obj) throws IOException { - return ParsingUtilities.mapper.readValue(obj.toString(), ReconOperation.class); - } - @JsonCreator public ReconOperation( @JsonProperty("engineConfig") diff --git a/main/src/com/google/refine/operations/recon/ReconUseValuesAsIdentifiersOperation.java b/main/src/com/google/refine/operations/recon/ReconUseValuesAsIdentifiersOperation.java index b60744119..d6115decc 100644 --- a/main/src/com/google/refine/operations/recon/ReconUseValuesAsIdentifiersOperation.java +++ b/main/src/com/google/refine/operations/recon/ReconUseValuesAsIdentifiersOperation.java @@ -1,11 +1,8 @@ package com.google.refine.operations.recon; -import java.io.IOException; import java.util.Collections; import java.util.List; -import org.json.JSONObject; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; @@ -25,7 +22,6 @@ import com.google.refine.model.changes.CellChange; import com.google.refine.model.changes.ReconChange; import com.google.refine.model.recon.StandardReconConfig; import com.google.refine.operations.EngineDependentMassCellOperation; -import com.google.refine.util.ParsingUtilities; public class ReconUseValuesAsIdentifiersOperation extends EngineDependentMassCellOperation { @@ -58,10 +54,6 @@ public class ReconUseValuesAsIdentifiersOperation extends EngineDependentMassCel this.reconConfig = new StandardReconConfig(service, identifierSpace, schemaSpace, null, null, true, Collections.emptyList()); } - static public ReconUseValuesAsIdentifiersOperation reconstruct(JSONObject obj) throws IOException { - return ParsingUtilities.mapper.readValue(obj.toString(), ReconUseValuesAsIdentifiersOperation.class); - } - @Override public String getBriefDescription(Project project) { return "Use values as reconciliation identifiers in column " + _columnName; diff --git a/main/src/com/google/refine/operations/row/DenormalizeOperation.java b/main/src/com/google/refine/operations/row/DenormalizeOperation.java index da4b3a6d2..aaee43c51 100644 --- a/main/src/com/google/refine/operations/row/DenormalizeOperation.java +++ b/main/src/com/google/refine/operations/row/DenormalizeOperation.java @@ -36,8 +36,6 @@ package com.google.refine.operations.row; import java.util.ArrayList; import java.util.List; -import org.json.JSONObject; - import com.fasterxml.jackson.annotation.JsonCreator; import com.google.refine.history.HistoryEntry; @@ -50,10 +48,6 @@ import com.google.refine.model.Row; import com.google.refine.model.changes.MassRowChange; public class DenormalizeOperation extends AbstractOperation { - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception { - return new DenormalizeOperation(); - } - @JsonCreator public DenormalizeOperation() { } diff --git a/main/src/com/google/refine/operations/row/RowFlagOperation.java b/main/src/com/google/refine/operations/row/RowFlagOperation.java index 5a998edda..ddf142ec4 100644 --- a/main/src/com/google/refine/operations/row/RowFlagOperation.java +++ b/main/src/com/google/refine/operations/row/RowFlagOperation.java @@ -36,8 +36,6 @@ package com.google.refine.operations.row; import java.util.ArrayList; import java.util.List; -import org.json.JSONObject; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; @@ -47,21 +45,15 @@ import com.google.refine.browsing.FilteredRows; import com.google.refine.browsing.RowVisitor; import com.google.refine.history.Change; import com.google.refine.history.HistoryEntry; -import com.google.refine.model.AbstractOperation; import com.google.refine.model.Project; import com.google.refine.model.Row; import com.google.refine.model.changes.MassChange; import com.google.refine.model.changes.RowFlagChange; import com.google.refine.operations.EngineDependentOperation; -import com.google.refine.util.ParsingUtilities; public class RowFlagOperation extends EngineDependentOperation { final protected boolean _flagged; - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception { - return ParsingUtilities.mapper.readValue(obj.toString(), RowFlagOperation.class); - } - @JsonCreator public RowFlagOperation( @JsonProperty("engineConfig") diff --git a/main/src/com/google/refine/operations/row/RowRemovalOperation.java b/main/src/com/google/refine/operations/row/RowRemovalOperation.java index ba2dd823f..bf536ce0d 100644 --- a/main/src/com/google/refine/operations/row/RowRemovalOperation.java +++ b/main/src/com/google/refine/operations/row/RowRemovalOperation.java @@ -33,12 +33,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package com.google.refine.operations.row; - import java.io.IOException; -import java.util.ArrayList; + import java.util.ArrayList; import java.util.List; -import org.json.JSONObject; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; @@ -47,18 +44,12 @@ import com.google.refine.browsing.EngineConfig; import com.google.refine.browsing.FilteredRows; import com.google.refine.browsing.RowVisitor; import com.google.refine.history.HistoryEntry; -import com.google.refine.model.AbstractOperation; import com.google.refine.model.Project; import com.google.refine.model.Row; import com.google.refine.model.changes.RowRemovalChange; import com.google.refine.operations.EngineDependentOperation; -import com.google.refine.util.ParsingUtilities; public class RowRemovalOperation extends EngineDependentOperation { - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException { - return ParsingUtilities.mapper.readValue(obj.toString(), RowRemovalOperation.class); - } - @JsonCreator public RowRemovalOperation( @JsonProperty("engineConfig") diff --git a/main/src/com/google/refine/operations/row/RowReorderOperation.java b/main/src/com/google/refine/operations/row/RowReorderOperation.java index 97c7e3ced..b90867846 100644 --- a/main/src/com/google/refine/operations/row/RowReorderOperation.java +++ b/main/src/com/google/refine/operations/row/RowReorderOperation.java @@ -33,12 +33,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package com.google.refine.operations.row; - import java.io.IOException; -import java.util.ArrayList; + import java.util.ArrayList; import java.util.List; -import org.json.JSONObject; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; @@ -55,13 +52,8 @@ import com.google.refine.model.changes.RowReorderChange; import com.google.refine.sorting.SortingConfig; import com.google.refine.sorting.SortingRecordVisitor; import com.google.refine.sorting.SortingRowVisitor; -import com.google.refine.util.ParsingUtilities; public class RowReorderOperation extends AbstractOperation { - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException { - return ParsingUtilities.mapper.readValue(obj.toString(), RowReorderOperation.class); - } - final protected Mode _mode; final protected SortingConfig _sorting; diff --git a/main/src/com/google/refine/operations/row/RowStarOperation.java b/main/src/com/google/refine/operations/row/RowStarOperation.java index ed88f6d31..1d6caf472 100644 --- a/main/src/com/google/refine/operations/row/RowStarOperation.java +++ b/main/src/com/google/refine/operations/row/RowStarOperation.java @@ -33,12 +33,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package com.google.refine.operations.row; - import java.io.IOException; -import java.util.ArrayList; + import java.util.ArrayList; import java.util.List; -import org.json.JSONObject; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; @@ -48,21 +45,15 @@ import com.google.refine.browsing.FilteredRows; import com.google.refine.browsing.RowVisitor; import com.google.refine.history.Change; import com.google.refine.history.HistoryEntry; -import com.google.refine.model.AbstractOperation; import com.google.refine.model.Project; import com.google.refine.model.Row; import com.google.refine.model.changes.MassChange; import com.google.refine.model.changes.RowStarChange; import com.google.refine.operations.EngineDependentOperation; -import com.google.refine.util.ParsingUtilities; public class RowStarOperation extends EngineDependentOperation { final protected boolean _starred; - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException { - return ParsingUtilities.mapper.readValue(obj.toString(), RowStarOperation.class); - } - @JsonCreator public RowStarOperation( @JsonProperty("engineConfig") diff --git a/main/tests/server/src/com/google/refine/tests/model/changes/DataExtensionChangeTest.java b/main/tests/server/src/com/google/refine/tests/model/changes/DataExtensionChangeTest.java index c3608622b..689b050c2 100644 --- a/main/tests/server/src/com/google/refine/tests/model/changes/DataExtensionChangeTest.java +++ b/main/tests/server/src/com/google/refine/tests/model/changes/DataExtensionChangeTest.java @@ -1,18 +1,11 @@ package com.google.refine.tests.model.changes; -import com.google.refine.model.ModelException; -import com.google.refine.model.Project; -import com.google.refine.model.changes.DataExtensionChange; -import com.google.refine.model.changes.MassChange; - import static org.junit.Assert.assertEquals; -import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.LineNumberReader; -import java.io.Reader; import org.slf4j.LoggerFactory; import org.testng.annotations.BeforeMethod; @@ -20,6 +13,9 @@ import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import com.google.refine.history.Change; +import com.google.refine.model.ModelException; +import com.google.refine.model.Project; +import com.google.refine.model.changes.DataExtensionChange; import com.google.refine.tests.RefineTest; import com.google.refine.util.Pool; diff --git a/main/tests/server/src/com/google/refine/tests/operations/cell/BlankDownTests.java b/main/tests/server/src/com/google/refine/tests/operations/cell/BlankDownTests.java index 1e7669b29..06e3d58a7 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/cell/BlankDownTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/cell/BlankDownTests.java @@ -24,7 +24,7 @@ import com.google.refine.operations.cell.FillDownOperation; import com.google.refine.process.Process; import com.google.refine.tests.RefineTest; import com.google.refine.tests.util.TestUtils; -import com.google.refine.util.Pool; +import com.google.refine.util.ParsingUtilities; public class BlankDownTests extends RefineTest { @@ -56,7 +56,7 @@ public class BlankDownTests extends RefineTest { + "\"description\":\"Blank down cells in column my column\"," + "\"engineConfig\":{\"mode\":\"record-based\",\"facets\":[]}," + "\"columnName\":\"my column\"}"; - AbstractOperation op = BlankDownOperation.reconstruct(project, new JSONObject(json)); + AbstractOperation op = ParsingUtilities.mapper.readValue(json, BlankDownOperation.class); TestUtils.isSerializedTo(op, json); } @@ -107,7 +107,6 @@ public class BlankDownTests extends RefineTest { "second"); Process process = op.createProcess(project, new Properties()); process.performImmediate(); - //project.saveToOutputStream(System.out, new Pool()); Assert.assertEquals("c", project.rows.get(0).cells.get(3).value); Assert.assertNull(project.rows.get(1).cells.get(3)); diff --git a/main/tests/server/src/com/google/refine/tests/operations/cell/FillDownTests.java b/main/tests/server/src/com/google/refine/tests/operations/cell/FillDownTests.java index eb15e693d..73d82f2e7 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/cell/FillDownTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/cell/FillDownTests.java @@ -20,9 +20,10 @@ import com.google.refine.model.Project; import com.google.refine.model.Row; import com.google.refine.operations.OperationRegistry; import com.google.refine.operations.cell.FillDownOperation; +import com.google.refine.process.Process; import com.google.refine.tests.RefineTest; import com.google.refine.tests.util.TestUtils; -import com.google.refine.process.Process; +import com.google.refine.util.ParsingUtilities; public class FillDownTests extends RefineTest { @@ -54,7 +55,7 @@ public class FillDownTests extends RefineTest { + "\"description\":\"Fill down cells in column my key\"," + "\"engineConfig\":{\"mode\":\"record-based\",\"facets\":[]}," + "\"columnName\":\"my key\"}"; - TestUtils.isSerializedTo(FillDownOperation.reconstruct(project, new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, FillDownOperation.class), json); } @Test diff --git a/main/tests/server/src/com/google/refine/tests/operations/cell/JoinMultiValuedCellsTests.java b/main/tests/server/src/com/google/refine/tests/operations/cell/JoinMultiValuedCellsTests.java index c1a87aec7..9e84f3c37 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/cell/JoinMultiValuedCellsTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/cell/JoinMultiValuedCellsTests.java @@ -36,7 +36,6 @@ package com.google.refine.tests.operations.cell; import java.util.Properties; import org.json.JSONException; -import org.json.JSONObject; import org.slf4j.LoggerFactory; import org.testng.Assert; import org.testng.annotations.BeforeMethod; @@ -51,6 +50,7 @@ import com.google.refine.operations.cell.MultiValuedCellJoinOperation; import com.google.refine.process.Process; import com.google.refine.tests.RefineTest; import com.google.refine.tests.util.TestUtils; +import com.google.refine.util.ParsingUtilities; public class JoinMultiValuedCellsTests extends RefineTest { @@ -85,7 +85,7 @@ public class JoinMultiValuedCellsTests extends RefineTest { + "\"columnName\":\"value column\"," + "\"keyColumnName\":\"key column\"," + "\"separator\":\",\"}"; - TestUtils.isSerializedTo(MultiValuedCellJoinOperation.reconstruct(project, new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, MultiValuedCellJoinOperation.class), json); } diff --git a/main/tests/server/src/com/google/refine/tests/operations/cell/KeyValueColumnizeTests.java b/main/tests/server/src/com/google/refine/tests/operations/cell/KeyValueColumnizeTests.java index 38567d48f..0ebeadb82 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/cell/KeyValueColumnizeTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/cell/KeyValueColumnizeTests.java @@ -67,6 +67,7 @@ import com.google.refine.process.Process; import com.google.refine.tests.RefineServletStub; import com.google.refine.tests.RefineTest; import com.google.refine.tests.util.TestUtils; +import com.google.refine.util.ParsingUtilities; public class KeyValueColumnizeTests extends RefineTest { @@ -119,14 +120,14 @@ public class KeyValueColumnizeTests extends RefineTest { + "\"keyColumnName\":\"key column\"," + "\"valueColumnName\":\"value column\"," + "\"noteColumnName\":null}"; - TestUtils.isSerializedTo(KeyValueColumnizeOperation.reconstruct(project, new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, KeyValueColumnizeOperation.class), json); String jsonFull = "{\"op\":\"core/key-value-columnize\"," + "\"description\":\"Columnize by key column key column and value column value column with note column note column\"," + "\"keyColumnName\":\"key column\"," + "\"valueColumnName\":\"value column\"," + "\"noteColumnName\":\"note column\"}"; - TestUtils.isSerializedTo(KeyValueColumnizeOperation.reconstruct(project, new JSONObject(jsonFull)), jsonFull); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(jsonFull, KeyValueColumnizeOperation.class), jsonFull); } /** 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 da41c8c02..01497bd5d 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 @@ -3,15 +3,12 @@ package com.google.refine.tests.operations.cell; import java.util.List; import org.json.JSONException; -import org.json.JSONObject; import org.testng.Assert; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import static org.mockito.Mockito.mock; import com.fasterxml.jackson.core.type.TypeReference; -import com.google.refine.model.Project; import com.google.refine.operations.OperationRegistry; import com.google.refine.operations.cell.MassEditOperation; import com.google.refine.operations.cell.MassEditOperation.Edit; @@ -31,13 +28,12 @@ public class MassOperationTests extends RefineTest { @Test public void serializeMassEditOperation() throws JSONException, Exception { - Project project = mock(Project.class); String json = "{\"op\":\"core/mass-edit\"," + "\"description\":\"Mass edit cells in column my column\"," + "\"engineConfig\":{\"mode\":\"record-based\",\"facets\":[]}," + "\"columnName\":\"my column\",\"expression\":\"value\"," + "\"edits\":[{\"fromBlank\":false,\"fromError\":false,\"from\":[\"String\"],\"to\":\"newString\"}]}"; - TestUtils.isSerializedTo(MassEditOperation.reconstruct(project, new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, MassEditOperation.class), json); } @Test diff --git a/main/tests/server/src/com/google/refine/tests/operations/cell/SplitMultiValuedCellsTests.java b/main/tests/server/src/com/google/refine/tests/operations/cell/SplitMultiValuedCellsTests.java index da372dff0..a74aebdb0 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/cell/SplitMultiValuedCellsTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/cell/SplitMultiValuedCellsTests.java @@ -37,7 +37,6 @@ package com.google.refine.tests.operations.cell; import java.util.Properties; import org.json.JSONException; -import org.json.JSONObject; import org.slf4j.LoggerFactory; import org.testng.Assert; import org.testng.annotations.BeforeMethod; @@ -51,6 +50,7 @@ import com.google.refine.operations.cell.MultiValuedCellSplitOperation; import com.google.refine.process.Process; import com.google.refine.tests.RefineTest; import com.google.refine.tests.util.TestUtils; +import com.google.refine.util.ParsingUtilities; public class SplitMultiValuedCellsTests extends RefineTest { @@ -80,7 +80,7 @@ public class SplitMultiValuedCellsTests extends RefineTest { + "\"mode\":\"separator\"," + "\"separator\":\":\"," + "\"regex\":false}"; - TestUtils.isSerializedTo(MultiValuedCellSplitOperation.reconstruct(project, new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, MultiValuedCellSplitOperation.class), json); } @Test @@ -91,7 +91,7 @@ public class SplitMultiValuedCellsTests extends RefineTest { + "\"keyColumnName\":\"Key\"," + "\"mode\":\"lengths\"," + "\"fieldLengths\":[1,1]}"; - TestUtils.isSerializedTo(MultiValuedCellSplitOperation.reconstruct(project, new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, MultiValuedCellSplitOperation.class), json); } /** diff --git a/main/tests/server/src/com/google/refine/tests/operations/cell/TransposeTests.java b/main/tests/server/src/com/google/refine/tests/operations/cell/TransposeTests.java index 3c08cb0b3..b58977510 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/cell/TransposeTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/cell/TransposeTests.java @@ -33,19 +33,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package com.google.refine.tests.operations.cell; -import static org.mockito.Mockito.mock; - import org.json.JSONException; -import org.json.JSONObject; import org.slf4j.LoggerFactory; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; -import com.google.refine.model.Project; import com.google.refine.operations.OperationRegistry; import com.google.refine.operations.cell.TransposeRowsIntoColumnsOperation; import com.google.refine.tests.RefineTest; import com.google.refine.tests.util.TestUtils; +import com.google.refine.util.ParsingUtilities; public class TransposeTests extends RefineTest { @@ -62,8 +59,7 @@ public class TransposeTests extends RefineTest { + "\"description\":\"Transpose every 3 cells in column start column into separate columns\"," + "\"columnName\":\"start column\"," + "\"rowCount\":3}"; - Project project = mock(Project.class); - TestUtils.isSerializedTo(TransposeRowsIntoColumnsOperation.reconstruct(project , new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, TransposeRowsIntoColumnsOperation.class), json); } } diff --git a/main/tests/server/src/com/google/refine/tests/operations/column/ColumnAdditionByFetchingURLsOperationTests.java b/main/tests/server/src/com/google/refine/tests/operations/column/ColumnAdditionByFetchingURLsOperationTests.java index 4697cf37a..41101a5ff 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/column/ColumnAdditionByFetchingURLsOperationTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/column/ColumnAdditionByFetchingURLsOperationTests.java @@ -63,6 +63,7 @@ import com.google.refine.process.Process; import com.google.refine.process.ProcessManager; import com.google.refine.tests.RefineTest; import com.google.refine.tests.util.TestUtils; +import com.google.refine.util.ParsingUtilities; public class ColumnAdditionByFetchingURLsOperationTests extends RefineTest { @@ -125,12 +126,12 @@ public class ColumnAdditionByFetchingURLsOperationTests extends RefineTest { @Test public void serializeColumnAdditionByFetchingURLsOperation() throws JSONException, Exception { - TestUtils.isSerializedTo(ColumnAdditionByFetchingURLsOperation.reconstruct(project, new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ColumnAdditionByFetchingURLsOperation.class), json); } @Test public void serializeUrlFetchingProcess() throws Exception { - AbstractOperation op = ColumnAdditionByFetchingURLsOperation.reconstruct(project, new JSONObject(json)); + AbstractOperation op = ParsingUtilities.mapper.readValue(json, ColumnAdditionByFetchingURLsOperation.class); Process process = op.createProcess(project, new Properties()); TestUtils.isSerializedTo(process, String.format(processJson, process.hashCode())); } diff --git a/main/tests/server/src/com/google/refine/tests/operations/column/ColumnAdditionOperationTests.java b/main/tests/server/src/com/google/refine/tests/operations/column/ColumnAdditionOperationTests.java index d150adafb..8bb492edd 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/column/ColumnAdditionOperationTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/column/ColumnAdditionOperationTests.java @@ -1,17 +1,14 @@ package com.google.refine.tests.operations.column; -import static org.mockito.Mockito.mock; - import org.json.JSONException; -import org.json.JSONObject; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import com.google.refine.model.Project; import com.google.refine.operations.OperationRegistry; import com.google.refine.operations.column.ColumnAdditionOperation; import com.google.refine.tests.RefineTest; import com.google.refine.tests.util.TestUtils; +import com.google.refine.util.ParsingUtilities; public class ColumnAdditionOperationTests extends RefineTest { @@ -28,7 +25,6 @@ public class ColumnAdditionOperationTests extends RefineTest { + " \"expression\":\"grel:value.parseJson()[\\\"employment-summary\\\"].join('###')\"," + " \"onError\":\"set-to-blank\"" + "}"; - Project project = mock(Project.class); - TestUtils.isSerializedTo(ColumnAdditionOperation.reconstruct(project, new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ColumnAdditionOperation.class), json); } } diff --git a/main/tests/server/src/com/google/refine/tests/operations/column/ColumnMoveOperationTests.java b/main/tests/server/src/com/google/refine/tests/operations/column/ColumnMoveOperationTests.java index 61d7aef91..a0ef81029 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/column/ColumnMoveOperationTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/column/ColumnMoveOperationTests.java @@ -1,17 +1,14 @@ package com.google.refine.tests.operations.column; -import static org.mockito.Mockito.mock; - import org.json.JSONException; -import org.json.JSONObject; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import com.google.refine.model.Project; import com.google.refine.operations.OperationRegistry; import com.google.refine.operations.column.ColumnMoveOperation; import com.google.refine.tests.RefineTest; import com.google.refine.tests.util.TestUtils; +import com.google.refine.util.ParsingUtilities; public class ColumnMoveOperationTests extends RefineTest { @@ -26,7 +23,6 @@ public class ColumnMoveOperationTests extends RefineTest { + "\"description\":\"Move column my column to position 3\"," + "\"columnName\":\"my column\"," + "\"index\":3}"; - Project project = mock(Project.class); - TestUtils.isSerializedTo(ColumnMoveOperation.reconstruct(project , new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ColumnMoveOperation.class), json); } } diff --git a/main/tests/server/src/com/google/refine/tests/operations/column/ColumnRemovalOperationTests.java b/main/tests/server/src/com/google/refine/tests/operations/column/ColumnRemovalOperationTests.java index 36a87e417..3caf1f463 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/column/ColumnRemovalOperationTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/column/ColumnRemovalOperationTests.java @@ -1,17 +1,14 @@ package com.google.refine.tests.operations.column; -import static org.mockito.Mockito.mock; - import org.json.JSONException; -import org.json.JSONObject; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import com.google.refine.model.Project; import com.google.refine.operations.OperationRegistry; import com.google.refine.operations.column.ColumnRemovalOperation; import com.google.refine.tests.RefineTest; import com.google.refine.tests.util.TestUtils; +import com.google.refine.util.ParsingUtilities; public class ColumnRemovalOperationTests extends RefineTest { @@ -26,7 +23,6 @@ public class ColumnRemovalOperationTests extends RefineTest { String json = "{\"op\":\"core/column-removal\"," + "\"description\":\"Remove column my column\"," + "\"columnName\":\"my column\"}"; - Project project = mock(Project.class); - TestUtils.isSerializedTo(ColumnRemovalOperation.reconstruct(project, new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ColumnRemovalOperation.class), json); } } 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 917d6fdbc..b75a8ebb5 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,13 +1,10 @@ package com.google.refine.tests.operations.column; -import static org.mockito.Mockito.mock; - import org.json.JSONException; import org.json.JSONObject; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import com.google.refine.model.Project; import com.google.refine.operations.OperationRegistry; import com.google.refine.operations.column.ColumnRenameOperation; import com.google.refine.tests.RefineTest; @@ -27,7 +24,10 @@ public class ColumnRenameOperationTests extends RefineTest { + "\"description\":\"Rename column old name to new name\"," + "\"oldColumnName\":\"old name\"," + "\"newColumnName\":\"new name\"}"; - Project project = mock(Project.class); - TestUtils.isSerializedTo(ColumnRenameOperation.reconstruct(project, new JSONObject(json)), json); + JSONObject obj = new JSONObject(json); + TestUtils.isSerializedTo(new ColumnRenameOperation( + obj.getString("oldColumnName"), + obj.getString("newColumnName") + ), json); } } diff --git a/main/tests/server/src/com/google/refine/tests/operations/column/ColumnSplitOperationTests.java b/main/tests/server/src/com/google/refine/tests/operations/column/ColumnSplitOperationTests.java index 57949edd9..1a44a8251 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/column/ColumnSplitOperationTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/column/ColumnSplitOperationTests.java @@ -1,17 +1,14 @@ package com.google.refine.tests.operations.column; -import static org.mockito.Mockito.mock; - import org.json.JSONException; -import org.json.JSONObject; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import com.google.refine.model.Project; import com.google.refine.operations.OperationRegistry; import com.google.refine.operations.column.ColumnSplitOperation; import com.google.refine.tests.RefineTest; import com.google.refine.tests.util.TestUtils; +import com.google.refine.util.ParsingUtilities; public class ColumnSplitOperationTests extends RefineTest { @BeforeSuite @@ -36,8 +33,7 @@ public class ColumnSplitOperationTests extends RefineTest { " \"regex\": false,\n" + " \"maxColumns\": 0\n" + " }"; - Project project = mock(Project.class); - TestUtils.isSerializedTo(ColumnSplitOperation.reconstruct(project, new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ColumnSplitOperation.class), json); } @Test @@ -55,7 +51,6 @@ public class ColumnSplitOperationTests extends RefineTest { " \"mode\": \"lengths\",\n" + " \"fieldLengths\": [1,1]\n" + " }"; - Project project = mock(Project.class); - TestUtils.isSerializedTo(ColumnSplitOperation.reconstruct(project, new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ColumnSplitOperation.class), json); } } diff --git a/main/tests/server/src/com/google/refine/tests/operations/recon/ExtendDataOperationTests.java b/main/tests/server/src/com/google/refine/tests/operations/recon/ExtendDataOperationTests.java index 17cdb98ba..8038c94d2 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/recon/ExtendDataOperationTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/recon/ExtendDataOperationTests.java @@ -69,6 +69,7 @@ import com.google.refine.process.Process; import com.google.refine.process.ProcessManager; import com.google.refine.tests.RefineTest; import com.google.refine.tests.util.TestUtils; +import com.google.refine.util.ParsingUtilities; public class ExtendDataOperationTests extends RefineTest { @@ -165,12 +166,12 @@ public class ExtendDataOperationTests extends RefineTest { @Test public void serializeExtendDataOperation() throws JSONException, Exception { - TestUtils.isSerializedTo(ExtendDataOperation.reconstruct(project, new JSONObject(operationJson)), operationJson); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(operationJson, ExtendDataOperation.class), operationJson); } @Test public void serializeExtendDataProcess() throws JSONException, Exception { - Process p = ExtendDataOperation.reconstruct(project, new JSONObject(operationJson)) + Process p = ParsingUtilities.mapper.readValue(operationJson, ExtendDataOperation.class) .createProcess(project, new Properties()); TestUtils.isSerializedTo(p, String.format(processJson, p.hashCode())); } diff --git a/main/tests/server/src/com/google/refine/tests/operations/recon/ReconClearSimilarCellsOperationTests.java b/main/tests/server/src/com/google/refine/tests/operations/recon/ReconClearSimilarCellsOperationTests.java index bddfb4fed..6ca86e8c2 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/recon/ReconClearSimilarCellsOperationTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/recon/ReconClearSimilarCellsOperationTests.java @@ -1,15 +1,12 @@ package com.google.refine.tests.operations.recon; -import static org.mockito.Mockito.mock; - -import org.json.JSONObject; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import com.google.refine.model.Project; import com.google.refine.operations.OperationRegistry; import com.google.refine.operations.recon.ReconClearSimilarCellsOperation; import com.google.refine.tests.RefineTest; import com.google.refine.tests.util.TestUtils; +import com.google.refine.util.ParsingUtilities; public class ReconClearSimilarCellsOperationTests extends RefineTest { @BeforeSuite @@ -24,7 +21,6 @@ public class ReconClearSimilarCellsOperationTests extends RefineTest { + "\"engineConfig\":{\"mode\":\"row-based\",\"facets\":[]}," + "\"columnName\":\"my column\"," + "\"similarValue\":\"some value\"}"; - Project project = mock(Project.class); - TestUtils.isSerializedTo(ReconClearSimilarCellsOperation.reconstruct(project, new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ReconClearSimilarCellsOperation.class), json); } } diff --git a/main/tests/server/src/com/google/refine/tests/operations/recon/ReconCopyAcrossColumnsOperationTests.java b/main/tests/server/src/com/google/refine/tests/operations/recon/ReconCopyAcrossColumnsOperationTests.java index 23b38e248..8fe76e10d 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/recon/ReconCopyAcrossColumnsOperationTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/recon/ReconCopyAcrossColumnsOperationTests.java @@ -1,15 +1,12 @@ package com.google.refine.tests.operations.recon; -import static org.mockito.Mockito.mock; - -import org.json.JSONObject; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import com.google.refine.model.Project; import com.google.refine.operations.OperationRegistry; import com.google.refine.operations.recon.ReconCopyAcrossColumnsOperation; import com.google.refine.tests.RefineTest; import com.google.refine.tests.util.TestUtils; +import com.google.refine.util.ParsingUtilities; public class ReconCopyAcrossColumnsOperationTests extends RefineTest { @BeforeSuite @@ -26,7 +23,6 @@ public class ReconCopyAcrossColumnsOperationTests extends RefineTest { + "\"toColumnNames\":[\"first\",\"second\"]," + "\"judgments\":[\"matched\",\"new\"]," + "\"applyToJudgedCells\":true}"; - Project project = mock(Project.class); - TestUtils.isSerializedTo(ReconCopyAcrossColumnsOperation.reconstruct(project, new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ReconCopyAcrossColumnsOperation.class), json); } } diff --git a/main/tests/server/src/com/google/refine/tests/operations/recon/ReconDiscardJudgmentsOperationTests.java b/main/tests/server/src/com/google/refine/tests/operations/recon/ReconDiscardJudgmentsOperationTests.java index ce44bb9cd..c778ae5c3 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/recon/ReconDiscardJudgmentsOperationTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/recon/ReconDiscardJudgmentsOperationTests.java @@ -1,15 +1,12 @@ package com.google.refine.tests.operations.recon; -import static org.mockito.Mockito.mock; - -import org.json.JSONObject; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import com.google.refine.model.Project; import com.google.refine.operations.OperationRegistry; import com.google.refine.operations.recon.ReconDiscardJudgmentsOperation; import com.google.refine.tests.RefineTest; import com.google.refine.tests.util.TestUtils; +import com.google.refine.util.ParsingUtilities; public class ReconDiscardJudgmentsOperationTests extends RefineTest { @BeforeSuite @@ -29,7 +26,6 @@ public class ReconDiscardJudgmentsOperationTests extends RefineTest { " \"columnName\": \"researcher\",\n" + " \"clearData\": true\n" + " }"; - Project project = mock(Project.class); - TestUtils.isSerializedTo(ReconDiscardJudgmentsOperation.reconstruct(project, new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ReconDiscardJudgmentsOperation.class), json); } } diff --git a/main/tests/server/src/com/google/refine/tests/operations/recon/ReconJudgeSimilarCellsOperationTests.java b/main/tests/server/src/com/google/refine/tests/operations/recon/ReconJudgeSimilarCellsOperationTests.java index 76cf1e39e..ee31342fd 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/recon/ReconJudgeSimilarCellsOperationTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/recon/ReconJudgeSimilarCellsOperationTests.java @@ -1,14 +1,12 @@ package com.google.refine.tests.operations.recon; -import org.json.JSONObject; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import static org.mockito.Mockito.mock; -import com.google.refine.model.Project; import com.google.refine.operations.OperationRegistry; import com.google.refine.operations.recon.ReconJudgeSimilarCellsOperation; import com.google.refine.tests.RefineTest; import com.google.refine.tests.util.TestUtils; +import com.google.refine.util.ParsingUtilities; public class ReconJudgeSimilarCellsOperationTests extends RefineTest { @BeforeSuite @@ -26,6 +24,6 @@ public class ReconJudgeSimilarCellsOperationTests extends RefineTest { + "\"judgment\":\"matched\"," + "\"match\":{\"id\":\"Q7884717\",\"name\":\"Unicef Indonesia\",\"score\":71.42857142857143,\"types\":[\"Q43229\"]}," + "\"shareNewTopics\":false}"; - TestUtils.isSerializedTo(ReconJudgeSimilarCellsOperation.reconstruct(mock(Project.class), new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ReconJudgeSimilarCellsOperation.class), json); } } diff --git a/main/tests/server/src/com/google/refine/tests/operations/recon/ReconJudgeSimilarCellsTests.java b/main/tests/server/src/com/google/refine/tests/operations/recon/ReconJudgeSimilarCellsTests.java index 8587fa417..4f5c8d263 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/recon/ReconJudgeSimilarCellsTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/recon/ReconJudgeSimilarCellsTests.java @@ -2,7 +2,6 @@ package com.google.refine.tests.operations.recon; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; -import static org.mockito.Mockito.mock; import java.io.IOException; import java.util.Collections; @@ -26,6 +25,7 @@ import com.google.refine.operations.recon.ReconJudgeSimilarCellsOperation; import com.google.refine.process.Process; import com.google.refine.tests.RefineTest; import com.google.refine.tests.util.TestUtils; +import com.google.refine.util.ParsingUtilities; public class ReconJudgeSimilarCellsTests extends RefineTest { @@ -47,7 +47,7 @@ public class ReconJudgeSimilarCellsTests extends RefineTest { + "\"similarValue\":\"foo\"," + "\"judgment\":\"new\"," + "\"shareNewTopics\":true}"; - TestUtils.isSerializedTo(ReconJudgeSimilarCellsOperation.reconstruct(mock(Project.class), new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ReconJudgeSimilarCellsOperation.class), json); } @Test @@ -61,7 +61,7 @@ public class ReconJudgeSimilarCellsTests extends RefineTest { + "\"match\":{\"id\":\"Q42\",\"name\":\"Douglas Adams\",\"types\":[\"Q5\"],\"score\":85}," + "\"shareNewTopics\":false" + "}"; - TestUtils.isSerializedTo(ReconJudgeSimilarCellsOperation.reconstruct(mock(Project.class), new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ReconJudgeSimilarCellsOperation.class), json); } @Test diff --git a/main/tests/server/src/com/google/refine/tests/operations/recon/ReconMarkNewTopicsOperationTests.java b/main/tests/server/src/com/google/refine/tests/operations/recon/ReconMarkNewTopicsOperationTests.java index a63dea505..655dbbbfe 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/recon/ReconMarkNewTopicsOperationTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/recon/ReconMarkNewTopicsOperationTests.java @@ -1,15 +1,12 @@ package com.google.refine.tests.operations.recon; -import static org.mockito.Mockito.mock; - -import org.json.JSONObject; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import com.google.refine.model.Project; import com.google.refine.operations.OperationRegistry; import com.google.refine.operations.recon.ReconMarkNewTopicsOperation; import com.google.refine.tests.RefineTest; import com.google.refine.tests.util.TestUtils; +import com.google.refine.util.ParsingUtilities; public class ReconMarkNewTopicsOperationTests extends RefineTest { @BeforeSuite @@ -26,7 +23,6 @@ public class ReconMarkNewTopicsOperationTests extends RefineTest { + "\"shareNewTopics\":true," + "\"description\":\"Mark to create new items for cells in column my column, one item for each group of similar cells\"" + "}"; - Project project = mock(Project.class); - TestUtils.isSerializedTo(ReconMarkNewTopicsOperation.reconstruct(project, new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ReconMarkNewTopicsOperation.class), json); } } diff --git a/main/tests/server/src/com/google/refine/tests/operations/recon/ReconMatchBestCandidatesOperationTests.java b/main/tests/server/src/com/google/refine/tests/operations/recon/ReconMatchBestCandidatesOperationTests.java index 63274e487..9213238b5 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/recon/ReconMatchBestCandidatesOperationTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/recon/ReconMatchBestCandidatesOperationTests.java @@ -1,15 +1,12 @@ package com.google.refine.tests.operations.recon; -import static org.mockito.Mockito.mock; - -import org.json.JSONObject; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import com.google.refine.model.Project; import com.google.refine.operations.OperationRegistry; import com.google.refine.operations.recon.ReconMatchBestCandidatesOperation; import com.google.refine.tests.RefineTest; import com.google.refine.tests.util.TestUtils; +import com.google.refine.util.ParsingUtilities; public class ReconMatchBestCandidatesOperationTests extends RefineTest { @BeforeSuite @@ -28,7 +25,6 @@ public class ReconMatchBestCandidatesOperationTests extends RefineTest { + "]}," + "\"columnName\":\"organization_name\"" + "}"; - Project project = mock(Project.class); - TestUtils.isSerializedTo(ReconMatchBestCandidatesOperation.reconstruct(project, new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ReconMatchBestCandidatesOperation.class), json); } } diff --git a/main/tests/server/src/com/google/refine/tests/operations/recon/ReconMatchSpecificTopicOperationTests.java b/main/tests/server/src/com/google/refine/tests/operations/recon/ReconMatchSpecificTopicOperationTests.java index 1e1c51386..145e5b8c7 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/recon/ReconMatchSpecificTopicOperationTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/recon/ReconMatchSpecificTopicOperationTests.java @@ -1,15 +1,12 @@ package com.google.refine.tests.operations.recon; -import static org.mockito.Mockito.mock; - -import org.json.JSONObject; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import com.google.refine.model.Project; import com.google.refine.operations.OperationRegistry; import com.google.refine.operations.recon.ReconMatchSpecificTopicOperation; import com.google.refine.tests.RefineTest; import com.google.refine.tests.util.TestUtils; +import com.google.refine.util.ParsingUtilities; public class ReconMatchSpecificTopicOperationTests extends RefineTest { @BeforeSuite @@ -37,7 +34,6 @@ public class ReconMatchSpecificTopicOperationTests extends RefineTest { " \"identifierSpace\": \"http://www.wikidata.org/entity/\",\n" + " \"schemaSpace\": \"http://www.wikidata.org/prop/direct/\"\n" + " }"; - Project project = mock(Project.class); - TestUtils.isSerializedTo(ReconMatchSpecificTopicOperation.reconstruct(project, new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ReconMatchSpecificTopicOperation.class), json); } } diff --git a/main/tests/server/src/com/google/refine/tests/operations/recon/ReconOperationTests.java b/main/tests/server/src/com/google/refine/tests/operations/recon/ReconOperationTests.java index 1fed8577f..e5206cd17 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/recon/ReconOperationTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/recon/ReconOperationTests.java @@ -5,7 +5,6 @@ import static org.mockito.Mockito.mock; import java.util.Properties; import org.json.JSONException; -import org.json.JSONObject; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; @@ -16,6 +15,7 @@ import com.google.refine.operations.OperationRegistry; import com.google.refine.operations.recon.ReconOperation; import com.google.refine.tests.RefineTest; import com.google.refine.tests.util.TestUtils; +import com.google.refine.util.ParsingUtilities; public class ReconOperationTests extends RefineTest { @@ -74,12 +74,12 @@ public class ReconOperationTests extends RefineTest { @Test public void serializeReconOperation() throws JSONException, Exception { - TestUtils.isSerializedTo(ReconOperation.reconstruct(project, new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ReconOperation.class), json); } @Test public void serializeReconProcess() throws JSONException, Exception { - ReconOperation op = ReconOperation.reconstruct(project, new JSONObject(json)); + ReconOperation op = ParsingUtilities.mapper.readValue(json, ReconOperation.class); com.google.refine.process.Process process = op.createProcess(project, new Properties()); TestUtils.isSerializedTo(process, String.format(processJson, process.hashCode())); } diff --git a/main/tests/server/src/com/google/refine/tests/operations/recon/ReconUseValuesAsIdsOperationTests.java b/main/tests/server/src/com/google/refine/tests/operations/recon/ReconUseValuesAsIdsOperationTests.java index 3a6d94036..249c4e967 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/recon/ReconUseValuesAsIdsOperationTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/recon/ReconUseValuesAsIdsOperationTests.java @@ -6,7 +6,6 @@ import static org.testng.Assert.assertNull; import java.util.Properties; import org.json.JSONException; -import org.json.JSONObject; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; @@ -16,6 +15,7 @@ import com.google.refine.operations.OperationRegistry; import com.google.refine.operations.recon.ReconUseValuesAsIdentifiersOperation; import com.google.refine.tests.RefineTest; import com.google.refine.tests.util.TestUtils; +import com.google.refine.util.ParsingUtilities; public class ReconUseValuesAsIdsOperationTests extends RefineTest { @@ -36,7 +36,7 @@ public class ReconUseValuesAsIdsOperationTests extends RefineTest { @Test public void serializeReconUseValuesAsIdentifiersOperation() throws JSONException, Exception { - TestUtils.isSerializedTo(ReconUseValuesAsIdentifiersOperation.reconstruct(new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ReconUseValuesAsIdentifiersOperation.class), json); } @Test @@ -45,7 +45,7 @@ public class ReconUseValuesAsIdsOperationTests extends RefineTest { + "Q343,hello\n" + ",world\n" + "Q31,test"); - ReconUseValuesAsIdentifiersOperation op = ReconUseValuesAsIdentifiersOperation.reconstruct(new JSONObject(json)); + ReconUseValuesAsIdentifiersOperation op = ParsingUtilities.mapper.readValue(json, ReconUseValuesAsIdentifiersOperation.class); op.createProcess(project, new Properties()).performImmediate(); assertEquals("Q343", project.rows.get(0).cells.get(0).recon.match.id); diff --git a/main/tests/server/src/com/google/refine/tests/operations/row/DenormalizeOperationTests.java b/main/tests/server/src/com/google/refine/tests/operations/row/DenormalizeOperationTests.java index d5a344fe2..7e8457a08 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/row/DenormalizeOperationTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/row/DenormalizeOperationTests.java @@ -3,7 +3,6 @@ package com.google.refine.tests.operations.row; import static org.mockito.Mockito.mock; import org.json.JSONException; -import org.json.JSONObject; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; @@ -26,6 +25,6 @@ public class DenormalizeOperationTests extends RefineTest { String json = "{" + "\"op\":\"core/denormalize\"," + "\"description\":\"Denormalize\"}"; - TestUtils.isSerializedTo(DenormalizeOperation.reconstruct(project, new JSONObject(json)), json); + TestUtils.isSerializedTo(new DenormalizeOperation(), json); } } diff --git a/main/tests/server/src/com/google/refine/tests/operations/row/RowFlagOperationTests.java b/main/tests/server/src/com/google/refine/tests/operations/row/RowFlagOperationTests.java index e7c625706..d8afecad1 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/row/RowFlagOperationTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/row/RowFlagOperationTests.java @@ -3,7 +3,6 @@ package com.google.refine.tests.operations.row; import static org.mockito.Mockito.mock; import org.json.JSONException; -import org.json.JSONObject; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; @@ -12,6 +11,7 @@ import com.google.refine.operations.OperationRegistry; import com.google.refine.operations.row.RowFlagOperation; import com.google.refine.tests.RefineTest; import com.google.refine.tests.util.TestUtils; +import com.google.refine.util.ParsingUtilities; public class RowFlagOperationTests extends RefineTest { @BeforeSuite @@ -27,6 +27,6 @@ public class RowFlagOperationTests extends RefineTest { + "\"description\":\"Flag rows\"," + "\"flagged\":true," + "\"engineConfig\":{\"mode\":\"row-based\",\"facets\":[]}}"; - TestUtils.isSerializedTo(RowFlagOperation.reconstruct(project, new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, RowFlagOperation.class), json); } } diff --git a/main/tests/server/src/com/google/refine/tests/operations/row/RowRemovalOperationTests.java b/main/tests/server/src/com/google/refine/tests/operations/row/RowRemovalOperationTests.java index 4be80efd3..db168c626 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/row/RowRemovalOperationTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/row/RowRemovalOperationTests.java @@ -5,7 +5,6 @@ import static org.mockito.Mockito.mock; import java.io.IOException; import org.json.JSONException; -import org.json.JSONObject; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; @@ -14,6 +13,7 @@ import com.google.refine.operations.OperationRegistry; import com.google.refine.operations.row.RowRemovalOperation; import com.google.refine.tests.RefineTest; import com.google.refine.tests.util.TestUtils; +import com.google.refine.util.ParsingUtilities; public class RowRemovalOperationTests extends RefineTest { @BeforeSuite @@ -28,6 +28,6 @@ public class RowRemovalOperationTests extends RefineTest { + "\"op\":\"core/row-removal\"," + "\"description\":\"Remove rows\"," + "\"engineConfig\":{\"mode\":\"row-based\",\"facets\":[]}}"; - TestUtils.isSerializedTo(RowRemovalOperation.reconstruct(project, new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, RowRemovalOperation.class), json); } } diff --git a/main/tests/server/src/com/google/refine/tests/operations/row/RowReorderOperationTests.java b/main/tests/server/src/com/google/refine/tests/operations/row/RowReorderOperationTests.java index 08b91927b..adb1160bd 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/row/RowReorderOperationTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/row/RowReorderOperationTests.java @@ -23,6 +23,7 @@ import com.google.refine.process.Process; import com.google.refine.sorting.SortingConfig; import com.google.refine.tests.RefineTest; import com.google.refine.tests.util.TestUtils; +import com.google.refine.util.ParsingUtilities; public class RowReorderOperationTests extends RefineTest { @@ -85,7 +86,7 @@ public class RowReorderOperationTests extends RefineTest { " ]\n" + " }\n" + " }"; - TestUtils.isSerializedTo(RowReorderOperation.reconstruct(project, new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, RowReorderOperation.class), json); } } diff --git a/main/tests/server/src/com/google/refine/tests/operations/row/RowStarOperationTests.java b/main/tests/server/src/com/google/refine/tests/operations/row/RowStarOperationTests.java index 84e829f69..924c50ff4 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/row/RowStarOperationTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/row/RowStarOperationTests.java @@ -3,14 +3,15 @@ package com.google.refine.tests.operations.row; import static org.mockito.Mockito.mock; import org.json.JSONException; -import org.json.JSONObject; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; + import com.google.refine.model.Project; import com.google.refine.operations.OperationRegistry; import com.google.refine.operations.row.RowStarOperation; import com.google.refine.tests.RefineTest; import com.google.refine.tests.util.TestUtils; +import com.google.refine.util.ParsingUtilities; public class RowStarOperationTests extends RefineTest { @BeforeSuite @@ -26,6 +27,6 @@ public class RowStarOperationTests extends RefineTest { + "\"description\":\"Star rows\"," + "\"starred\":true," + "\"engineConfig\":{\"mode\":\"row-based\",\"facets\":[]}}"; - TestUtils.isSerializedTo(RowStarOperation.reconstruct(project, new JSONObject(json)), json); + TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, RowStarOperation.class), json); } }