Unify JSON testing in Wikidata extension

This commit is contained in:
Antonin Delpeuch 2018-10-12 12:42:01 +01:00
parent 75b642f9bf
commit 0698b9c84e
2 changed files with 6 additions and 1 deletions

View File

@ -42,6 +42,7 @@ import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Project; import com.google.refine.model.Project;
import com.google.refine.operations.OperationRegistry; import com.google.refine.operations.OperationRegistry;
import com.google.refine.tests.RefineTest; import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.ParsingUtilities; import com.google.refine.util.ParsingUtilities;
import com.google.refine.util.Pool; import com.google.refine.util.Pool;
@ -78,7 +79,7 @@ public abstract class OperationTest extends RefineTest {
AbstractOperation op = reconstruct(); AbstractOperation op = reconstruct();
StringWriter writer = new StringWriter(); StringWriter writer = new StringWriter();
ParsingUtilities.defaultWriter.writeValue(writer, op); ParsingUtilities.defaultWriter.writeValue(writer, op);
JacksonSerializationTest.assertJsonEquals(json.toString(), writer.toString()); TestUtils.assertEqualAsJson(json.toString(), writer.toString());
} }
protected LineNumberReader makeReader(String input) { protected LineNumberReader makeReader(String input) {

View File

@ -42,6 +42,7 @@ import org.apache.commons.io.FileUtils;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRawValue; import com.fasterxml.jackson.annotation.JsonRawValue;
@ -86,6 +87,7 @@ public class ImportingJob {
return config.toString(); return config.toString();
} }
@JsonIgnore
public JSONObject getOrCreateDefaultConfig() { public JSONObject getOrCreateDefaultConfig() {
return config; return config;
} }
@ -137,6 +139,7 @@ public class ImportingJob {
} }
@JsonIgnore
public JSONObject getRetrievalRecord() { public JSONObject getRetrievalRecord() {
synchronized(config) { synchronized(config) {
return JSONUtilities.getObject(config,"retrievalRecord"); return JSONUtilities.getObject(config,"retrievalRecord");
@ -152,6 +155,7 @@ public class ImportingJob {
return fileRecordObject.has("metaDataFormat"); return fileRecordObject.has("metaDataFormat");
} }
@JsonIgnore
public List<JSONObject> getSelectedFileRecords() { public List<JSONObject> getSelectedFileRecords() {
List<JSONObject> results = new ArrayList<JSONObject>(); List<JSONObject> results = new ArrayList<JSONObject>();