Migrate ColumnRenameOperation to Jackson
This commit is contained in:
parent
7ea346d08e
commit
d6ca879558
@ -33,6 +33,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package com.google.refine.operations.column;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.refine.history.Change;
|
||||
import com.google.refine.history.HistoryEntry;
|
||||
@ -44,8 +45,11 @@ public class ColumnRenameOperation extends AbstractOperation {
|
||||
final protected String _oldColumnName;
|
||||
final protected String _newColumnName;
|
||||
|
||||
@JsonCreator
|
||||
public ColumnRenameOperation(
|
||||
@JsonProperty("oldColumnName")
|
||||
String oldColumnName,
|
||||
@JsonProperty("newColumnName")
|
||||
String newColumnName
|
||||
) {
|
||||
_oldColumnName = oldColumnName;
|
||||
|
@ -1,14 +1,14 @@
|
||||
package com.google.refine.tests.operations.column;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.testng.annotations.BeforeSuite;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.refine.model.AbstractOperation;
|
||||
import com.google.refine.operations.OperationRegistry;
|
||||
import com.google.refine.operations.column.ColumnRenameOperation;
|
||||
import com.google.refine.tests.RefineTest;
|
||||
import com.google.refine.tests.util.TestUtils;
|
||||
import com.google.refine.util.ParsingUtilities;
|
||||
|
||||
|
||||
public class ColumnRenameOperationTests extends RefineTest {
|
||||
@ -19,15 +19,12 @@ public class ColumnRenameOperationTests extends RefineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializeColumnRenameOperation() throws JSONException, Exception {
|
||||
public void serializeColumnRenameOperation() throws Exception {
|
||||
String json = "{\"op\":\"core/column-rename\","
|
||||
+ "\"description\":\"Rename column old name to new name\","
|
||||
+ "\"oldColumnName\":\"old name\","
|
||||
+ "\"newColumnName\":\"new name\"}";
|
||||
JSONObject obj = new JSONObject(json);
|
||||
TestUtils.isSerializedTo(new ColumnRenameOperation(
|
||||
obj.getString("oldColumnName"),
|
||||
obj.getString("newColumnName")
|
||||
), json);
|
||||
AbstractOperation op = ParsingUtilities.mapper.readValue(json, AbstractOperation.class);
|
||||
TestUtils.isSerializedTo(op, json);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user