Start serialization tests for operations

This commit is contained in:
Antonin Delpeuch 2018-08-11 19:47:58 +01:00
parent fac8936411
commit 2edf83bdf7
14 changed files with 367 additions and 97 deletions

View File

@ -69,6 +69,8 @@ import com.google.refine.model.metadata.ProjectMetadata;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.JSONUtilities;
import edu.mit.simile.butterfly.ButterflyModule;
/**
* A base class containing various utilities to help testing Refine.
*/
@ -83,7 +85,7 @@ public class RefineTest {
private List<ImportingJob> importingJobs = new ArrayList<ImportingJob>();
@BeforeSuite
public void init() {
public void init() {
System.setProperty("log4j.configuration", "tests.log4j.properties");
try {
workspaceDir = TestUtils.createTempDirectory("openrefine-test-workspace-dir");
@ -93,6 +95,8 @@ public class RefineTest {
"{\"class\":\"com.google.refine.preference.TopList\",\"top\":2147483647," +
"\"list\":[]},\"scripting.expressions\":{\"class\":\"com.google.refine.preference.TopList\",\"top\":100,\"list\":[]}}}}");
FileProjectManager.initialize(workspaceDir);
} catch (IOException e) {
workspaceDir = null;
e.printStackTrace();
@ -315,4 +319,10 @@ public class RefineTest {
Assert.fail("JSONException",e);
}
}
protected ButterflyModule getCoreModule() {
ButterflyModule coreModule = mock(ButterflyModule.class);
when(coreModule.getName()).thenReturn("core");
return coreModule;
}
}

View File

@ -1,24 +1,34 @@
package com.google.refine.tests.operations.cell;
import static org.mockito.Mockito.when;
import java.util.Properties;
import org.json.JSONObject;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import com.google.refine.ProjectManager;
import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Project;
import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.cell.BlankDownOperation;
import com.google.refine.process.Process;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
public class BlankDownTests extends RefineTest {
Project project = null;
@BeforeSuite
public void registerOperation() {
OperationRegistry.registerOperation(getCoreModule(), "blank-down", BlankDownOperation.class);
}
@BeforeMethod
public void setUp() {
project = createCSVProject(
@ -34,6 +44,17 @@ public class BlankDownTests extends RefineTest {
ProjectManager.singleton.deleteProject(project.id);
}
@Test
public void serializeBlankDownOperation() {
AbstractOperation op = new BlankDownOperation(
new JSONObject("{\"mode\":\"record-based\",\"facets\":[]}"),
"my column");
TestUtils.isSerializedTo(op, "{\"op\":\"core/blank-down\","
+ "\"description\":\"Blank down cells in column my column\","
+ "\"engineConfig\":{\"mode\":\"record-based\",\"facets\":[]},"
+ "\"columnName\":\"my column\"}");
}
@Test
public void testBlankDownRecords() throws Exception {
AbstractOperation op = new BlankDownOperation(

View File

@ -6,19 +6,27 @@ import org.json.JSONObject;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import com.google.refine.ProjectManager;
import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Project;
import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.cell.FillDownOperation;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.process.Process;
public class FillDownTests extends RefineTest {
Project project = null;
@BeforeSuite
public void registerOperation() {
OperationRegistry.registerOperation(getCoreModule(), "fill-down", FillDownOperation.class);
}
@BeforeMethod
public void setUp() {
project = createCSVProject(
@ -34,6 +42,17 @@ public class FillDownTests extends RefineTest {
ProjectManager.singleton.deleteProject(project.id);
}
@Test
public void serializeFillDownOperation() {
AbstractOperation op = new FillDownOperation(
new JSONObject("{\"mode\":\"record-based\",\"facets\":[]}"),
"my key");
TestUtils.isSerializedTo(op, "{\"op\":\"core/fill-down\","
+ "\"description\":\"Fill down cells in column my key\","
+ "\"engineConfig\":{\"mode\":\"record-based\",\"facets\":[]},"
+ "\"columnName\":\"my key\"}");
}
@Test
public void testFillDownRecordKey() throws Exception {
AbstractOperation op = new FillDownOperation(

View File

@ -35,16 +35,21 @@ package com.google.refine.tests.operations.cell;
import java.util.Properties;
import org.json.JSONObject;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Project;
import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.cell.BlankDownOperation;
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;
public class JoinMultiValuedCellsTests extends RefineTest {
@ -54,6 +59,25 @@ public class JoinMultiValuedCellsTests extends RefineTest {
public void init() {
logger = LoggerFactory.getLogger(this.getClass());
}
@BeforeSuite
public void registerOperation() {
OperationRegistry.registerOperation(getCoreModule(), "multivalued-cell-join", MultiValuedCellJoinOperation.class);
}
@Test
public void serializeMultiValuedCellJoinOperation() {
AbstractOperation op = new MultiValuedCellJoinOperation(
"value column",
"key column",
",");
TestUtils.isSerializedTo(op, "{\"op\":\"core/multivalued-cell-join\","
+ "\"description\":\"Join multi-valued cells in column value column\","
+ "\"columnName\":\"value column\","
+ "\"keyColumnName\":\"key column\","
+ "\"separator\":\",\"}");
}
/*
* Test to demonstrate the intended behaviour of the function

View File

@ -61,6 +61,8 @@ import com.google.refine.model.AbstractOperation;
import com.google.refine.model.ModelException;
import com.google.refine.model.Project;
import com.google.refine.model.metadata.ProjectMetadata;
import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.cell.BlankDownOperation;
import com.google.refine.operations.cell.KeyValueColumnizeOperation;
import com.google.refine.process.Process;
import com.google.refine.tests.RefineServletStub;
@ -94,6 +96,7 @@ public class KeyValueColumnizeTests extends RefineTest {
pm.setName("KeyValueColumnize test");
ProjectManager.singleton.registerProject(project, pm);
options = mock(JSONObject.class);
OperationRegistry.registerOperation(getCoreModule(), "key-value-columnize", KeyValueColumnizeOperation.class);
ImportingManager.initialize(servlet);
job = ImportingManager.createJob();
@ -109,7 +112,74 @@ public class KeyValueColumnizeTests extends RefineTest {
pm = null;
options = null;
}
@Test
public void serializeKeyValueColumnizeOperation() {
AbstractOperation op = new KeyValueColumnizeOperation("key column", "value column", null);
TestUtils.isSerializedTo(op, "{\"op\":\"core/key-value-columnize\",\"description\":\"Columnize by key column key column and value column value column\",\"keyColumnName\":\"key column\",\"valueColumnName\":\"value column\",\"noteColumnName\":null}");
op = new KeyValueColumnizeOperation("key column", "value column", "note column");
TestUtils.isSerializedTo(op, "{\"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\"}");
}
/**
* Test in the case where an ID is available in the first column.
* @throws Exception
*/
@Test
public void testKeyValueColumnizeWithID() throws Exception {
Project project = createCSVProject(
"ID,Cat,Val\n"
+ "1,a,1\n"
+ "1,b,3\n"
+ "2,b,4\n"
+ "2,c,5\n"
+ "3,a,2\n"
+ "3,b,5\n"
+ "3,d,3\n");
AbstractOperation op = new KeyValueColumnizeOperation(
"Cat", "Val", null);
Process process = op.createProcess(project, new Properties());
process.performImmediate();
// Expected output from the GUI.
// ID,a,b,c,d
// 1,1,3,,
// 2,,4,5,
// 3,2,5,,3
Assert.assertEquals(project.columnModel.columns.size(), 5);
Assert.assertEquals(project.columnModel.columns.get(0).getName(), "ID");
Assert.assertEquals(project.columnModel.columns.get(1).getName(), "a");
Assert.assertEquals(project.columnModel.columns.get(2).getName(), "b");
Assert.assertEquals(project.columnModel.columns.get(3).getName(), "c");
Assert.assertEquals(project.columnModel.columns.get(4).getName(), "d");
Assert.assertEquals(project.rows.size(), 3);
// The actual row data structure has to leave the columns model untouched for redo/undo purpose.
// So we have 2 empty columns(column 1,2) on the row level.
// 1,1,3,,
Assert.assertEquals(project.rows.get(0).cells.get(0).value, "1");
Assert.assertEquals(project.rows.get(0).cells.get(3).value, "1");
Assert.assertEquals(project.rows.get(0).cells.get(4).value, "3");
// 2,,4,5,
Assert.assertEquals(project.rows.get(1).cells.get(0).value, "2");
Assert.assertEquals(project.rows.get(1).cells.get(4).value, "4");
Assert.assertEquals(project.rows.get(1).cells.get(5).value, "5");
// 3,2,5,,3
Assert.assertEquals(project.rows.get(2).cells.get(0).value, "3");
Assert.assertEquals(project.rows.get(2).cells.get(3).value, "2");
Assert.assertEquals(project.rows.get(2).cells.get(4).value, "5");
Assert.assertEquals(project.rows.get(2).cells.get(6).value, "3");
}
/**
* Test to demonstrate the intended behaviour of the function, for issue #1214
* https://github.com/OpenRefine/OpenRefine/issues/1214

View File

@ -2,18 +2,43 @@ 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 com.google.refine.model.AbstractOperation;
import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.cell.MassEditOperation;
import com.google.refine.operations.cell.MassEditOperation.Edit;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.ParsingUtilities;
public class MassOperationTests extends RefineTest {
private List<Edit> editList;
private String editsString;
@BeforeSuite
public void setUp() {
OperationRegistry.registerOperation(getCoreModule(), "mass-edit", MassEditOperation.class);
}
@Test
public void serializeMassEditOperation() throws JSONException, Exception {
editsString = "[{\"from\":[\"String\"],\"to\":\"newString\",\"type\":\"text\"}]";
editList = MassEditOperation.reconstructEdits(ParsingUtilities.evaluateJsonStringToArray(editsString));
JSONObject engineConfig = new JSONObject("{\"mode\":\"record-based\",\"facets\":[]}");
AbstractOperation op = new MassEditOperation(engineConfig, "my column", "value", editList);
TestUtils.isSerializedTo(op, "{\"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\"}]}");
}
@Test
public void testReconstructEditString() throws Exception {

View File

@ -44,8 +44,11 @@ import org.testng.annotations.Test;
import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Project;
import com.google.refine.process.Process;
import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.cell.BlankDownOperation;
import com.google.refine.operations.cell.MultiValuedCellSplitOperation;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
public class SplitMultiValuedCellsTests extends RefineTest {
@ -54,6 +57,23 @@ public class SplitMultiValuedCellsTests extends RefineTest {
@BeforeTest
public void init() {
logger = LoggerFactory.getLogger(this.getClass());
OperationRegistry.registerOperation(getCoreModule(), "multivalued-cell-split", MultiValuedCellSplitOperation.class);
}
@Test
public void serializeMultiValuedCellSplitOperation() {
AbstractOperation op = new MultiValuedCellSplitOperation(
"Value",
"Key",
":",
false);
TestUtils.isSerializedTo(op, "{\"op\":\"core/multivalued-cell-split\","
+ "\"description\":\"Split multi-valued cells in column Value\","
+ "\"columnName\":\"Value\","
+ "\"keyColumnName\":\"Key\","
+ "\"mode\":\"separator\","
+ "\"separator\":\":\","
+ "\"regex\":false}");
}
/**

View File

@ -33,7 +33,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.google.refine.tests.operations.cell;
import java.util.Properties;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
@ -41,11 +40,12 @@ import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Project;
import com.google.refine.model.metadata.ProjectMetadata;
import com.google.refine.operations.cell.KeyValueColumnizeOperation;
import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.cell.BlankDownOperation;
import com.google.refine.operations.cell.TransposeRowsIntoColumnsOperation;
import com.google.refine.process.Process;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
public class TransposeTests extends RefineTest {
@ -53,99 +53,16 @@ public class TransposeTests extends RefineTest {
@BeforeTest
public void init() {
logger = LoggerFactory.getLogger(this.getClass());
}
/**
* Test in the case where an ID is available in the first column.
* @throws Exception
*/
@Test
public void testKeyValueColumnizeWithID() throws Exception {
Project project = createCSVProject(
"ID,Cat,Val\n"
+ "1,a,1\n"
+ "1,b,3\n"
+ "2,b,4\n"
+ "2,c,5\n"
+ "3,a,2\n"
+ "3,b,5\n"
+ "3,d,3\n");
AbstractOperation op = new KeyValueColumnizeOperation(
"Cat", "Val", null);
Process process = op.createProcess(project, new Properties());
process.performImmediate();
// Expected output from the GUI.
// ID,a,b,c,d
// 1,1,3,,
// 2,,4,5,
// 3,2,5,,3
Assert.assertEquals(project.columnModel.columns.size(), 5);
Assert.assertEquals(project.columnModel.columns.get(0).getName(), "ID");
Assert.assertEquals(project.columnModel.columns.get(1).getName(), "a");
Assert.assertEquals(project.columnModel.columns.get(2).getName(), "b");
Assert.assertEquals(project.columnModel.columns.get(3).getName(), "c");
Assert.assertEquals(project.columnModel.columns.get(4).getName(), "d");
Assert.assertEquals(project.rows.size(), 3);
// The actual row data structure has to leave the columns model untouched for redo/undo purpose.
// So we have 2 empty columns(column 1,2) on the row level.
// 1,1,3,,
Assert.assertEquals(project.rows.get(0).cells.get(0).value, "1");
Assert.assertEquals(project.rows.get(0).cells.get(3).value, "1");
Assert.assertEquals(project.rows.get(0).cells.get(4).value, "3");
// 2,,4,5,
Assert.assertEquals(project.rows.get(1).cells.get(0).value, "2");
Assert.assertEquals(project.rows.get(1).cells.get(4).value, "4");
Assert.assertEquals(project.rows.get(1).cells.get(5).value, "5");
// 3,2,5,,3
Assert.assertEquals(project.rows.get(2).cells.get(0).value, "3");
Assert.assertEquals(project.rows.get(2).cells.get(3).value, "2");
Assert.assertEquals(project.rows.get(2).cells.get(4).value, "5");
Assert.assertEquals(project.rows.get(2).cells.get(6).value, "3");
OperationRegistry.registerOperation(getCoreModule(), "transpose-rows-into-columns", TransposeRowsIntoColumnsOperation.class);
}
/**
* Test to demonstrate the intended behaviour of the function when no id is available, for issue #1214
* https://github.com/OpenRefine/OpenRefine/issues/1214
*/
@Test
public void testKeyValueColumnizeWithoutID() throws Exception {
Project project = createCSVProject(
"Key,Value\n"
+ "merchant,Katie\n"
+ "fruit,apple\n"
+ "price,1.2\n"
+ "fruit,pear\n"
+ "price,1.5\n"
+ "merchant,John\n"
+ "fruit,banana\n"
+ "price,3.1\n");
AbstractOperation op = new KeyValueColumnizeOperation(
"Key",
"Value",
null);
Process process = op.createProcess(project, new Properties());
process.performImmediate();
int merchantCol = project.columnModel.getColumnByName("merchant").getCellIndex();
int fruitCol = project.columnModel.getColumnByName("fruit").getCellIndex();
int priceCol = project.columnModel.getColumnByName("price").getCellIndex();
Assert.assertEquals(project.rows.get(0).getCellValue(merchantCol), "Katie");
Assert.assertEquals(project.rows.get(1).getCellValue(merchantCol), null);
Assert.assertEquals(project.rows.get(2).getCellValue(merchantCol), "John");
Assert.assertEquals(project.rows.get(0).getCellValue(fruitCol), "apple");
Assert.assertEquals(project.rows.get(1).getCellValue(fruitCol), "pear");
Assert.assertEquals(project.rows.get(2).getCellValue(fruitCol), "banana");
Assert.assertEquals(project.rows.get(0).getCellValue(priceCol), "1.2");
Assert.assertEquals(project.rows.get(1).getCellValue(priceCol), "1.5");
Assert.assertEquals(project.rows.get(2).getCellValue(priceCol), "3.1");
public void testTransposeRowsIntoColumnsOperation() {
AbstractOperation op = new TransposeRowsIntoColumnsOperation("start column", 3);
TestUtils.isSerializedTo(op, "{\"op\":\"core/transpose-rows-into-columns\","
+ "\"description\":\"Transpose every 3 cells in column start column into separate columns\","
+ "\"columnName\":\"start column\","
+ "\"rowCount\":3}");
}
}

View File

@ -0,0 +1,28 @@
package com.google.refine.tests.operations.column;
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.cell.BlankDownOperation;
import com.google.refine.operations.column.ColumnMoveOperation;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
public class ColumnMoveOperationTests extends RefineTest {
@BeforeSuite
public void setUp() {
OperationRegistry.registerOperation(getCoreModule(), "column-move", ColumnMoveOperation.class);
}
@Test
public void serializeColumnMoveOperation() {
AbstractOperation op = new ColumnMoveOperation("my column", 3);
TestUtils.isSerializedTo(op, "{\"op\":\"core/column-move\","
+ "\"description\":\"Move column my column to position 3\","
+ "\"columnName\":\"my column\","
+ "\"index\":3}");
}
}

View File

@ -0,0 +1,28 @@
package com.google.refine.tests.operations.column;
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.ColumnMoveOperation;
import com.google.refine.operations.column.ColumnRemovalOperation;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
public class ColumnRemovalOperationTests extends RefineTest {
@BeforeSuite
public void setUp() {
OperationRegistry.registerOperation(getCoreModule(), "column-removal", ColumnRemovalOperation.class);
}
@Test
public void serializeColumnRemovalOperation() {
AbstractOperation op = new ColumnRemovalOperation("my column");
TestUtils.isSerializedTo(op, "{\"op\":\"core/column-removal\","
+ "\"description\":\"Remove column my column\","
+ "\"columnName\":\"my column\"}");
}
}

View File

@ -0,0 +1,29 @@
package com.google.refine.tests.operations.column;
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.ColumnMoveOperation;
import com.google.refine.operations.column.ColumnRenameOperation;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
public class ColumnRenameOperationTests extends RefineTest {
@BeforeSuite
public void setUp() {
OperationRegistry.registerOperation(getCoreModule(), "column-rename", ColumnRenameOperation.class);
}
@Test
public void serializeColumnRenameOperation() {
AbstractOperation op = new ColumnRenameOperation("old name", "new name");
TestUtils.isSerializedTo(op, "{\"op\":\"core/column-rename\","
+ "\"description\":\"Rename column old name to new name\","
+ "\"oldColumnName\":\"old name\","
+ "\"newColumnName\":\"new name\"}");
}
}

View File

@ -0,0 +1,30 @@
package com.google.refine.tests.operations.column;
import java.util.Arrays;
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.ColumnMoveOperation;
import com.google.refine.operations.column.ColumnReorderOperation;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
public class ColumnReorderOperationTests extends RefineTest {
@BeforeSuite
public void setUp() {
OperationRegistry.registerOperation(getCoreModule(), "column-reorder", ColumnReorderOperation.class);
}
@Test
public void serializeColumnReorderOperation() {
AbstractOperation op = new ColumnReorderOperation(Arrays.asList("b","c","a"));
TestUtils.isSerializedTo(op, "{\"op\":\"core/column-reorder\","
+ "\"description\":\"Reorder columns\","
+ "\"columnNames\":[\"b\",\"c\",\"a\"]}");
}
}

View File

@ -1,4 +1,4 @@
package com.google.refine.tests.operations.cell;
package com.google.refine.tests.operations.recon;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
@ -8,6 +8,7 @@ import java.util.Properties;
import org.json.JSONObject;
import org.slf4j.LoggerFactory;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
@ -18,9 +19,12 @@ import com.google.refine.model.Project;
import com.google.refine.model.Recon;
import com.google.refine.model.recon.ReconConfig;
import com.google.refine.model.recon.StandardReconConfig;
import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.column.ColumnMoveOperation;
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;
public class ReconJudgeSimilarCellsTests extends RefineTest {
@ -30,6 +34,24 @@ public class ReconJudgeSimilarCellsTests extends RefineTest {
@BeforeTest
public void init() {
logger = LoggerFactory.getLogger(this.getClass());
OperationRegistry.registerOperation(getCoreModule(), "recon-judge-similar-cells", ReconJudgeSimilarCellsOperation.class);
}
@Test
public void serializeReconJudgeSimilarCellsOperation() {
AbstractOperation op = new ReconJudgeSimilarCellsOperation(
ENGINE_CONFIG,
"A",
"foo",
Recon.Judgment.New,
null, true);
TestUtils.isSerializedTo(op, "{\"op\":\"core/recon-judge-similar-cells\","
+ "\"description\":\"Mark to create one single new item for all cells containing \\\"foo\\\" in column A\","
+ "\"engineConfig\":{\"mode\":\"row-based\"},"
+ "\"columnName\":\"A\","
+ "\"similarValue\":\"foo\","
+ "\"judgment\":\"new\","
+ "\"shareNewTopics\":true}");
}
@Test

View File

@ -0,0 +1,27 @@
package com.google.refine.tests.operations.row;
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.cell.MultiValuedCellSplitOperation;
import com.google.refine.operations.row.DenormalizeOperation;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
public class DenormalizeOperationTests extends RefineTest {
@BeforeSuite
public void registerOperation() {
OperationRegistry.registerOperation(getCoreModule(), "denormalize", DenormalizeOperation.class);
}
@Test
public void serializeDenormalizeOperation() {
AbstractOperation op = new DenormalizeOperation();
TestUtils.isSerializedTo(op, "{"
+ "\"op\":\"core/denormalize\","
+ "\"description\":\"Denormalize\"}");
}
}