Fix reconciliation result deserialization. Closes #1876.

This commit is contained in:
Antonin Delpeuch 2018-12-02 11:59:47 +09:00
parent 85887372ae
commit 82598ae1d5
2 changed files with 15 additions and 1 deletions

View File

@ -334,7 +334,7 @@ public class StandardReconConfig extends ReconConfig {
public String name; public String name;
@JsonProperty("id") @JsonProperty("id")
public String id; public String id;
@JsonProperty("types") @JsonProperty("type")
public List<ReconType> types = Collections.emptyList(); public List<ReconType> types = Collections.emptyList();
@JsonProperty("score") @JsonProperty("score")
public double 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.ReconJob;
import com.google.refine.model.recon.StandardReconConfig; import com.google.refine.model.recon.StandardReconConfig;
import com.google.refine.model.recon.StandardReconConfig.ColumnDetail; 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.OperationRegistry;
import com.google.refine.operations.recon.ReconOperation; import com.google.refine.operations.recon.ReconOperation;
import com.google.refine.tests.RefineTest; import com.google.refine.tests.RefineTest;
@ -172,4 +173,17 @@ public class StandardReconConfigTests extends RefineTest {
ColumnDetail cd = ParsingUtilities.mapper.readValue(uiJson, ColumnDetail.class); ColumnDetail cd = ParsingUtilities.mapper.readValue(uiJson, ColumnDetail.class);
TestUtils.isSerializedTo(cd, backendJson); 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");
}
} }