use of org.openrefine.wikidata.updates.TermedStatementEntityEdit in project OpenRefine by OpenRefine.
the class QuantityScrutinizerTest method testBoundsDisallowed.
@Test
public void testBoundsDisallowed() {
ItemIdValue idA = TestingData.existingId;
Snak mainSnak = Datamodel.makeValueSnak(propertyIdValue, valueWithBounds);
Statement statement = new StatementImpl("P1083", mainSnak, idA);
TermedStatementEntityEdit update = new TermedStatementEntityEditBuilder(idA).addStatement(add(statement)).build();
List<Statement> constraintDefinitions = constraintParameterStatementList(noBoundsEntity, new ArrayList<>());
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
when(fetcher.getConstraintsByType(propertyIdValue, NO_BOUNDS_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
setFetcher(fetcher);
scrutinize(update);
assertWarningsRaised(QuantityScrutinizer.boundsDisallowedType);
}
use of org.openrefine.wikidata.updates.TermedStatementEntityEdit in project OpenRefine by OpenRefine.
the class QuantityScrutinizerTest method testTrailingZeros.
@Test
public void testTrailingZeros() {
ItemIdValue idA = TestingData.existingId;
Snak mainSnak = Datamodel.makeValueSnak(propertyIdValue, trailingZeros);
Statement statement = new StatementImpl("P1083", mainSnak, idA);
TermedStatementEntityEdit update = new TermedStatementEntityEditBuilder(idA).addStatement(add(statement)).build();
List<Statement> constraintDefinitions = constraintParameterStatementList(integerValueEntity, new ArrayList<>());
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
when(fetcher.getConstraintsByType(propertyIdValue, INTEGER_VALUED_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
setFetcher(fetcher);
scrutinize(update);
assertWarningsRaised(QuantityScrutinizer.integerConstraintType);
}
use of org.openrefine.wikidata.updates.TermedStatementEntityEdit in project OpenRefine by OpenRefine.
the class QuantityScrutinizerTest method testWrongUnit.
@Test
public void testWrongUnit() {
ItemIdValue idA = TestingData.existingId;
Snak mainSnak = Datamodel.makeValueSnak(propertyIdValue, wrongUnitValue);
Statement statement = new StatementImpl("P1083", mainSnak, idA);
TermedStatementEntityEdit update = new TermedStatementEntityEditBuilder(idA).addStatement(add(statement)).build();
Snak qualifierSnak = Datamodel.makeValueSnak(itemParameterPID, allowedUnit);
List<Snak> qualifierSnakList = Collections.singletonList(qualifierSnak);
SnakGroup snakGroup1 = Datamodel.makeSnakGroup(qualifierSnakList);
List<SnakGroup> constraintQualifiers = Collections.singletonList(snakGroup1);
List<Statement> constraintDefinitions = constraintParameterStatementList(allowedUnitEntity, constraintQualifiers);
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
when(fetcher.getConstraintsByType(propertyIdValue, ALLOWED_UNITS_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
setFetcher(fetcher);
scrutinize(update);
assertWarningsRaised(QuantityScrutinizer.invalidUnitType);
}
use of org.openrefine.wikidata.updates.TermedStatementEntityEdit in project OpenRefine by OpenRefine.
the class WikibaseSchemaTest method testEvaluateRespectsFacets.
@Test
public void testEvaluateRespectsFacets() throws IOException {
String serialized = TestingData.jsonFromFile("schema/inception.json");
WikibaseSchema schema = WikibaseSchema.reconstruct(serialized);
Engine engine = new Engine(project);
EngineConfig engineConfig = EngineConfig.reconstruct("{\n" + " \"mode\": \"row-based\",\n" + " \"facets\": [\n" + " {\n" + " \"mode\": \"text\",\n" + " \"invert\": false,\n" + " \"caseSensitive\": false,\n" + " \"query\": \"www\",\n" + " \"name\": \"reference\",\n" + " \"type\": \"text\",\n" + " \"columnName\": \"reference\"\n" + " }\n" + " ]\n" + " }");
engine.initializeFromConfig(engineConfig);
List<TermedStatementEntityEdit> updates = schema.evaluate(project, engine);
List<TermedStatementEntityEdit> expected = new ArrayList<>();
TermedStatementEntityEdit update1 = new TermedStatementEntityEditBuilder(qid1).addStatement(statementUpdate1).build();
expected.add(update1);
assertEquals(expected, updates);
}
use of org.openrefine.wikidata.updates.TermedStatementEntityEdit in project OpenRefine by OpenRefine.
the class UpdateSchedulerTest method testNewItemMentioned.
@Test
public void testNewItemMentioned() throws ImpossibleSchedulingException {
TermedStatementEntityEdit updateA = new TermedStatementEntityEditBuilder(existingIdA).addStatement(sAtoNewA).build();
TermedStatementEntityEdit newUpdate = new TermedStatementEntityEditBuilder(newIdA).addStatement(sNewAtoB).build();
List<TermedStatementEntityEdit> scheduled = schedule(updateA, newUpdate);
assertEquals(Arrays.asList(newUpdate, updateA), scheduled);
}
Aggregations