Merge pull request #1877 from OpenRefine/issue1876

Fix reconciliation result deserialization
This commit is contained in:
Antonin Delpeuch 2018-12-09 22:47:40 +09:00 committed by GitHub
commit d4222c05ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -334,7 +334,7 @@ public class StandardReconConfig extends ReconConfig {
public String name;
@JsonProperty("id")
public String id;
@JsonProperty("types")
@JsonProperty("type")
public List<ReconType> types = Collections.emptyList();
@JsonProperty("score")
public double score;

View File

@ -20,6 +20,7 @@ import com.google.refine.model.recon.ReconConfig;
import com.google.refine.model.recon.ReconJob;
import com.google.refine.model.recon.StandardReconConfig;
import com.google.refine.model.recon.StandardReconConfig.ColumnDetail;
import com.google.refine.model.recon.StandardReconConfig.ReconResult;
import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.recon.ReconOperation;
import com.google.refine.tests.RefineTest;
@ -172,4 +173,17 @@ public class StandardReconConfigTests extends RefineTest {
ColumnDetail cd = ParsingUtilities.mapper.readValue(uiJson, ColumnDetail.class);
TestUtils.isSerializedTo(cd, backendJson);
}
@Test
public void deserializeReconResult() throws JsonParseException, JsonMappingException, IOException {
String json = "{\"score\":100.0,"
+ "\"match\":false,"
+ "\"type\":["
+ " {\"id\":\"Q17366755\","
+ " \"name\":\"hamlet in Alberta\"}],"
+ "\"id\":\"Q5136635\","
+ "\"name\":\"Cluny\"}";
ReconResult rr = ParsingUtilities.mapper.readValue(json, ReconResult.class);
assertEquals(rr.types.get(0).name, "hamlet in Alberta");
}
}