use of com.google.refine.browsing.EngineConfig in project OpenRefine by OpenRefine.
the class EngineConfigTests method reconstructNoFacetsProvided.
@Test
public void reconstructNoFacetsProvided() {
EngineConfig ec = EngineConfig.reconstruct(noFacetProvided);
Assert.assertEquals(ec.getMode(), Mode.RowBased);
Assert.assertTrue(ec.getFacetConfigs().isEmpty());
}
use of com.google.refine.browsing.EngineConfig in project OpenRefine by OpenRefine.
the class Command method getEngine.
/**
* Utility function to reconstruct the browsing engine from the "engine" request parameter,
* most often in the POST body.
*
* @param request
* @param project
* @return
* @throws Exception
*/
protected static Engine getEngine(HttpServletRequest request, Project project) throws Exception {
if (request == null) {
throw new IllegalArgumentException("parameter 'request' should not be null");
}
if (project == null) {
throw new IllegalArgumentException("parameter 'project' should not be null");
}
Engine engine = new Engine(project);
EngineConfig c = getEngineConfig(request);
if (c != null) {
engine.initializeFromConfig(c);
}
return engine;
}
use of com.google.refine.browsing.EngineConfig in project OpenRefine by OpenRefine.
the class CommandTests method getEngineConfigRegressionTest.
@Test
public void getEngineConfigRegressionTest() {
when(request.getParameter("engine")).thenReturn("{\"mode\":\"row-based\"}");
EngineConfig o = null;
try {
o = SUT.wrapGetEngineConfig(request);
Assert.assertEquals(Mode.RowBased, o.getMode());
} catch (Exception e) {
Assert.fail();
}
verify(request, times(1)).getParameter("engine");
}
use of com.google.refine.browsing.EngineConfig in project OpenRefine by OpenRefine.
the class WikibaseSchemaTest method testEvaluateRespectsFacets.
@Test
public void testEvaluateRespectsFacets() throws IOException {
String serialized = TestingData.jsonFromFile("schema/inception.json");
WikibaseSchema schema = WikibaseSchema.reconstruct(serialized);
Engine engine = new Engine(project);
EngineConfig engineConfig = EngineConfig.reconstruct("{\n" + " \"mode\": \"row-based\",\n" + " \"facets\": [\n" + " {\n" + " \"mode\": \"text\",\n" + " \"invert\": false,\n" + " \"caseSensitive\": false,\n" + " \"query\": \"www\",\n" + " \"name\": \"reference\",\n" + " \"type\": \"text\",\n" + " \"columnName\": \"reference\"\n" + " }\n" + " ]\n" + " }");
engine.initializeFromConfig(engineConfig);
List<TermedStatementEntityEdit> updates = schema.evaluate(project, engine);
List<TermedStatementEntityEdit> expected = new ArrayList<>();
TermedStatementEntityEdit update1 = new TermedStatementEntityEditBuilder(qid1).addStatement(statementUpdate1).build();
expected.add(update1);
assertEquals(expected, updates);
}
use of com.google.refine.browsing.EngineConfig in project OpenRefine by OpenRefine.
the class EngineConfigTests method serializeEngineConfig.
@Test
public void serializeEngineConfig() {
EngineConfig ec = EngineConfig.reconstruct(engineConfigJson);
TestUtils.isSerializedTo(ec, engineConfigJson);
}
Aggregations