Serialization tests for operations.row
This commit is contained in:
parent
6ccd8ea9ee
commit
14233b8ea8
@ -0,0 +1,32 @@
|
|||||||
|
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.RowFlagOperation;
|
||||||
|
import com.google.refine.tests.RefineTest;
|
||||||
|
import com.google.refine.tests.util.TestUtils;
|
||||||
|
|
||||||
|
public class RowFlagOperationTests extends RefineTest {
|
||||||
|
@BeforeSuite
|
||||||
|
public void registerOperation() {
|
||||||
|
OperationRegistry.registerOperation(getCoreModule(), "row-flag", RowFlagOperation.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void serializeRowFlagOperation() throws JSONException, Exception {
|
||||||
|
Project project = mock(Project.class);
|
||||||
|
String json = "{"
|
||||||
|
+ "\"op\":\"core/row-flag\","
|
||||||
|
+ "\"description\":\"Flag rows\","
|
||||||
|
+ "\"flagged\":true,"
|
||||||
|
+ "\"engineConfig\":{\"mode\":\"row-based\",\"facets\":[]}}";
|
||||||
|
TestUtils.isSerializedTo(RowFlagOperation.reconstruct(project, new JSONObject(json)), json);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
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.RowRemovalOperation;
|
||||||
|
import com.google.refine.tests.RefineTest;
|
||||||
|
import com.google.refine.tests.util.TestUtils;
|
||||||
|
|
||||||
|
public class RowRemovalOperationTests extends RefineTest {
|
||||||
|
@BeforeSuite
|
||||||
|
public void registerOperation() {
|
||||||
|
OperationRegistry.registerOperation(getCoreModule(), "row-removal", RowRemovalOperation.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void serializeRowRemovalOperation() throws JSONException, Exception {
|
||||||
|
Project project = mock(Project.class);
|
||||||
|
String json = "{"
|
||||||
|
+ "\"op\":\"core/row-removal\","
|
||||||
|
+ "\"description\":\"Remove rows\","
|
||||||
|
+ "\"engineConfig\":{\"mode\":\"row-based\",\"facets\":[]}}";
|
||||||
|
TestUtils.isSerializedTo(RowRemovalOperation.reconstruct(project, new JSONObject(json)), json);
|
||||||
|
}
|
||||||
|
}
|
@ -21,6 +21,11 @@ public class RowReorderOperationTests extends RefineTest {
|
|||||||
|
|
||||||
Project project = null;
|
Project project = null;
|
||||||
|
|
||||||
|
@BeforeSuite
|
||||||
|
public void registerOperation() {
|
||||||
|
OperationRegistry.registerOperation(getCoreModule(), "row-reorder", RowReorderOperation.class);
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeMethod
|
@BeforeMethod
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
project = createCSVProject(
|
project = createCSVProject(
|
||||||
@ -50,4 +55,29 @@ public class RowReorderOperationTests extends RefineTest {
|
|||||||
Assert.assertEquals("b", project.rows.get(2).cells.get(1).value);
|
Assert.assertEquals("b", project.rows.get(2).cells.get(1).value);
|
||||||
Assert.assertEquals("d", project.rows.get(3).cells.get(1).value);
|
Assert.assertEquals("d", project.rows.get(3).cells.get(1).value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void serializeRowReorderOperation() throws JSONException, Exception {
|
||||||
|
Project project = mock(Project.class);
|
||||||
|
String json = " {\n" +
|
||||||
|
" \"op\": \"core/row-reorder\",\n" +
|
||||||
|
" \"description\": \"Reorder rows\",\n" +
|
||||||
|
" \"mode\": \"record-based\",\n" +
|
||||||
|
" \"sorting\": {\n" +
|
||||||
|
" \"criteria\": [\n" +
|
||||||
|
" {\n" +
|
||||||
|
" \"errorPosition\": 1,\n" +
|
||||||
|
" \"valueType\": \"number\",\n" +
|
||||||
|
" \"column\": \"start_year\",\n" +
|
||||||
|
" \"blankPosition\": 2,\n" +
|
||||||
|
" \"reverse\": false\n" +
|
||||||
|
" }\n" +
|
||||||
|
" ]\n" +
|
||||||
|
" }\n" +
|
||||||
|
" }";
|
||||||
|
TestUtils.isSerializedTo(RowReorderOperation.reconstruct(project, new JSONObject(json)), json);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
public class RowStarOperationTests extends RefineTest {
|
||||||
|
@BeforeSuite
|
||||||
|
public void registerOperation() {
|
||||||
|
OperationRegistry.registerOperation(getCoreModule(), "row-star", RowStarOperation.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void serializeRowStarOperation() throws JSONException, Exception {
|
||||||
|
Project project = mock(Project.class);
|
||||||
|
String json = "{"
|
||||||
|
+ "\"op\":\"core/row-star\","
|
||||||
|
+ "\"description\":\"Star rows\","
|
||||||
|
+ "\"starred\":true,"
|
||||||
|
+ "\"engineConfig\":{\"mode\":\"row-based\",\"facets\":[]}}";
|
||||||
|
TestUtils.isSerializedTo(RowStarOperation.reconstruct(project, new JSONObject(json)), json);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user