use of org.openrefine.wikidata.updates.TermedStatementEntityEdit 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);
}
use of org.openrefine.wikidata.updates.TermedStatementEntityEdit 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);
}
use of org.openrefine.wikidata.updates.TermedStatementEntityEdit 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);
}
use of org.openrefine.wikidata.updates.TermedStatementEntityEdit in project OpenRefine by OpenRefine.
the class WikibaseSchemaTest method testEvaluate.
@Test
public void testEvaluate() throws IOException {
String serialized = TestingData.jsonFromFile("schema/inception.json");
WikibaseSchema schema = WikibaseSchema.reconstruct(serialized);
Engine engine = new Engine(project);
List<TermedStatementEntityEdit> updates = schema.evaluate(project, engine);
List<TermedStatementEntityEdit> expected = new ArrayList<>();
TermedStatementEntityEdit update1 = new TermedStatementEntityEditBuilder(qid1).addStatement(statementUpdate1).build();
expected.add(update1);
TermedStatementEntityEdit update2 = new TermedStatementEntityEditBuilder(qid2).addStatement(statementUpdate2).build();
expected.add(update2);
assertEquals(expected, updates);
}
use of org.openrefine.wikidata.updates.TermedStatementEntityEdit in project OpenRefine by OpenRefine.
the class RestrictedPositionScrutinizerTest method testNotRestricted.
@Test
public void testNotRestricted() {
ItemIdValue idA = TestingData.existingId;
Snak mainSnak = Datamodel.makeSomeValueSnak(propertyIdValue);
Statement statement = new StatementImpl("P22", mainSnak, idA);
TermedStatementEntityEdit update = new TermedStatementEntityEditBuilder(idA).addStatement(add(statement)).build();
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
when(fetcher.getConstraintsByType(propertyIdValue, SCOPE_CONSTRAINT_QID)).thenReturn(new ArrayList<>());
setFetcher(fetcher);
scrutinize(update);
assertNoWarningRaised();
}
Aggregations