Migrate TextSearchFacetTests.java to use the helpers
This commit is contained in:
parent
5278e929a2
commit
8f9fc61046
@ -68,15 +68,10 @@ import com.google.refine.tests.util.TestUtils;
|
|||||||
|
|
||||||
public class TextSearchFacetTests extends RefineTest {
|
public class TextSearchFacetTests extends RefineTest {
|
||||||
// dependencies
|
// dependencies
|
||||||
private RefineServlet servlet;
|
|
||||||
private Project project;
|
private Project project;
|
||||||
private ProjectMetadata pm;
|
|
||||||
private JSONObject options;
|
|
||||||
private ImportingJob job;
|
|
||||||
private SeparatorBasedImporter importer;
|
|
||||||
private TextSearchFacet textfilter;
|
private TextSearchFacet textfilter;
|
||||||
private JSONObject textsearchfacet;
|
|
||||||
private RowFilter rowfilter;
|
private RowFilter rowfilter;
|
||||||
|
private JSONObject textsearchfacet;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@BeforeTest
|
@BeforeTest
|
||||||
@ -86,39 +81,11 @@ public class TextSearchFacetTests extends RefineTest {
|
|||||||
|
|
||||||
@BeforeMethod
|
@BeforeMethod
|
||||||
public void setUp() throws JSONException, IOException, ModelException {
|
public void setUp() throws JSONException, IOException, ModelException {
|
||||||
servlet = new RefineServletStub();
|
project = createCSVProject("TextSearchFacet test", "Value\n"
|
||||||
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"
|
|
||||||
+ "a\n"
|
+ "a\n"
|
||||||
+ "b\n"
|
+ "b\n"
|
||||||
+ "ab\n"
|
+ "ab\n"
|
||||||
+ "Abc\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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -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, 2, project.rows.get(2)),false);
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 3, project.rows.get(3)),true);
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user