Avoid double serialization of json mode in recon config

This commit is contained in:
Antonin Delpeuch 2018-11-26 06:33:07 +09:00
parent 8853e72ab9
commit 1e578384e2
2 changed files with 10 additions and 2 deletions

View File

@ -43,8 +43,8 @@ import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonTypeIdResolver;
import com.google.refine.model.Cell;
import com.google.refine.model.Project;
@ -131,7 +131,8 @@ abstract public class ReconConfig {
/**
* Returns the identifier for the reconciliation mode, as serialized in JSON.
* This is the same identifier that was used to register the registration mode.
* Jackson already adds the mode during serialization hence the JsonIgnore here.
*/
@JsonProperty("mode")
@JsonIgnore
abstract public String getMode();
}

View File

@ -1,5 +1,7 @@
package com.google.refine.tests.model.recon;
import static org.testng.Assert.assertEquals;
import java.util.ArrayList;
import org.slf4j.LoggerFactory;
@ -14,6 +16,7 @@ import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.recon.ReconOperation;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.ParsingUtilities;
public class StandardReconConfigTests extends RefineTest {
@ -85,5 +88,9 @@ public class StandardReconConfigTests extends RefineTest {
" }";
ReconConfig config = ReconConfig.reconstruct(json);
TestUtils.isSerializedTo(config, json);
// the "mode" only appears once in the serialization result
String fullJson = ParsingUtilities.mapper.writeValueAsString(config);
assertEquals(fullJson.indexOf("\"mode\"", fullJson.indexOf("\"mode\"")+1), -1);
}
}