Search in sources :

Example 41 with TermedStatementEntityEditBuilder

use of org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder in project OpenRefine by OpenRefine.

the class UpdateSchedulerTest method testNewItemNotMentioned.

@Test
public void testNewItemNotMentioned() throws ImpossibleSchedulingException {
    TermedStatementEntityEdit updateA = new TermedStatementEntityEditBuilder(existingIdA).addStatement(sAtoNewA).build();
    List<TermedStatementEntityEdit> scheduled = schedule(updateA);
    TermedStatementEntityEdit newUpdate = new TermedStatementEntityEditBuilder(newIdA).build();
    assertEquals(Arrays.asList(newUpdate, updateA), scheduled);
}
Also used : TermedStatementEntityEditBuilder(org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder) TermedStatementEntityEdit(org.openrefine.wikidata.updates.TermedStatementEntityEdit) Test(org.testng.annotations.Test)

Example 42 with TermedStatementEntityEditBuilder

use of org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder in project OpenRefine by OpenRefine.

the class UpdateSchedulerTest method testMergeNew.

@Test
public void testMergeNew() throws ImpossibleSchedulingException {
    TermedStatementEntityEdit update1 = new TermedStatementEntityEditBuilder(newIdA).addLabel(Datamodel.makeMonolingualTextValue("hello", "fr"), true).addStatement(sNewAtoB).build();
    TermedStatementEntityEdit update2 = new TermedStatementEntityEditBuilder(newIdA).addLabel(Datamodel.makeMonolingualTextValue("hello", "fr"), true).build();
    TermedStatementEntityEdit merged = update1.merge(update2);
    assertEquals(Collections.singletonList(merged), schedule(update1, update2));
}
Also used : TermedStatementEntityEditBuilder(org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder) TermedStatementEntityEdit(org.openrefine.wikidata.updates.TermedStatementEntityEdit) Test(org.testng.annotations.Test)

Example 43 with TermedStatementEntityEditBuilder

use of org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder in project OpenRefine by OpenRefine.

the class WikibaseAPIUpdateSchedulerTest method testUpdateIsNotSplit.

@Test
public void testUpdateIsNotSplit() throws ImpossibleSchedulingException {
    TermedStatementEntityEdit updateA = new TermedStatementEntityEditBuilder(existingIdA).addStatement(sAtoNewA).addStatement(sAtoNewB).build();
    TermedStatementEntityEdit newUpdateA = new TermedStatementEntityEditBuilder(newIdA).build();
    TermedStatementEntityEdit newUpdateB = new TermedStatementEntityEditBuilder(newIdB).build();
    List<TermedStatementEntityEdit> scheduled = schedule(updateA);
    assertSetEquals(Arrays.asList(newUpdateA, newUpdateB, updateA), scheduled);
}
Also used : TermedStatementEntityEditBuilder(org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder) TermedStatementEntityEdit(org.openrefine.wikidata.updates.TermedStatementEntityEdit) Test(org.testng.annotations.Test)

Example 44 with TermedStatementEntityEditBuilder

use of org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder in project OpenRefine by OpenRefine.

the class WikibaseAPIUpdateSchedulerTest method testOrderPreserved.

@Test
public void testOrderPreserved() throws ImpossibleSchedulingException {
    TermedStatementEntityEdit updateA = new TermedStatementEntityEditBuilder(existingIdA).addStatement(sAtoB).build();
    TermedStatementEntityEdit updateB = new TermedStatementEntityEditBuilder(existingIdB).addStatement(sBtoA).build();
    List<TermedStatementEntityEdit> scheduled = schedule(updateA, updateB);
    assertEquals(Arrays.asList(updateA, updateB), scheduled);
}
Also used : TermedStatementEntityEditBuilder(org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder) TermedStatementEntityEdit(org.openrefine.wikidata.updates.TermedStatementEntityEdit) Test(org.testng.annotations.Test)

Example 45 with TermedStatementEntityEditBuilder

use of org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder in project OpenRefine by OpenRefine.

the class WikibaseAPIUpdateSchedulerTest method testMixedUpdate.

@Test
public void testMixedUpdate() throws ImpossibleSchedulingException {
    TermedStatementEntityEdit updateA = new TermedStatementEntityEditBuilder(existingIdA).addStatement(sAtoNewA).addStatement(sAtoNewB).addStatement(sAtoB).build();
    TermedStatementEntityEdit newUpdateA = new TermedStatementEntityEditBuilder(newIdA).addStatement(sNewAtoB).build();
    TermedStatementEntityEdit newUpdateB = new TermedStatementEntityEditBuilder(newIdB).build();
    List<TermedStatementEntityEdit> scheduled = schedule(updateA, newUpdateA);
    assertEquals(Arrays.asList(newUpdateA, newUpdateB, updateA), scheduled);
}
Also used : TermedStatementEntityEditBuilder(org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder) TermedStatementEntityEdit(org.openrefine.wikidata.updates.TermedStatementEntityEdit) Test(org.testng.annotations.Test)

Aggregations

TermedStatementEntityEditBuilder (org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder)107 TermedStatementEntityEdit (org.openrefine.wikidata.updates.TermedStatementEntityEdit)102 Test (org.testng.annotations.Test)101 ItemIdValue (org.wikidata.wdtk.datamodel.interfaces.ItemIdValue)57 Statement (org.wikidata.wdtk.datamodel.interfaces.Statement)56 ConstraintFetcher (org.openrefine.wikidata.qa.ConstraintFetcher)52 Snak (org.wikidata.wdtk.datamodel.interfaces.Snak)49 StatementImpl (org.wikidata.wdtk.datamodel.implementation.StatementImpl)44 SnakGroup (org.wikidata.wdtk.datamodel.interfaces.SnakGroup)34 ValueSnak (org.wikidata.wdtk.datamodel.interfaces.ValueSnak)18 WikidataRefineTest (org.openrefine.wikidata.testing.WikidataRefineTest)13 ArrayList (java.util.ArrayList)11 StatementEdit (org.openrefine.wikidata.updates.StatementEdit)9 JacksonSerializationTest (org.openrefine.wikidata.testing.JacksonSerializationTest)7 NoValueSnak (org.wikidata.wdtk.datamodel.interfaces.NoValueSnak)5 ReconEntityIdValue (org.openrefine.wikidata.schema.entityvalues.ReconEntityIdValue)4 Claim (org.wikidata.wdtk.datamodel.interfaces.Claim)4 EntityIdValue (org.wikidata.wdtk.datamodel.interfaces.EntityIdValue)4 ItemDocument (org.wikidata.wdtk.datamodel.interfaces.ItemDocument)3 Engine (com.google.refine.browsing.Engine)2