use of org.openrefine.wikidata.updates.TermedStatementEntityEdit in project OpenRefine by OpenRefine.
the class QuickStatementsExporterTest method testDeleteStatement.
@Test
public void testDeleteStatement() throws IOException {
TermedStatementEntityEdit update = new TermedStatementEntityEditBuilder(qid1).addStatement(new StatementEdit(TestingData.generateStatement(qid1, qid2), StatementMerger.FORMER_DEFAULT_STRATEGY, StatementEditingMode.DELETE)).build();
assertEquals("- Q1377\tP38\tQ865528\n", export(update));
}
use of org.openrefine.wikidata.updates.TermedStatementEntityEdit in project OpenRefine by OpenRefine.
the class QuickStatementsExporterTest method testImpossibleScheduling.
@Test
public void testImpossibleScheduling() throws IOException {
StatementEdit sNewAtoNewB = TestingData.generateStatementAddition(newIdA, newIdB);
TermedStatementEntityEdit update = new TermedStatementEntityEditBuilder(newIdA).addStatement(sNewAtoNewB).build();
assertEquals(QuickStatementsExporter.impossibleSchedulingErrorMessage, export(update));
}
use of org.openrefine.wikidata.updates.TermedStatementEntityEdit in project OpenRefine by OpenRefine.
the class QuickStatementsExporterTest method testQualifier.
@Test
public void testQualifier() throws IOException {
Statement baseStatement = TestingData.generateStatement(qid1, qid2);
Statement otherStatement = TestingData.generateStatement(qid2, qid1);
Snak qualifierSnak = otherStatement.getClaim().getMainSnak();
SnakGroup group = Datamodel.makeSnakGroup(Collections.singletonList(qualifierSnak));
Claim claim = Datamodel.makeClaim(qid1, baseStatement.getClaim().getMainSnak(), Collections.singletonList(group));
Statement statement = Datamodel.makeStatement(claim, Collections.emptyList(), StatementRank.NORMAL, "");
StatementEdit statementUpdate = new StatementEdit(statement, StatementMerger.FORMER_DEFAULT_STRATEGY, StatementEditingMode.ADD_OR_MERGE);
TermedStatementEntityEdit update = new TermedStatementEntityEditBuilder(qid1).addStatement(statementUpdate).build();
assertEquals("Q1377\tP38\tQ865528\tP38\tQ1377\n", export(update));
}
use of org.openrefine.wikidata.updates.TermedStatementEntityEdit in project OpenRefine by OpenRefine.
the class QuickStatementsExporterTest method testReferences.
/**
* issue #2320
*
* A statement with different references should be duplicated, but each with a different reference.
*/
@Test
public void testReferences() throws IOException {
Statement baseStatement = TestingData.generateStatement(qid1, qid2);
Statement otherStatement = TestingData.generateStatement(qid2, qid1);
Snak snak1 = baseStatement.getClaim().getMainSnak();
Snak snak2 = otherStatement.getClaim().getMainSnak();
SnakGroup group1 = Datamodel.makeSnakGroup(Collections.singletonList(snak1));
SnakGroup group2 = Datamodel.makeSnakGroup(Collections.singletonList(snak2));
Claim claim = Datamodel.makeClaim(qid1, baseStatement.getClaim().getMainSnak(), Collections.singletonList(group2));
Reference reference1 = Datamodel.makeReference(Collections.singletonList(group1));
Reference reference2 = Datamodel.makeReference(Collections.singletonList(group2));
Statement statement = Datamodel.makeStatement(claim, Arrays.asList(reference1, reference2), StatementRank.NORMAL, "");
StatementEdit statementUpdate = new StatementEdit(statement, StatementMerger.FORMER_DEFAULT_STRATEGY, StatementEditingMode.ADD_OR_MERGE);
TermedStatementEntityEdit update = new TermedStatementEntityEditBuilder(qid1).addStatement(statementUpdate).build();
assertEquals("Q1377\tP38\tQ865528\tP38\tQ1377\tS38\tQ865528\n" + "Q1377\tP38\tQ865528\tP38\tQ1377\tS38\tQ1377\n", export(update));
}
use of org.openrefine.wikidata.updates.TermedStatementEntityEdit in project OpenRefine by OpenRefine.
the class QuickStatementsExporterTest method testNameDesc.
@Test
public void testNameDesc() throws IOException {
/**
* Adding labels and description without overriding is not supported by QS, so we fall back on adding them with
* overriding.
*/
TermedStatementEntityEdit update = new TermedStatementEntityEditBuilder(qid1).addLabel(Datamodel.makeMonolingualTextValue("some label", "en"), true).addDescription(Datamodel.makeMonolingualTextValue("some description", "en"), true).build();
assertEquals("Q1377\tLen\t\"some label\"\n" + "Q1377\tDen\t\"some description\"\n", export(update));
}
Aggregations