Migrate TextSearchFacetTests.java to use the helpers
@@ -68,15 +68,10 @@ import com.google.refine.tests.util.TestUtils;
public class TextSearchFacetTests extends RefineTest {
// dependencies
- private RefineServlet servlet;
private Project project;
- private ProjectMetadata pm;
- private JSONObject options;
- private ImportingJob job;
- private SeparatorBasedImporter importer;
private TextSearchFacet textfilter;
- private JSONObject textsearchfacet;
private RowFilter rowfilter;
+ private JSONObject textsearchfacet;
@Override
@BeforeTest
@@ -86,39 +81,11 @@ public class TextSearchFacetTests extends RefineTest {
@BeforeMethod
public void setUp() throws JSONException, IOException, ModelException {
- servlet = new RefineServletStub();
- File dir = TestUtils.createTempDirectory("openrefine-test-workspace-dir");
- FileProjectManager.initialize(dir);
- project = new Project();
- pm = new ProjectMetadata();
- pm.setName("TextSearchFacet test");
- ProjectManager.singleton.registerProject(project, pm);
- options = mock(JSONObject.class);
-
- ImportingManager.initialize(servlet);
- job = ImportingManager.createJob();
- importer = new SeparatorBasedImporter();
-
- String csv = "Value\n"
+ project = createCSVProject("TextSearchFacet test", "Value\n"
+ "a\n"
+ "b\n"
+ "ab\n"
- + "Abc\n";
- prepareOptions(",", 10, 0, 0, 1, false, false);
- List<Exception> exceptions = new ArrayList<Exception>();
- importer.parseOneFile(project, pm, job, "filesource", new StringReader(csv), -1, options, exceptions);
- project.update();
- ProjectManager.singleton.registerProject(project, pm);
- }
-
- @AfterMethod
- public void tearDown() {
- ImportingManager.disposeJob(job.id);
- ProjectManager.singleton.deleteProject(project.id);
- job = null;
- project = null;
- pm = null;
- options = null;
+ + "Abc\n");
}
/**
@@ -245,21 +212,5 @@ public class TextSearchFacetTests extends RefineTest {
Assert.assertEquals(rowfilter.filterRow(project, 2, project.rows.get(2)),false);
Assert.assertEquals(rowfilter.filterRow(project, 3, project.rows.get(3)),true);
}
-
- private void prepareOptions(
- String sep, int limit, int skip, int ignoreLines,
- int headerLines, boolean guessValueType, boolean ignoreQuotes) {
-
- whenGetStringOption("separator", options, sep);
- whenGetIntegerOption("limit", options, limit);
- whenGetIntegerOption("skipDataLines", options, skip);
- whenGetIntegerOption("ignoreLines", options, ignoreLines);
- whenGetIntegerOption("headerLines", options, headerLines);
- whenGetBooleanOption("guessCellValueTypes", options, guessValueType);
- whenGetBooleanOption("processQuotes", options, !ignoreQuotes);
- whenGetBooleanOption("storeBlankCellsAsNulls", options, true);
- }
-
-
}
