use of org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue 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.wikidata.wdtk.datamodel.interfaces.PropertyIdValue 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.wikidata.wdtk.datamodel.interfaces.PropertyIdValue in project OpenRefine by OpenRefine.
the class ConstraintTest method setUp.
@BeforeMethod
public void setUp() {
Snak qualifierSnak1 = Datamodel.makeValueSnak(constraintException, exceptionValue);
List<Snak> qualifierSnakList1 = Collections.singletonList(qualifierSnak1);
Snak qualifierSnak2 = Datamodel.makeValueSnak(constraintStatus, statusValue);
List<Snak> qualifierSnakList2 = Collections.singletonList(qualifierSnak2);
SnakGroup qualifier1 = Datamodel.makeSnakGroup(qualifierSnakList1);
SnakGroup qualifier2 = Datamodel.makeSnakGroup(qualifierSnakList2);
List<SnakGroup> snakGroupList = Arrays.asList(qualifier1, qualifier2);
PropertyIdValue propertyIdValue = Datamodel.makeWikidataPropertyIdValue("P2302");
Snak mainSnak = Datamodel.makeValueSnak(propertyIdValue, itemIdValue);
Claim claim = Datamodel.makeClaim(itemIdValue, mainSnak, snakGroupList);
Reference reference = Datamodel.makeReference(snakGroupList);
List<Reference> referenceList = Collections.singletonList(reference);
statement = Datamodel.makeStatement(claim, referenceList, StatementRank.NORMAL, "P2302$77BD7FE4-C051-4776-855C-543F0CE697D0");
constraint = new Constraint(statement);
}
use of org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue in project OpenRefine by OpenRefine.
the class SchemaPropertyExtractorTest method testNoProperties.
@Test
public void testNoProperties() {
schema = new WikibaseSchema();
SchemaPropertyExtractor extractor = new SchemaPropertyExtractor();
Set<PropertyIdValue> propertyIdValues = extractor.getAllProperties(schema);
Assert.assertEquals(propertyIdValues, new HashSet<>());
}
use of org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue in project OpenRefine by OpenRefine.
the class EntityCacheTests method testGet.
@Test
public void testGet() throws MediaWikiApiErrorException, IOException {
WikibaseDataFetcher fetcher = mock(WikibaseDataFetcher.class);
PropertyIdValue id = Datamodel.makeWikidataPropertyIdValue("P42");
PropertyDocument doc = Datamodel.makePropertyDocument(id, Datamodel.makeDatatypeIdValue(DatatypeIdValue.DT_GEO_SHAPE));
when(fetcher.getEntityDocument(id.getId())).thenReturn(doc);
EntityCache SUT = new EntityCache(fetcher);
Assert.assertEquals(SUT.get(id), doc);
// try another time, it is now cached
Assert.assertEquals(SUT.get(id), doc);
// the fetcher was only called once thanks to caching
verify(fetcher, times(1)).getEntityDocument(id.getId());
}
Aggregations