Package org.openrefine
Class RefineTest
- java.lang.Object
-
- org.openrefine.RefineTest
-
- Direct Known Subclasses:
ImporterTest
public class RefineTest extends Object
A base class containing various utilities to help testing Refine.
-
-
Field Summary
Fields Modifier and Type Field Description protected static Properties
bindings
protected org.slf4j.Logger
logger
protected File
workspaceDir
-
Constructor Summary
Constructors Constructor Description RefineTest()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
assertGridEquals(Grid actual, Grid expected)
static void
assertProjectCreated(Project project, int numCols, int numRows)
Check that a project was created with the appropriate number of columns and rows.protected void
cleanupProjectsAndJobs()
Cleans up the projects and jobs created with createCSVProjectprotected Runner
createDatamodelRunner()
Method that subclasses can override to change the runner used in the test.protected Grid
createGrid(String[] columns, Serializable[][] rows)
protected Grid
createGridWithRecords(String[] columns, Serializable[][] rows)
protected Project
createProject(String[] columns, Serializable[][] rows)
Helper to create a project with given contents.protected Project
createProject(String projectName, String[] columns, Serializable[] rows)
Deprecated.protected Project
createProject(String projectName, String[] columns, Serializable[][] rows)
Helper to create a project with given contents.protected Project
createProject(String projectName, Grid grid)
void
init()
protected void
initProjectManager()
protected void
parseEval(Properties bindings, String[] test)
Parse and evaluate a GREL expression and compare the result to the expect valueprotected void
parseEvalType(Properties bindings, String test, Class clazz)
Parse and evaluate a GREL expression and compare the result an expected type using instanceofstatic void
prepareImportOptions(com.fasterxml.jackson.databind.node.ObjectNode options, String sep, int limit, int skip, int ignoreLines, int headerLines, boolean guessValueType, boolean ignoreQuotes)
Initializes the importing options for the CSV importer.protected Runner
runner()
Method to access the runner easily from tests.void
TearDown()
protected Recon
testRecon(String name, String id, Recon.Judgment judgment)
protected List<Row>
toRows(Cell[][] cells)
-
-
-
Field Detail
-
bindings
protected static Properties bindings
-
logger
protected org.slf4j.Logger logger
-
workspaceDir
protected File workspaceDir
-
-
Method Detail
-
createDatamodelRunner
protected Runner createDatamodelRunner()
Method that subclasses can override to change the runner used in the test.
-
runner
protected Runner runner()
Method to access the runner easily from tests.
-
init
@BeforeSuite public void init()
-
initProjectManager
@BeforeMethod protected void initProjectManager()
-
createProject
protected Project createProject(String[] columns, Serializable[][] rows)
Helper to create a project with given contents. Not much control is given on the import options, because this method is intended to be a quick way to create a project for a test. For more control over the import, just call the importer directly.- Parameters:
columns
- the list of column namesrows
- the cell values, as a flattened array of arrays- Returns:
-
createProject
protected Project createProject(String projectName, String[] columns, Serializable[][] rows)
Helper to create a project with given contents. Not much control is given on the import options, because this method is intended to be a quick way to create a project for a test. For more control over the import, just call the importer directly. The projects created via this method will be disposed of at the end of each test.- Parameters:
projectName
- the name of the project to createcolumns
- the list of column namesrows
- the cell values, as a flattened array of arrays- Returns:
-
createGrid
protected Grid createGrid(String[] columns, Serializable[][] rows)
-
createGridWithRecords
protected Grid createGridWithRecords(String[] columns, Serializable[][] rows)
-
createProject
@Deprecated protected Project createProject(String projectName, String[] columns, Serializable[] rows)
Deprecated.
-
prepareImportOptions
public static void prepareImportOptions(com.fasterxml.jackson.databind.node.ObjectNode options, String sep, int limit, int skip, int ignoreLines, int headerLines, boolean guessValueType, boolean ignoreQuotes)
Initializes the importing options for the CSV importer.- Parameters:
options
-sep
-limit
-skip
-ignoreLines
-headerLines
-guessValueType
-ignoreQuotes
-
-
cleanupProjectsAndJobs
@AfterMethod protected void cleanupProjectsAndJobs()
Cleans up the projects and jobs created with createCSVProject
-
testRecon
protected Recon testRecon(String name, String id, Recon.Judgment judgment)
-
assertProjectCreated
public static void assertProjectCreated(Project project, int numCols, int numRows)
Check that a project was created with the appropriate number of columns and rows.- Parameters:
project
- project to checknumCols
- expected column countnumRows
- expected row count
-
parseEval
protected void parseEval(Properties bindings, String[] test) throws ParsingException
Parse and evaluate a GREL expression and compare the result to the expect value- Parameters:
bindings
-test
-- Throws:
ParsingException
-
parseEvalType
protected void parseEvalType(Properties bindings, String test, Class clazz) throws ParsingException
Parse and evaluate a GREL expression and compare the result an expected type using instanceof- Parameters:
bindings
-test
-- Throws:
ParsingException
-
-