Unlink wikidata extension from RefineTest

This commit is contained in:
Antonin Delpeuch 2019-09-12 10:24:25 +01:00
parent 6c128d6692
commit fdf742b052
11 changed files with 84 additions and 18 deletions

View File

@ -34,14 +34,14 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.openrefine.wikidata.testing.TestingData; import org.openrefine.wikidata.testing.TestingData;
import org.openrefine.wikidata.testing.WikidataRefineTest;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
import com.google.refine.RefineTest;
import com.google.refine.commands.Command; import com.google.refine.commands.Command;
import com.google.refine.model.Project; import com.google.refine.model.Project;
public abstract class CommandTest extends RefineTest { public abstract class CommandTest extends WikidataRefineTest {
protected Project project = null; protected Project project = null;
protected HttpServletRequest request = null; protected HttpServletRequest request = null;
@ -50,6 +50,7 @@ public abstract class CommandTest extends RefineTest {
protected Command command = null; protected Command command = null;
@BeforeMethod(alwaysRun = true) @BeforeMethod(alwaysRun = true)
public void setUpProject() { public void setUpProject() {
project = createCSVProject(TestingData.inceptionWithNewCsv); project = createCSVProject(TestingData.inceptionWithNewCsv);

View File

@ -23,11 +23,11 @@
******************************************************************************/ ******************************************************************************/
package org.openrefine.wikidata.editing; package org.openrefine.wikidata.editing;
import static org.testng.Assert.assertEquals;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import static org.testng.Assert.assertEquals;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -37,6 +37,7 @@ import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.openrefine.wikidata.testing.TestingData; import org.openrefine.wikidata.testing.TestingData;
import org.openrefine.wikidata.testing.WikidataRefineTest;
import org.openrefine.wikidata.updates.ItemUpdate; import org.openrefine.wikidata.updates.ItemUpdate;
import org.openrefine.wikidata.updates.ItemUpdateBuilder; import org.openrefine.wikidata.updates.ItemUpdateBuilder;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
@ -51,9 +52,7 @@ import org.wikidata.wdtk.wikibaseapi.WikibaseDataEditor;
import org.wikidata.wdtk.wikibaseapi.WikibaseDataFetcher; import org.wikidata.wdtk.wikibaseapi.WikibaseDataFetcher;
import org.wikidata.wdtk.wikibaseapi.apierrors.MediaWikiApiErrorException; import org.wikidata.wdtk.wikibaseapi.apierrors.MediaWikiApiErrorException;
import com.google.refine.RefineTest; public class EditBatchProcessorTest extends WikidataRefineTest {
public class EditBatchProcessorTest extends RefineTest {
private WikibaseDataFetcher fetcher = null; private WikibaseDataFetcher fetcher = null;
private WikibaseDataEditor editor = null; private WikibaseDataEditor editor = null;

View File

@ -30,6 +30,7 @@ import java.util.Collections;
import org.openrefine.wikidata.testing.JacksonSerializationTest; import org.openrefine.wikidata.testing.JacksonSerializationTest;
import org.openrefine.wikidata.testing.TestingData; import org.openrefine.wikidata.testing.TestingData;
import org.openrefine.wikidata.testing.WikidataRefineTest;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -39,7 +40,7 @@ import com.google.refine.model.Project;
import com.google.refine.model.Recon; import com.google.refine.model.Recon;
import com.google.refine.model.recon.StandardReconConfig; import com.google.refine.model.recon.StandardReconConfig;
public class NewItemLibraryTest extends RefineTest { public class NewItemLibraryTest extends WikidataRefineTest {
private NewItemLibrary library; private NewItemLibrary library;

View File

@ -33,6 +33,7 @@ import java.util.Properties;
import org.openrefine.wikidata.schema.WikibaseSchema; import org.openrefine.wikidata.schema.WikibaseSchema;
import org.openrefine.wikidata.testing.TestingData; import org.openrefine.wikidata.testing.TestingData;
import org.openrefine.wikidata.testing.WikidataRefineTest;
import org.openrefine.wikidata.updates.ItemUpdate; import org.openrefine.wikidata.updates.ItemUpdate;
import org.openrefine.wikidata.updates.ItemUpdateBuilder; import org.openrefine.wikidata.updates.ItemUpdateBuilder;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -48,7 +49,7 @@ import com.google.refine.RefineTest;
import com.google.refine.browsing.Engine; import com.google.refine.browsing.Engine;
import com.google.refine.model.Project; import com.google.refine.model.Project;
public class QuickStatementsExporterTest extends RefineTest { public class QuickStatementsExporterTest extends WikidataRefineTest {
private QuickStatementsExporter exporter = new QuickStatementsExporter(); private QuickStatementsExporter exporter = new QuickStatementsExporter();
private ItemIdValue newIdA = TestingData.newIdA; private ItemIdValue newIdA = TestingData.newIdA;

View File

@ -4,6 +4,7 @@ import java.io.IOException;
import java.io.StringWriter; import java.io.StringWriter;
import java.util.Properties; import java.util.Properties;
import org.openrefine.wikidata.testing.WikidataRefineTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.refine.RefineTest; import com.google.refine.RefineTest;
@ -11,7 +12,7 @@ import com.google.refine.browsing.Engine;
import com.google.refine.model.Project; import com.google.refine.model.Project;
import com.google.refine.util.TestUtils; import com.google.refine.util.TestUtils;
public class SchemaExporterTest extends RefineTest { public class SchemaExporterTest extends WikidataRefineTest {
private SchemaExporter exporter = new SchemaExporter(); private SchemaExporter exporter = new SchemaExporter();

View File

@ -32,10 +32,10 @@ import java.io.StringReader;
import java.io.StringWriter; import java.io.StringWriter;
import java.util.Properties; import java.util.Properties;
import org.openrefine.wikidata.testing.WikidataRefineTest;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.refine.RefineTest;
import com.google.refine.history.Change; import com.google.refine.history.Change;
import com.google.refine.model.AbstractOperation; import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Project; import com.google.refine.model.Project;
@ -46,7 +46,7 @@ import com.google.refine.util.TestUtils;
import edu.mit.simile.butterfly.ButterflyModule; import edu.mit.simile.butterfly.ButterflyModule;
public abstract class OperationTest extends RefineTest { public abstract class OperationTest extends WikidataRefineTest {
protected Project project = null; protected Project project = null;
protected ButterflyModule module = null; protected ButterflyModule module = null;

View File

@ -26,13 +26,13 @@ package org.openrefine.wikidata.schema;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull; import static org.testng.Assert.assertNull;
import org.openrefine.wikidata.testing.WikidataRefineTest;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.refine.RefineTest;
import com.google.refine.model.Project; import com.google.refine.model.Project;
public class ExpressionContextTest extends RefineTest { public class ExpressionContextTest extends WikidataRefineTest {
Project project = null; Project project = null;

View File

@ -29,17 +29,17 @@ import java.io.Serializable;
import org.openrefine.wikidata.qa.QAWarningStore; import org.openrefine.wikidata.qa.QAWarningStore;
import org.openrefine.wikidata.schema.exceptions.SkipSchemaExpressionException; import org.openrefine.wikidata.schema.exceptions.SkipSchemaExpressionException;
import org.openrefine.wikidata.testing.TestingData; import org.openrefine.wikidata.testing.TestingData;
import org.openrefine.wikidata.testing.WikidataRefineTest;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
import com.google.refine.RefineTest;
import com.google.refine.model.Cell; import com.google.refine.model.Cell;
import com.google.refine.model.ModelException; import com.google.refine.model.ModelException;
import com.google.refine.model.Project; import com.google.refine.model.Project;
import com.google.refine.model.Recon; import com.google.refine.model.Recon;
import com.google.refine.model.Row; import com.google.refine.model.Row;
public class WbExpressionTest<T> extends RefineTest { public class WbExpressionTest<T> extends WikidataRefineTest {
protected Project project; protected Project project;
protected Row row; protected Row row;

View File

@ -32,6 +32,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import org.openrefine.wikidata.testing.TestingData; import org.openrefine.wikidata.testing.TestingData;
import org.openrefine.wikidata.testing.WikidataRefineTest;
import org.openrefine.wikidata.updates.ItemUpdate; import org.openrefine.wikidata.updates.ItemUpdate;
import org.openrefine.wikidata.updates.ItemUpdateBuilder; import org.openrefine.wikidata.updates.ItemUpdateBuilder;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
@ -47,13 +48,12 @@ import org.wikidata.wdtk.datamodel.interfaces.StatementRank;
import org.wikidata.wdtk.datamodel.interfaces.StringValue; import org.wikidata.wdtk.datamodel.interfaces.StringValue;
import org.wikidata.wdtk.datamodel.interfaces.TimeValue; import org.wikidata.wdtk.datamodel.interfaces.TimeValue;
import com.google.refine.RefineTest;
import com.google.refine.browsing.Engine; import com.google.refine.browsing.Engine;
import com.google.refine.browsing.EngineConfig; import com.google.refine.browsing.EngineConfig;
import com.google.refine.model.Project; import com.google.refine.model.Project;
import com.google.refine.util.TestUtils; import com.google.refine.util.TestUtils;
public class WikibaseSchemaTest extends RefineTest { public class WikibaseSchemaTest extends WikidataRefineTest {
private ItemIdValue qid1 = Datamodel.makeWikidataItemIdValue("Q1377"); private ItemIdValue qid1 = Datamodel.makeWikidataItemIdValue("Q1377");
private ItemIdValue qid2 = Datamodel.makeWikidataItemIdValue("Q865528"); private ItemIdValue qid2 = Datamodel.makeWikidataItemIdValue("Q865528");

View File

@ -0,0 +1,63 @@
package org.openrefine.wikidata.testing;
import static org.mockito.Mockito.mock;
import java.io.File;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import org.testng.annotations.BeforeMethod;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.refine.ProjectManager;
import com.google.refine.ProjectManagerStub;
import com.google.refine.ProjectMetadata;
import com.google.refine.RefineServlet;
import com.google.refine.RefineServletStub;
import com.google.refine.RefineTest;
import com.google.refine.importers.SeparatorBasedImporter;
import com.google.refine.importing.ImportingJob;
import com.google.refine.importing.ImportingManager;
import com.google.refine.model.Project;
public class WikidataRefineTest {
protected File workspaceDir;
protected RefineServlet servlet;
private List<Project> projects = new ArrayList<Project>();
private List<ImportingJob> importingJobs = new ArrayList<ImportingJob>();
public Project createCSVProject(String input) {
return createCSVProject("test project", input);
}
protected Project createCSVProject(String projectName, String input) {
Project project = new Project();
ProjectMetadata metadata = new ProjectMetadata();
metadata.setName(projectName);
ObjectNode options = mock(ObjectNode.class);
RefineTest.prepareImportOptions(options, ",", -1, 0, 0, 1, false, false);
ImportingJob job = ImportingManager.createJob();
SeparatorBasedImporter importer = new SeparatorBasedImporter();
List<Exception> exceptions = new ArrayList<Exception>();
importer.parseOneFile(project, metadata, job, "filesource", new StringReader(input), -1, options, exceptions);
project.update();
ProjectManager.singleton.registerProject(project, metadata);
projects.add(project);
importingJobs.add(job);
return project;
}
@BeforeMethod(alwaysRun = true)
public void initServlet() {
servlet = new RefineServletStub();
ProjectManager.singleton = new ProjectManagerStub();
ImportingManager.initialize(servlet);
}
}

View File

@ -195,7 +195,7 @@ public class RefineTest extends PowerMockTestCase {
* @param guessValueType * @param guessValueType
* @param ignoreQuotes * @param ignoreQuotes
*/ */
private void prepareImportOptions(ObjectNode options, public static void prepareImportOptions(ObjectNode options,
String sep, int limit, int skip, int ignoreLines, String sep, int limit, int skip, int ignoreLines,
int headerLines, boolean guessValueType, boolean ignoreQuotes) { int headerLines, boolean guessValueType, boolean ignoreQuotes) {