Search in sources :

Example 1 with ItemUpdate

use of org.wikidata.wdtk.datamodel.interfaces.ItemUpdate in project OpenRefine by OpenRefine.

the class TermedStatementEntityEditTest method testToEntityUpdate.

@Test
public void testToEntityUpdate() {
    TermedStatementEntityEdit edit = new TermedStatementEntityEditBuilder(existingSubject).addAlias(Datamodel.makeMonolingualTextValue("alias", "en")).addStatement(statementUpdate1).build();
    ItemDocument itemDocument = ItemDocumentBuilder.forItemId(existingSubject).withStatement(statement2).withLabel(Datamodel.makeMonolingualTextValue("label", "en")).build();
    ItemUpdate update = (ItemUpdate) edit.toEntityUpdate(itemDocument);
    assertEquals(update.getEntityId(), existingSubject);
    assertEquals(update.getAliases(), Collections.singletonMap("en", Datamodel.makeAliasUpdate(Collections.singletonList(Datamodel.makeMonolingualTextValue("alias", "en")), Collections.emptyList())));
    assertTrue(update.getDescriptions().isEmpty());
    assertTrue(update.getLabels().isEmpty());
    assertEquals(update.getStatements(), Datamodel.makeStatementUpdate(Collections.singletonList(statement1), Collections.emptyList(), Collections.emptySet()));
}
Also used : ItemDocument(org.wikidata.wdtk.datamodel.interfaces.ItemDocument) ItemUpdate(org.wikidata.wdtk.datamodel.interfaces.ItemUpdate) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)1 ItemDocument (org.wikidata.wdtk.datamodel.interfaces.ItemDocument)1 ItemUpdate (org.wikidata.wdtk.datamodel.interfaces.ItemUpdate)1