@Test
public void testMergeExisting() {

	// Existing duplicates are removed in passing, when modifying statements
	// of a property
	Statement s1 = StatementBuilder.forSubjectAndProperty(Q1, P1)
			.withValue(Q1).withId("ID-s1").build();
	Statement s2 = StatementBuilder.forSubjectAndProperty(Q1, P1)
			.withValue(Q1).withId("ID-s2").build();
	Statement s3 = StatementBuilder.forSubjectAndProperty(Q1, P1)
			.withValue(Q2).build();
	ItemDocument currentDocument = ItemDocumentBuilder.forItemId(Q1)
			.withStatement(s1).withStatement(s2).build();
	StatementUpdate su = new StatementUpdate(currentDocument,
			Collections.singletonList(s3), Collections.emptyList());
	assertEquals(su.toDelete, Collections.singletonList("ID-s1"));
	assertEquals(1, su.toKeep.size());
	assertTrue(su.toKeep.containsKey(P1));
	assertEquals(2, su.toKeep.get(P1).size());
	assertEquals(s3, su.toKeep.get(P1).get(0).statement);
	assertTrue(su.toKeep.get(P1).get(0).write);
	assertEquals(s2, su.toKeep.get(P1).get(1).statement);
	assertFalse(su.toKeep.get(P1).get(1).write);
	assertFalse(su.isEmptyEdit());
}