Search in sources :

Example 1 with EngineConfig

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());
}
Also used : EngineConfig(com.google.refine.browsing.EngineConfig) Test(org.testng.annotations.Test)

Example 2 with EngineConfig

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;
}
Also used : EngineConfig(com.google.refine.browsing.EngineConfig) Engine(com.google.refine.browsing.Engine)

Example 3 with EngineConfig

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");
}
Also used : EngineConfig(com.google.refine.browsing.EngineConfig) ServletException(javax.servlet.ServletException) RefineTest(com.google.refine.RefineTest) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 4 with EngineConfig

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);
}
Also used : TermedStatementEntityEditBuilder(org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder) TermedStatementEntityEdit(org.openrefine.wikidata.updates.TermedStatementEntityEdit) ArrayList(java.util.ArrayList) EngineConfig(com.google.refine.browsing.EngineConfig) Engine(com.google.refine.browsing.Engine) Test(org.testng.annotations.Test) WikidataRefineTest(org.openrefine.wikidata.testing.WikidataRefineTest)

Example 5 with EngineConfig

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);
}
Also used : EngineConfig(com.google.refine.browsing.EngineConfig) Test(org.testng.annotations.Test)

Aggregations

EngineConfig (com.google.refine.browsing.EngineConfig)7 Test (org.testng.annotations.Test)6 Engine (com.google.refine.browsing.Engine)2 RefineTest (com.google.refine.RefineTest)1 ArrayList (java.util.ArrayList)1 ServletException (javax.servlet.ServletException)1 WikidataRefineTest (org.openrefine.wikidata.testing.WikidataRefineTest)1 TermedStatementEntityEdit (org.openrefine.wikidata.updates.TermedStatementEntityEdit)1 TermedStatementEntityEditBuilder (org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder)1 BeforeTest (org.testng.annotations.BeforeTest)1