use of org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder in project OpenRefine by OpenRefine.
the class ReconEntityRewriterTest method testRewriteUpdateOnPreviouslyCreatedEntity.
@Test
public void testRewriteUpdateOnPreviouslyCreatedEntity() throws NewEntityNotCreatedYetException {
ItemIdValue subject = TestingData.newIdA;
rewriter = new ReconEntityRewriter(library, subject);
library.setId(4567L, "Q1234");
TermedStatementEntityEdit update = new TermedStatementEntityEditBuilder(TestingData.newIdB).addDescription(Datamodel.makeMonolingualTextValue("beschreibung", "de"), false).addAlias(Datamodel.makeMonolingualTextValue("darstellung", "de")).build();
TermedStatementEntityEdit rewritten = rewriter.rewrite(update);
TermedStatementEntityEdit expected = new TermedStatementEntityEditBuilder(newlyCreated).addDescription(Datamodel.makeMonolingualTextValue("beschreibung", "de"), false).addAlias(Datamodel.makeMonolingualTextValue("darstellung", "de")).build();
assertEquals(rewritten, expected);
}
use of org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder in project OpenRefine by OpenRefine.
the class ReconEntityRewriterTest method testRewriteUpdateOnExistingEntity.
@Test
public void testRewriteUpdateOnExistingEntity() throws NewEntityNotCreatedYetException {
ItemIdValue subject = TestingData.matchedId;
rewriter = new ReconEntityRewriter(library, subject);
library.setId(4567L, "Q1234");
TermedStatementEntityEdit update = new TermedStatementEntityEditBuilder(subject).addStatement(TestingData.generateStatementAddition(subject, TestingData.newIdB)).addStatement(TestingData.generateStatementDeletion(subject, TestingData.existingId)).addLabel(Datamodel.makeMonolingualTextValue("label", "de"), true).addDescription(Datamodel.makeMonolingualTextValue("beschreibung", "de"), false).addAlias(Datamodel.makeMonolingualTextValue("darstellung", "de")).build();
TermedStatementEntityEdit rewritten = rewriter.rewrite(update);
TermedStatementEntityEdit expected = new TermedStatementEntityEditBuilder(subject).addStatement(TestingData.generateStatementAddition(subject, newlyCreated)).addStatement(TestingData.generateStatementDeletion(subject, TestingData.existingId)).addLabel(Datamodel.makeMonolingualTextValue("label", "de"), true).addDescription(Datamodel.makeMonolingualTextValue("beschreibung", "de"), false).addAlias(Datamodel.makeMonolingualTextValue("darstellung", "de")).build();
assertEquals(rewritten, expected);
}
use of org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder in project OpenRefine by OpenRefine.
the class ReconEntityRewriterTest method testRewritePropertyUpdateOnExistingEntity.
@Test
public void testRewritePropertyUpdateOnExistingEntity() throws NewEntityNotCreatedYetException {
PropertyIdValue subject = TestingData.matchedPropertyID;
rewriter = new ReconEntityRewriter(library, subject);
library.setId(7654L, "P1234");
TermedStatementEntityEdit update = new TermedStatementEntityEditBuilder(subject).addStatement(TestingData.generateStatementAddition(subject, TestingData.newPropertyIdB)).addStatement(TestingData.generateStatementDeletion(subject, TestingData.existingPropertyId)).addLabel(Datamodel.makeMonolingualTextValue("label", "de"), true).addDescription(Datamodel.makeMonolingualTextValue("beschreibung", "de"), false).addAlias(Datamodel.makeMonolingualTextValue("darstellung", "de")).build();
TermedStatementEntityEdit rewritten = rewriter.rewrite(update);
TermedStatementEntityEdit expected = new TermedStatementEntityEditBuilder(subject).addStatement(TestingData.generateStatementAddition(subject, newlyCreatedProperty)).addStatement(TestingData.generateStatementDeletion(subject, TestingData.existingPropertyId)).addLabel(Datamodel.makeMonolingualTextValue("label", "de"), true).addDescription(Datamodel.makeMonolingualTextValue("beschreibung", "de"), false).addAlias(Datamodel.makeMonolingualTextValue("darstellung", "de")).build();
assertEquals(rewritten, expected);
}
use of org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder 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.TermedStatementEntityEditBuilder 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));
}
Aggregations