Merge pull request #1523 from OpenRefine/issue/1517
fix issue #1517, limit is written as int and should have been read as int
This commit is contained in:
commit
8dfd7588a8
@ -112,8 +112,7 @@ public class StandardReconConfig extends ReconConfig {
|
||||
|
||||
JSONObject t = obj.has("type") && !obj.isNull("type") ? obj.getJSONObject("type") : null;
|
||||
|
||||
String limitString = obj.has("limit") && !obj.isNull("limit") ? obj.getString("limit") : "";
|
||||
int limit = "".equals(limitString) ? 0 : Integer.parseInt(limitString);
|
||||
int limit = obj.has("limit") && !obj.isNull("limit") ? obj.getInt("limit") : 0;
|
||||
|
||||
return new StandardReconConfig(
|
||||
obj.getString("service"),
|
||||
|
@ -2,11 +2,13 @@ package com.google.refine.tests.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.refine.model.recon.ReconConfig;
|
||||
import com.google.refine.model.recon.StandardReconConfig;
|
||||
import com.google.refine.tests.RefineTest;
|
||||
|
||||
@ -44,4 +46,32 @@ public class ReconTests extends RefineTest {
|
||||
Assert.assertTrue(!Double.isInfinite(r));
|
||||
Assert.assertTrue(!Double.isNaN(r));
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression for issue #1517:
|
||||
* JSON deserialization exception due to the upgrade of org.json library in data package PR
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void limitJSONKeyTest() 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\": 0\n" +
|
||||
" }");
|
||||
|
||||
ReconConfig config = StandardReconConfig.reconstruct(obj);
|
||||
|
||||
// Assert the object is created
|
||||
Assert.assertTrue(config != null);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user