use of org.openrefine.wikidata.updates.TermedStatementEntityEdit in project OpenRefine by OpenRefine.
the class ReconEntityRewriterTest method testRewriteCreate.
@Test
public void testRewriteCreate() throws NewEntityNotCreatedYetException {
ItemIdValue subject = TestingData.newIdA;
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.TermedStatementEntityEdit in project OpenRefine by OpenRefine.
the class QuickStatementsExporterTest method testNoValue.
@Test
public void testNoValue() throws IOException {
PropertyIdValue pid = Datamodel.makeWikidataPropertyIdValue("P123");
Claim claim = Datamodel.makeClaim(qid1, Datamodel.makeNoValueSnak(pid), Collections.emptyList());
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\tP123\tnovalue\n", export(update));
}
use of org.openrefine.wikidata.updates.TermedStatementEntityEdit in project OpenRefine by OpenRefine.
the class QuickStatementsExporterTest method testSomeValue.
@Test
public void testSomeValue() throws IOException {
PropertyIdValue pid = Datamodel.makeWikidataPropertyIdValue("P123");
Claim claim = Datamodel.makeClaim(qid1, Datamodel.makeSomeValueSnak(pid), Collections.emptyList());
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\tP123\tsomevalue\n", export(update));
}
use of org.openrefine.wikidata.updates.TermedStatementEntityEdit in project OpenRefine by OpenRefine.
the class CommonDescriptionScrutinizerTest method testTooLong.
@Test
public void testTooLong() {
String description = "long description long description long description long description " + "long description long description long description long description " + "long description long description long description long description " + "long description long description long description long description";
TermedStatementEntityEdit update = new TermedStatementEntityEditBuilder(TestingData.newIdA).addDescription(Datamodel.makeMonolingualTextValue(description, "en"), true).build();
scrutinize(update);
assertWarningsRaised(CommonDescriptionScrutinizer.descTooLongType);
}
use of org.openrefine.wikidata.updates.TermedStatementEntityEdit in project OpenRefine by OpenRefine.
the class DifferenceWithinScrutinizerTest method testTrigger.
@Test
public void testTrigger() {
ItemIdValue idA = TestingData.existingId;
TimeValue lowerYear = new TimeValueImpl(1800, (byte) 10, (byte) 15, (byte) 0, (byte) 0, (byte) 0, (byte) 11, 0, 0, 0, TimeValue.CM_GREGORIAN_PRO);
TimeValue upperYear = new TimeValueImpl(2020, (byte) 10, (byte) 15, (byte) 0, (byte) 0, (byte) 0, (byte) 11, 0, 0, 0, TimeValue.CM_GREGORIAN_PRO);
ValueSnak value1 = Datamodel.makeValueSnak(lowerBoundPid, lowerYear);
ValueSnak value2 = Datamodel.makeValueSnak(upperBoundPid, upperYear);
Statement statement1 = new StatementImpl("P569", value1, idA);
Statement statement2 = new StatementImpl("P570", value2, idA);
TermedStatementEntityEdit updateA = new TermedStatementEntityEditBuilder(idA).addStatement(add(statement1)).addStatement(add(statement2)).build();
Snak propertyQualifier = Datamodel.makeValueSnak(propertyParameterPID, lowerBoundPid);
Snak minValueQualifier = Datamodel.makeValueSnak(minimumValuePID, minValue);
Snak maxValueQualifier = Datamodel.makeValueSnak(maximumValuePID, maxValue);
List<SnakGroup> constraintQualifiers = makeSnakGroupList(propertyQualifier, minValueQualifier, maxValueQualifier);
List<Statement> constraintDefinitions = constraintParameterStatementList(entityIdValue, constraintQualifiers);
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
when(fetcher.getConstraintsByType(upperBoundPid, DIFFERENCE_WITHIN_RANGE_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
setFetcher(fetcher);
scrutinize(updateA);
assertWarningsRaised(DifferenceWithinRangeScrutinizer.type);
}
Aggregations