use of org.openrefine.wikidata.qa.ConstraintFetcher in project OpenRefine by OpenRefine.
the class RestrictedValuesScrutinizerTest method testAllowedValue.
@Test
public void testAllowedValue() {
Snak mainSnak = Datamodel.makeValueSnak(allowedPropertyIdValue, allowedValue);
Statement statement = new StatementImpl("P1622", mainSnak, qid);
Snak qualifierSnak = Datamodel.makeValueSnak(itemParameterPID, allowedValue);
List<SnakGroup> constraintQualifiers = makeSnakGroupList(qualifierSnak);
List<Statement> constraintDefinitions = constraintParameterStatementList(allowedValueEntity, constraintQualifiers);
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
when(fetcher.getConstraintsByType(allowedPropertyIdValue, ALLOWED_VALUES_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
when(fetcher.getConstraintsByType(allowedPropertyIdValue, DISALLOWED_VALUES_CONSTRAINT_QID)).thenReturn(new ArrayList<>());
setFetcher(fetcher);
scrutinize(statement);
assertNoWarningRaised();
}
use of org.openrefine.wikidata.qa.ConstraintFetcher in project OpenRefine by OpenRefine.
the class RestrictedValuesScrutinizerTest method testAllowedValueFailing.
@Test
public void testAllowedValueFailing() {
Snak mainSnak = Datamodel.makeSomeValueSnak(allowedPropertyIdValue);
Statement statement = new StatementImpl("P1622", mainSnak, qid);
Snak qualifierSnak = Datamodel.makeValueSnak(itemParameterPID, allowedValue);
List<SnakGroup> constraintQualifiers = makeSnakGroupList(qualifierSnak);
List<Statement> constraintDefinitions = constraintParameterStatementList(allowedValueEntity, constraintQualifiers);
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
when(fetcher.getConstraintsByType(allowedPropertyIdValue, ALLOWED_VALUES_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
when(fetcher.getConstraintsByType(allowedPropertyIdValue, DISALLOWED_VALUES_CONSTRAINT_QID)).thenReturn(new ArrayList<>());
setFetcher(fetcher);
scrutinize(statement);
assertWarningsRaised(RestrictedValuesScrutinizer.type);
}
use of org.openrefine.wikidata.qa.ConstraintFetcher in project OpenRefine by OpenRefine.
the class RestrictedValuesScrutinizerTest method testNoConstraint.
@Test
public void testNoConstraint() {
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
when(fetcher.getConstraintsByType(any(), eq(ALLOWED_VALUES_CONSTRAINT_QID))).thenReturn(new ArrayList<>());
when(fetcher.getConstraintsByType(any(), eq(DISALLOWED_VALUES_CONSTRAINT_QID))).thenReturn(new ArrayList<>());
setFetcher(fetcher);
scrutinize(TestingData.generateStatement(qid, Datamodel.makeWikidataPropertyIdValue("P28732"), qid));
assertNoWarningRaised();
}
Aggregations