Unify JSON testing in Wikidata extension
This commit is contained in:
parent
0698b9c84e
commit
1c34b237e4
@ -31,6 +31,7 @@ import java.util.Properties;
|
||||
import org.json.JSONObject;
|
||||
import org.openrefine.wikidata.schema.WikibaseSchema;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import com.google.refine.history.Change;
|
||||
@ -42,7 +43,8 @@ import com.google.refine.util.Pool;
|
||||
|
||||
public class SaveWikibaseSchemaOperation extends AbstractOperation {
|
||||
|
||||
final public String operationDescription = "Save Wikibase schema";
|
||||
@JsonIgnore
|
||||
final public static String operationDescription = "Save Wikibase schema";
|
||||
@JsonProperty("schema")
|
||||
final protected WikibaseSchema _schema;
|
||||
|
||||
|
@ -33,6 +33,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import com.google.refine.tests.util.TestUtils;
|
||||
import com.google.refine.util.ParsingUtilities;
|
||||
|
||||
public class JacksonSerializationTest {
|
||||
@ -44,7 +45,7 @@ public class JacksonSerializationTest {
|
||||
try {
|
||||
|
||||
String actualJson = ParsingUtilities.defaultWriter.writeValueAsString(pojo);
|
||||
assertJsonEquals(expectedJson, actualJson);
|
||||
TestUtils.assertEqualAsJson(expectedJson, actualJson);
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail("Failed to serialize object");
|
||||
@ -68,15 +69,4 @@ public class JacksonSerializationTest {
|
||||
testSerialize(pojo, json);
|
||||
testDeserialize(targetClass, pojo, json);
|
||||
}
|
||||
|
||||
public static void assertJsonEquals(String expectedJson, String actualJson) {
|
||||
JsonNode parsedExpectedJson;
|
||||
try {
|
||||
parsedExpectedJson = mapper.readValue(expectedJson, JsonNode.class);
|
||||
JsonNode parsedActualJson = mapper.readValue(actualJson, JsonNode.class);
|
||||
assertEquals(parsedExpectedJson, parsedActualJson);
|
||||
} catch (IOException e) {
|
||||
Assert.fail("Invalid JSON");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user