Search in sources :

Example 36 with AbstractOperation

use of com.google.refine.model.AbstractOperation in project OpenRefine by OpenRefine.

the class ColumnAdditionByFetchingURLsOperationTests method serializeUrlFetchingProcess.

@Test
public void serializeUrlFetchingProcess() throws Exception {
    AbstractOperation op = ParsingUtilities.mapper.readValue(json, ColumnAdditionByFetchingURLsOperation.class);
    Process process = op.createProcess(project, new Properties());
    TestUtils.isSerializedTo(process, String.format(processJson, process.hashCode()));
}
Also used : AbstractOperation(com.google.refine.model.AbstractOperation) Process(com.google.refine.process.Process) Properties(java.util.Properties) RefineTest(com.google.refine.RefineTest) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 37 with AbstractOperation

use of com.google.refine.model.AbstractOperation in project OpenRefine by OpenRefine.

the class ReconJudgeSimilarCellsTests method testMarkNewTopics.

@Test
public void testMarkNewTopics() throws Exception {
    Project project = createCSVProject("A,B\n" + "foo,bar\n" + "alpha,beta\n");
    Column column = project.columnModel.columns.get(0);
    ReconConfig config = new StandardReconConfig("http://my.database/recon_service", "http://my.database/entity/", "http://my.database/schema/", null, null, true, Collections.emptyList());
    column.setReconConfig(config);
    AbstractOperation op = new ReconJudgeSimilarCellsOperation(ENGINE_CONFIG, "A", "foo", Recon.Judgment.New, null, true);
    Process process = op.createProcess(project, new Properties());
    process.performImmediate();
    Cell cell = project.rows.get(0).cells.get(0);
    assertEquals(Recon.Judgment.New, cell.recon.judgment);
    assertEquals("http://my.database/entity/", cell.recon.identifierSpace);
    assertNull(project.rows.get(1).cells.get(0).recon);
}
Also used : Project(com.google.refine.model.Project) StandardReconConfig(com.google.refine.model.recon.StandardReconConfig) ReconJudgeSimilarCellsOperation(com.google.refine.operations.recon.ReconJudgeSimilarCellsOperation) AbstractOperation(com.google.refine.model.AbstractOperation) Column(com.google.refine.model.Column) StandardReconConfig(com.google.refine.model.recon.StandardReconConfig) ReconConfig(com.google.refine.model.recon.ReconConfig) Process(com.google.refine.process.Process) Properties(java.util.Properties) Cell(com.google.refine.model.Cell) RefineTest(com.google.refine.RefineTest) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 38 with AbstractOperation

use of com.google.refine.model.AbstractOperation in project OpenRefine by OpenRefine.

the class BlankDownTests method testBlankDownRows.

@Test
public void testBlankDownRows() throws Exception {
    AbstractOperation op = new BlankDownOperation(EngineConfig.reconstruct("{\"mode\":\"row-based\",\"facets\":[]}"), "second");
    Process process = op.createProcess(project, new Properties());
    process.performImmediate();
    Assert.assertEquals("c", project.rows.get(0).cells.get(2).value);
    Assert.assertNull(project.rows.get(1).cells.get(2));
    Assert.assertNull(project.rows.get(2).cells.get(2));
    Assert.assertNull(project.rows.get(3).cells.get(2));
}
Also used : AbstractOperation(com.google.refine.model.AbstractOperation) Process(com.google.refine.process.Process) Properties(java.util.Properties) RefineTest(com.google.refine.RefineTest) Test(org.testng.annotations.Test)

Example 39 with AbstractOperation

use of com.google.refine.model.AbstractOperation in project OpenRefine by OpenRefine.

the class BlankDownTests method testKeyColumnIndex.

@Test
public void testKeyColumnIndex() throws Exception {
    // Shift all column indices
    for (Row r : project.rows) {
        r.cells.add(0, null);
    }
    List<Column> newColumns = new ArrayList<>();
    for (Column c : project.columnModel.columns) {
        newColumns.add(new Column(c.getCellIndex() + 1, c.getName()));
    }
    project.columnModel.columns.clear();
    project.columnModel.columns.addAll(newColumns);
    project.columnModel.update();
    AbstractOperation op = new BlankDownOperation(EngineConfig.reconstruct("{\"mode\":\"record-based\",\"facets\":[]}"), "second");
    Process process = op.createProcess(project, new Properties());
    process.performImmediate();
    Assert.assertEquals("c", project.rows.get(0).cells.get(3).value);
    Assert.assertNull(project.rows.get(1).cells.get(3));
    Assert.assertEquals("c", project.rows.get(2).cells.get(3).value);
    Assert.assertNull(project.rows.get(3).cells.get(3));
}
Also used : AbstractOperation(com.google.refine.model.AbstractOperation) Column(com.google.refine.model.Column) ArrayList(java.util.ArrayList) Process(com.google.refine.process.Process) Row(com.google.refine.model.Row) Properties(java.util.Properties) RefineTest(com.google.refine.RefineTest) Test(org.testng.annotations.Test)

Example 40 with AbstractOperation

use of com.google.refine.model.AbstractOperation in project OpenRefine by OpenRefine.

the class BlankDownTests method testBlankDownRecords.

@Test
public void testBlankDownRecords() throws Exception {
    AbstractOperation op = new BlankDownOperation(EngineConfig.reconstruct("{\"mode\":\"record-based\",\"facets\":[]}"), "second");
    Process process = op.createProcess(project, new Properties());
    process.performImmediate();
    Assert.assertEquals("c", project.rows.get(0).cells.get(2).value);
    Assert.assertNull(project.rows.get(1).cells.get(2));
    Assert.assertEquals("c", project.rows.get(2).cells.get(2).value);
    Assert.assertNull(project.rows.get(3).cells.get(2));
}
Also used : AbstractOperation(com.google.refine.model.AbstractOperation) Process(com.google.refine.process.Process) Properties(java.util.Properties) RefineTest(com.google.refine.RefineTest) Test(org.testng.annotations.Test)

Aggregations

AbstractOperation (com.google.refine.model.AbstractOperation)42 Process (com.google.refine.process.Process)36 Properties (java.util.Properties)36 Test (org.testng.annotations.Test)27 RefineTest (com.google.refine.RefineTest)25 Project (com.google.refine.model.Project)14 IOException (java.io.IOException)14 BeforeTest (org.testng.annotations.BeforeTest)14 ServletException (javax.servlet.ServletException)13 ArrayList (java.util.ArrayList)4 Column (com.google.refine.model.Column)3 HistoryEntry (com.google.refine.history.HistoryEntry)2 Cell (com.google.refine.model.Cell)2 Row (com.google.refine.model.Row)2 StringReader (java.io.StringReader)2 ProjectMetadata (com.google.refine.ProjectMetadata)1 Change (com.google.refine.history.Change)1 ModelException (com.google.refine.model.ModelException)1 ReconConfig (com.google.refine.model.recon.ReconConfig)1 StandardReconConfig (com.google.refine.model.recon.StandardReconConfig)1