Repository: wikidata/wikidata-toolkit
Issue: Regression: serialization of Statements

We have a problem with Statement serialization: statement values should only be serialized as part of the mainsnak, but they are also serialized at the Statement root:

Our tests currently specify this serialization:
```json
{
  "rank": "preferred",
  "value": {
    "value": {
      "id": "Q42",
      "numeric-id": 42,
      "entity-type": "item"
    },
    "type": "wikibase-entityid"
  },
  "id": "MyId",
  "mainsnak": {
    "property": "P42",
    "datatype": "wikibase-item",
    "datavalue": {
      "value": {
        "id": "Q42",
        "numeric-id": 42,
        "entity-type": "item"
      },
      "type": "wikibase-entityid"
    },
    "snaktype": "value"
  },
  "type": "statement"
}
```

The correct serialization should be:
```json
{
  "rank": "preferred",
  "id": "MyId",
  "mainsnak": {
    "property": "P42",
    "datatype": "wikibase-item",
    "datavalue": {
      "value": {
        "id": "Q42",
        "numeric-id": 42,
        "entity-type": "item"
      },
      "type": "wikibase-entityid"
    },
    "snaktype": "value"
  },
  "type": "statement"
}
```


This was introduced by the addition of Claim methods to the Statement class, #330, where a `@JsonIgnore` was forgotten. The faulty test was introduced in 5d34b3a0c.

Changed files:
wdtk-datamodel/src/test/java/org/wikidata/wdtk/datamodel/implementation/StatementImplTest.java
wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/StatementImpl.java

diff --git a/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/StatementImpl.java b/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/StatementImpl.java
index fef0bfcc..fbb9c267 100644
--- a/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/StatementImpl.java
+++ b/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/StatementImpl.java
@@ -222,6 +222,7 @@ public class StatementImpl implements Statement {
 	}
 
 	@Override
+	@JsonProperty("references")
 	public List<Reference> getReferences() {
 		return references;
 	}
@@ -233,6 +234,7 @@ public class StatementImpl implements Statement {
 	}
 
 	@Override
+	@JsonIgnore
 	public Value getValue() {
 		return mainSnak.getValue();
 	}
diff --git a/wdtk-datamodel/src/test/java/org/wikidata/wdtk/datamodel/implementation/StatementImplTest.java b/wdtk-datamodel/src/test/java/org/wikidata/wdtk/datamodel/implementation/StatementImplTest.java
index 3777c680..bd2350f4 100644
--- a/wdtk-datamodel/src/test/java/org/wikidata/wdtk/datamodel/implementation/StatementImplTest.java
+++ b/wdtk-datamodel/src/test/java/org/wikidata/wdtk/datamodel/implementation/StatementImplTest.java
@@ -48,11 +48,11 @@ public class StatementImplTest {
 			qualifiers, references, subjet);
 	private final Statement s2 = new StatementImpl("MyId", StatementRank.PREFERRED, mainSnak,
 			qualifiers, references, subjet);
-	private final String JSON_STATEMENT = "{\\"rank\\":\\"preferred\\",\\"references\\":[{\\"snaks\\":{\\"P42\\":[{\\"property\\":\\"P42\\",\\"datatype\\":\\"wikibase-item\\",\\"datavalue\\":{\\"value\\":{\\"id\\":\\"Q42\\",\\"numeric-id\\":42,\\"entity-type\\":\\"item\\"},\\"type\\":\\"wikibase-entityid\\"},\\"snaktype\\":\\"value\\"}]},\\"snaks-order\\":[\\"P42\\"]}],\\"value\\":{\\"value\\":{\\"id\\":\\"Q42\\",\\"numeric-id\\":42,\\"entity-type\\":\\"item\\"},\\"type\\":\\"wikibase-entityid\\"},\\"id\\":\\"MyId\\",\\"mainsnak\\":{\\"property\\":\\"P42\\",\\"datatype\\":\\"wikibase-item\\",\\"datavalue\\":{\\"value\\":{\\"id\\":\\"Q42\\",\\"numeric-id\\":42,\\"entity-type\\":\\"item\\"},\\"type\\":\\"wikibase-entityid\\"},\\"snaktype\\":\\"value\\"},\\"qualifiers-order\\":[\\"P42\\"],\\"type\\":\\"statement\\",\\"qualifiers\\":{\\"P42\\":[{\\"property\\":\\"P42\\",\\"datatype\\":\\"wikibase-item\\",\\"datavalue\\":{\\"value\\":{\\"id\\":\\"Q42\\",\\"numeric-id\\":42,\\"entity-type\\":\\"item\\"},\\"type\\":\\"wikibase-entityid\\"},\\"snaktype\\":\\"value\\"}]}}";
+	private final String JSON_STATEMENT = "{\\"rank\\":\\"preferred\\",\\"references\\":[{\\"snaks\\":{\\"P42\\":[{\\"property\\":\\"P42\\",\\"datatype\\":\\"wikibase-item\\",\\"datavalue\\":{\\"value\\":{\\"id\\":\\"Q42\\",\\"numeric-id\\":42,\\"entity-type\\":\\"item\\"},\\"type\\":\\"wikibase-entityid\\"},\\"snaktype\\":\\"value\\"}]},\\"snaks-order\\":[\\"P42\\"]}],\\"id\\":\\"MyId\\",\\"mainsnak\\":{\\"property\\":\\"P42\\",\\"datatype\\":\\"wikibase-item\\",\\"datavalue\\":{\\"value\\":{\\"id\\":\\"Q42\\",\\"numeric-id\\":42,\\"entity-type\\":\\"item\\"},\\"type\\":\\"wikibase-entityid\\"},\\"snaktype\\":\\"value\\"},\\"qualifiers-order\\":[\\"P42\\"],\\"type\\":\\"statement\\",\\"qualifiers\\":{\\"P42\\":[{\\"property\\":\\"P42\\",\\"datatype\\":\\"wikibase-item\\",\\"datavalue\\":{\\"value\\":{\\"id\\":\\"Q42\\",\\"numeric-id\\":42,\\"entity-type\\":\\"item\\"},\\"type\\":\\"wikibase-entityid\\"},\\"snaktype\\":\\"value\\"}]}}";
 
 	private final Statement smallStatement = new StatementImpl("MyId", StatementRank.PREFERRED, mainSnak,
 			Collections.emptyList(), Collections.emptyList(), subjet);
-	private final String JSON_SMALL_STATEMENT = "{\\"rank\\":\\"preferred\\",\\"value\\":{\\"value\\":{\\"id\\":\\"Q42\\",\\"numeric-id\\":42,\\"entity-type\\":\\"item\\"},\\"type\\":\\"wikibase-entityid\\"},\\"id\\":\\"MyId\\",\\"mainsnak\\":{\\"property\\":\\"P42\\",\\"datatype\\":\\"wikibase-item\\",\\"datavalue\\":{\\"value\\":{\\"id\\":\\"Q42\\",\\"numeric-id\\":42,\\"entity-type\\":\\"item\\"},\\"type\\":\\"wikibase-entityid\\"},\\"snaktype\\":\\"value\\"},\\"type\\":\\"statement\\"}";
+	private final String JSON_SMALL_STATEMENT = "{\\"rank\\":\\"preferred\\",\\"id\\":\\"MyId\\",\\"mainsnak\\":{\\"property\\":\\"P42\\",\\"datatype\\":\\"wikibase-item\\",\\"datavalue\\":{\\"value\\":{\\"id\\":\\"Q42\\",\\"numeric-id\\":42,\\"entity-type\\":\\"item\\"},\\"type\\":\\"wikibase-entityid\\"},\\"snaktype\\":\\"value\\"},\\"type\\":\\"statement\\"}";
 
 	@Test
 	public void gettersWorking() {