From 1c34b237e413b187e860d2bad009af5d3e69b358 Mon Sep 17 00:00:00 2001 From: Antonin Delpeuch Date: Fri, 12 Oct 2018 15:32:41 +0100 Subject: [PATCH] Unify JSON testing in Wikidata extension --- .../operations/SaveWikibaseSchemaOperation.java | 4 +++- .../wikidata/testing/JacksonSerializationTest.java | 14 ++------------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/extensions/wikidata/src/org/openrefine/wikidata/operations/SaveWikibaseSchemaOperation.java b/extensions/wikidata/src/org/openrefine/wikidata/operations/SaveWikibaseSchemaOperation.java index 0459ab2b2..13e043bd1 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/operations/SaveWikibaseSchemaOperation.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/operations/SaveWikibaseSchemaOperation.java @@ -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; diff --git a/extensions/wikidata/tests/src/org/openrefine/wikidata/testing/JacksonSerializationTest.java b/extensions/wikidata/tests/src/org/openrefine/wikidata/testing/JacksonSerializationTest.java index ab61ee7cc..e50b975da 100644 --- a/extensions/wikidata/tests/src/org/openrefine/wikidata/testing/JacksonSerializationTest.java +++ b/extensions/wikidata/tests/src/org/openrefine/wikidata/testing/JacksonSerializationTest.java @@ -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"); - } - } }