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);
}
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));
}
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));
}
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));
}
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");
}
Aggregations