Unlink wikidata extension from RefineTest
This commit is contained in:
parent
6c128d6692
commit
fdf742b052
@ -34,14 +34,14 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.openrefine.wikidata.testing.TestingData;
|
||||
import org.openrefine.wikidata.testing.WikidataRefineTest;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
|
||||
import com.google.refine.RefineTest;
|
||||
import com.google.refine.commands.Command;
|
||||
import com.google.refine.model.Project;
|
||||
|
||||
public abstract class CommandTest extends RefineTest {
|
||||
public abstract class CommandTest extends WikidataRefineTest {
|
||||
|
||||
protected Project project = null;
|
||||
protected HttpServletRequest request = null;
|
||||
@ -50,6 +50,7 @@ public abstract class CommandTest extends RefineTest {
|
||||
|
||||
protected Command command = null;
|
||||
|
||||
|
||||
@BeforeMethod(alwaysRun = true)
|
||||
public void setUpProject() {
|
||||
project = createCSVProject(TestingData.inceptionWithNewCsv);
|
||||
|
@ -23,11 +23,11 @@
|
||||
******************************************************************************/
|
||||
package org.openrefine.wikidata.editing;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@ -37,6 +37,7 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.openrefine.wikidata.testing.TestingData;
|
||||
import org.openrefine.wikidata.testing.WikidataRefineTest;
|
||||
import org.openrefine.wikidata.updates.ItemUpdate;
|
||||
import org.openrefine.wikidata.updates.ItemUpdateBuilder;
|
||||
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.apierrors.MediaWikiApiErrorException;
|
||||
|
||||
import com.google.refine.RefineTest;
|
||||
|
||||
public class EditBatchProcessorTest extends RefineTest {
|
||||
public class EditBatchProcessorTest extends WikidataRefineTest {
|
||||
|
||||
private WikibaseDataFetcher fetcher = null;
|
||||
private WikibaseDataEditor editor = null;
|
||||
|
@ -30,6 +30,7 @@ import java.util.Collections;
|
||||
|
||||
import org.openrefine.wikidata.testing.JacksonSerializationTest;
|
||||
import org.openrefine.wikidata.testing.TestingData;
|
||||
import org.openrefine.wikidata.testing.WikidataRefineTest;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
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.StandardReconConfig;
|
||||
|
||||
public class NewItemLibraryTest extends RefineTest {
|
||||
public class NewItemLibraryTest extends WikidataRefineTest {
|
||||
|
||||
private NewItemLibrary library;
|
||||
|
||||
|
@ -33,6 +33,7 @@ import java.util.Properties;
|
||||
|
||||
import org.openrefine.wikidata.schema.WikibaseSchema;
|
||||
import org.openrefine.wikidata.testing.TestingData;
|
||||
import org.openrefine.wikidata.testing.WikidataRefineTest;
|
||||
import org.openrefine.wikidata.updates.ItemUpdate;
|
||||
import org.openrefine.wikidata.updates.ItemUpdateBuilder;
|
||||
import org.testng.annotations.Test;
|
||||
@ -48,7 +49,7 @@ import com.google.refine.RefineTest;
|
||||
import com.google.refine.browsing.Engine;
|
||||
import com.google.refine.model.Project;
|
||||
|
||||
public class QuickStatementsExporterTest extends RefineTest {
|
||||
public class QuickStatementsExporterTest extends WikidataRefineTest {
|
||||
|
||||
private QuickStatementsExporter exporter = new QuickStatementsExporter();
|
||||
private ItemIdValue newIdA = TestingData.newIdA;
|
||||
|
@ -4,6 +4,7 @@ import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.openrefine.wikidata.testing.WikidataRefineTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
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.util.TestUtils;
|
||||
|
||||
public class SchemaExporterTest extends RefineTest {
|
||||
public class SchemaExporterTest extends WikidataRefineTest {
|
||||
|
||||
private SchemaExporter exporter = new SchemaExporter();
|
||||
|
||||
|
@ -32,10 +32,10 @@ import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.openrefine.wikidata.testing.WikidataRefineTest;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.refine.RefineTest;
|
||||
import com.google.refine.history.Change;
|
||||
import com.google.refine.model.AbstractOperation;
|
||||
import com.google.refine.model.Project;
|
||||
@ -46,7 +46,7 @@ import com.google.refine.util.TestUtils;
|
||||
|
||||
import edu.mit.simile.butterfly.ButterflyModule;
|
||||
|
||||
public abstract class OperationTest extends RefineTest {
|
||||
public abstract class OperationTest extends WikidataRefineTest {
|
||||
|
||||
protected Project project = null;
|
||||
protected ButterflyModule module = null;
|
||||
|
@ -26,13 +26,13 @@ package org.openrefine.wikidata.schema;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
import org.openrefine.wikidata.testing.WikidataRefineTest;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.refine.RefineTest;
|
||||
import com.google.refine.model.Project;
|
||||
|
||||
public class ExpressionContextTest extends RefineTest {
|
||||
public class ExpressionContextTest extends WikidataRefineTest {
|
||||
|
||||
Project project = null;
|
||||
|
||||
|
@ -29,17 +29,17 @@ import java.io.Serializable;
|
||||
import org.openrefine.wikidata.qa.QAWarningStore;
|
||||
import org.openrefine.wikidata.schema.exceptions.SkipSchemaExpressionException;
|
||||
import org.openrefine.wikidata.testing.TestingData;
|
||||
import org.openrefine.wikidata.testing.WikidataRefineTest;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
|
||||
import com.google.refine.RefineTest;
|
||||
import com.google.refine.model.Cell;
|
||||
import com.google.refine.model.ModelException;
|
||||
import com.google.refine.model.Project;
|
||||
import com.google.refine.model.Recon;
|
||||
import com.google.refine.model.Row;
|
||||
|
||||
public class WbExpressionTest<T> extends RefineTest {
|
||||
public class WbExpressionTest<T> extends WikidataRefineTest {
|
||||
|
||||
protected Project project;
|
||||
protected Row row;
|
||||
|
@ -32,6 +32,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.openrefine.wikidata.testing.TestingData;
|
||||
import org.openrefine.wikidata.testing.WikidataRefineTest;
|
||||
import org.openrefine.wikidata.updates.ItemUpdate;
|
||||
import org.openrefine.wikidata.updates.ItemUpdateBuilder;
|
||||
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.TimeValue;
|
||||
|
||||
import com.google.refine.RefineTest;
|
||||
import com.google.refine.browsing.Engine;
|
||||
import com.google.refine.browsing.EngineConfig;
|
||||
import com.google.refine.model.Project;
|
||||
import com.google.refine.util.TestUtils;
|
||||
|
||||
public class WikibaseSchemaTest extends RefineTest {
|
||||
public class WikibaseSchemaTest extends WikidataRefineTest {
|
||||
|
||||
private ItemIdValue qid1 = Datamodel.makeWikidataItemIdValue("Q1377");
|
||||
private ItemIdValue qid2 = Datamodel.makeWikidataItemIdValue("Q865528");
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -195,7 +195,7 @@ public class RefineTest extends PowerMockTestCase {
|
||||
* @param guessValueType
|
||||
* @param ignoreQuotes
|
||||
*/
|
||||
private void prepareImportOptions(ObjectNode options,
|
||||
public static void prepareImportOptions(ObjectNode options,
|
||||
String sep, int limit, int skip, int ignoreLines,
|
||||
int headerLines, boolean guessValueType, boolean ignoreQuotes) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user