Search in sources :

Example 6 with StandardReconConfig

use of com.google.refine.model.recon.StandardReconConfig 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 7 with StandardReconConfig

use of com.google.refine.model.recon.StandardReconConfig in project OpenRefine by OpenRefine.

the class ReconOperationTests method testFailingRecon.

@Test
public void testFailingRecon() throws Exception {
    Project project = createCSVProject("my recon test project", "column\n" + "valueA\n" + "valueB\n" + "valueC");
    StandardReconConfig reconConfig = mock(StandardReconConfig.class);
    List<Recon> reconList = Arrays.asList((Recon) null, (Recon) null, (Recon) null);
    ReconJob reconJob = mock(ReconJob.class);
    when(reconConfig.batchRecon(Mockito.any(), Mockito.anyLong())).thenReturn(reconList);
    when(reconConfig.getBatchSize()).thenReturn(10);
    when(reconConfig.createJob(Mockito.eq(project), Mockito.anyInt(), Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(reconJob);
    ReconOperation op = new ReconOperation(EngineConfig.reconstruct("{}"), "column", reconConfig);
    Process process = op.createProcess(project, new Properties());
    runAndWait(project.getProcessManager(), process, 1000);
    Column column = project.columnModel.columns.get(0);
    Assert.assertNotNull(column.getReconStats());
    Assert.assertEquals(column.getReconStats().matchedTopics, 0);
    Assert.assertNull(project.rows.get(0).getCell(0).recon);
    Assert.assertNull(project.rows.get(1).getCell(0).recon);
    Assert.assertNull(project.rows.get(2).getCell(0).recon);
}
Also used : Project(com.google.refine.model.Project) StandardReconConfig(com.google.refine.model.recon.StandardReconConfig) Column(com.google.refine.model.Column) ReconJob(com.google.refine.model.recon.ReconJob) Process(com.google.refine.process.Process) Properties(java.util.Properties) Recon(com.google.refine.model.Recon) RefineTest(com.google.refine.RefineTest) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

StandardReconConfig (com.google.refine.model.recon.StandardReconConfig)7 Column (com.google.refine.model.Column)6 Cell (com.google.refine.model.Cell)4 Project (com.google.refine.model.Project)4 ReconConfig (com.google.refine.model.recon.ReconConfig)4 IOException (java.io.IOException)3 Test (org.testng.annotations.Test)3 RefineTest (com.google.refine.RefineTest)2 Recon (com.google.refine.model.Recon)2 ReconCandidate (com.google.refine.model.ReconCandidate)2 Row (com.google.refine.model.Row)2 Process (com.google.refine.process.Process)2 HashSet (java.util.HashSet)2 Properties (java.util.Properties)2 BeforeTest (org.testng.annotations.BeforeTest)2 ReconJudgeOneCellCommand (com.google.refine.commands.recon.ReconJudgeOneCellCommand)1 AbstractOperation (com.google.refine.model.AbstractOperation)1 ReconJob (com.google.refine.model.recon.ReconJob)1 ReconciledDataExtensionJob (com.google.refine.model.recon.ReconciledDataExtensionJob)1 DataExtension (com.google.refine.model.recon.ReconciledDataExtensionJob.DataExtension)1