Accept empty string for the limit in a reconciliation config
This commit is contained in:
parent
1866f9691d
commit
8c8b091adc
@ -111,8 +111,13 @@ public class StandardReconConfig extends ReconConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSONObject t = obj.has("type") && !obj.isNull("type") ? obj.getJSONObject("type") : null;
|
JSONObject t = obj.has("type") && !obj.isNull("type") ? obj.getJSONObject("type") : null;
|
||||||
|
|
||||||
int limit = obj.has("limit") && !obj.isNull("limit") ? obj.getInt("limit") : 0;
|
int limit;
|
||||||
|
try {
|
||||||
|
limit = obj.has("limit") && !obj.isNull("limit") ? obj.getInt("limit") : 0;
|
||||||
|
} catch(JSONException e) {
|
||||||
|
limit = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return new StandardReconConfig(
|
return new StandardReconConfig(
|
||||||
obj.getString("service"),
|
obj.getString("service"),
|
||||||
|
@ -53,7 +53,7 @@ public class ReconTests extends RefineTest {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void limitJSONKeyTest() throws Exception {
|
public void limitJSONKeyAsIntTest() throws Exception {
|
||||||
JSONObject obj = new JSONObject(
|
JSONObject obj = new JSONObject(
|
||||||
" {\n" +
|
" {\n" +
|
||||||
" \"mode\": \"standard-service\",\n" +
|
" \"mode\": \"standard-service\",\n" +
|
||||||
@ -74,4 +74,35 @@ public class ReconTests extends RefineTest {
|
|||||||
// Assert the object is created
|
// Assert the object is created
|
||||||
Assert.assertTrue(config != null);
|
Assert.assertTrue(config != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Regression for issue #1526:
|
||||||
|
* the UI used to send an empty limit as an empty string, which
|
||||||
|
* failed to be parsed by the backend.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void limitJSONKeyAsEmptyStringTest() throws Exception {
|
||||||
|
JSONObject obj = new JSONObject(
|
||||||
|
" {\n" +
|
||||||
|
" \"mode\": \"standard-service\",\n" +
|
||||||
|
" \"service\": \"https://tools.wmflabs.org/openrefine-wikidata/en/api\",\n" +
|
||||||
|
" \"identifierSpace\": \"http://www.wikidata.org/entity/\",\n" +
|
||||||
|
" \"schemaSpace\": \"http://www.wikidata.org/prop/direct/\",\n" +
|
||||||
|
" \"type\": {\n" +
|
||||||
|
" \"id\": \"Q13442814\",\n" +
|
||||||
|
" \"name\": \"scientific article\"\n" +
|
||||||
|
" },\n" +
|
||||||
|
" \"autoMatch\": true,\n" +
|
||||||
|
" \"columnDetails\": [],\n" +
|
||||||
|
" \"limit\": \"\"\n" +
|
||||||
|
" }");
|
||||||
|
|
||||||
|
ReconConfig config = StandardReconConfig.reconstruct(obj);
|
||||||
|
|
||||||
|
// Assert the object is created
|
||||||
|
Assert.assertTrue(config != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user