Search in sources :

Example 36 with Process

use of com.google.refine.process.Process 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 37 with Process

use of com.google.refine.process.Process 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 38 with Process

use of com.google.refine.process.Process 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 39 with Process

use of com.google.refine.process.Process 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)

Example 40 with Process

use of com.google.refine.process.Process in project OpenRefine by OpenRefine.

the class JoinMultiValuedCellsTests method testJoinMultiValuedCellsMultipleSpaces.

@Test
public void testJoinMultiValuedCellsMultipleSpaces() throws Exception {
    AbstractOperation op = new MultiValuedCellJoinOperation("Value", "Key", ",     ,");
    Process process = op.createProcess(project, new Properties());
    process.performImmediate();
    int keyCol = project.columnModel.getColumnByName("Key").getCellIndex();
    int valueCol = project.columnModel.getColumnByName("Value").getCellIndex();
    Assert.assertEquals(project.rows.get(0).getCellValue(keyCol), "Record_1");
    Assert.assertEquals(project.rows.get(0).getCellValue(valueCol), "one,     ,two,     ,three,     ,four");
}
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)

Aggregations

Process (com.google.refine.process.Process)43 Properties (java.util.Properties)41 AbstractOperation (com.google.refine.model.AbstractOperation)36 Test (org.testng.annotations.Test)29 RefineTest (com.google.refine.RefineTest)27 BeforeTest (org.testng.annotations.BeforeTest)20 Project (com.google.refine.model.Project)17 IOException (java.io.IOException)14 ServletException (javax.servlet.ServletException)13 Cell (com.google.refine.model.Cell)5 Row (com.google.refine.model.Row)5 Column (com.google.refine.model.Column)4 ProcessManager (com.google.refine.process.ProcessManager)4 ArrayList (java.util.ArrayList)4 StandardReconConfig (com.google.refine.model.recon.StandardReconConfig)2 ReconOperation (com.google.refine.operations.recon.ReconOperation)2 RefineTest (com.google.refine.tests.RefineTest)2 StringReader (java.io.StringReader)2 HttpUrl (okhttp3.HttpUrl)2 MockResponse (okhttp3.mockwebserver.MockResponse)2