StatementUpdate { @JsonIgnore public String getJsonUpdateString() { try { return mapper.writeValueAsString(this); } catch (JsonProcessingException e) { return ("Failed to serialize statement update to JSON: " + e.toString()); } } StatementUpdate(StatementDocument currentDocument,
			List<Statement> addStatements, List<Statement> deleteStatements); @JsonIgnore String getJsonUpdateString(); StatementDocument performEdit(WbEditingAction action, boolean editAsBot, String summary, List<String> tags); @JsonProperty("claims") @JsonInclude(Include.NON_EMPTY) List<Statement> getUpdatedStatements(); @JsonIgnore boolean isEmptyEdit(); void setGuidGenerator(GuidGenerator generator);  }
@Test public void testAddStatements() { Statement s1 = StatementBuilder.forSubjectAndProperty(Q1, P1) .withValue(Q1).withId("ID-s1").build(); Statement s2 = StatementBuilder.forSubjectAndProperty(Q1, P2) .withValue(Q1).withId("ID-s2").build(); Statement s3 = StatementBuilder.forSubjectAndProperty(Q1, P2) .withValue(Q2).build(); Statement s4 = StatementBuilder.forSubjectAndProperty(Q1, P2) .withValue(Q3).build(); ItemDocument currentDocument = ItemDocumentBuilder.forItemId(Q1) .withStatement(s1).withStatement(s2).build(); StatementUpdate su = new StatementUpdate(currentDocument, Arrays.asList(s3, s4), Collections.emptyList()); assertEquals(0, su.toDelete.size()); assertEquals(1, su.toKeep.size()); assertTrue(su.toKeep.containsKey(P2)); assertEquals(3, su.toKeep.get(P2).size()); assertEquals(s3, su.toKeep.get(P2).get(0).statement); assertTrue(su.toKeep.get(P2).get(0).write); assertEquals(s4, su.toKeep.get(P2).get(1).statement); assertTrue(su.toKeep.get(P2).get(1).write); assertEquals(s2, su.toKeep.get(P2).get(2).statement); assertFalse(su.toKeep.get(P2).get(2).write); assertEquals("{\"claims\":[" + JsonSerializer.getJsonString(s3) + "," + JsonSerializer.getJsonString(s4) + "]}", su.getJsonUpdateString()); }