Search in sources :

Example 56 with ConstraintFetcher

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();
}
Also used : Snak(org.wikidata.wdtk.datamodel.interfaces.Snak) ConstraintFetcher(org.openrefine.wikidata.qa.ConstraintFetcher) Statement(org.wikidata.wdtk.datamodel.interfaces.Statement) StatementImpl(org.wikidata.wdtk.datamodel.implementation.StatementImpl) SnakGroup(org.wikidata.wdtk.datamodel.interfaces.SnakGroup) Test(org.testng.annotations.Test)

Example 57 with ConstraintFetcher

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);
}
Also used : Snak(org.wikidata.wdtk.datamodel.interfaces.Snak) ConstraintFetcher(org.openrefine.wikidata.qa.ConstraintFetcher) Statement(org.wikidata.wdtk.datamodel.interfaces.Statement) StatementImpl(org.wikidata.wdtk.datamodel.implementation.StatementImpl) SnakGroup(org.wikidata.wdtk.datamodel.interfaces.SnakGroup) Test(org.testng.annotations.Test)

Example 58 with ConstraintFetcher

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();
}
Also used : ConstraintFetcher(org.openrefine.wikidata.qa.ConstraintFetcher) Test(org.testng.annotations.Test)

Aggregations

ConstraintFetcher (org.openrefine.wikidata.qa.ConstraintFetcher)58 Test (org.testng.annotations.Test)58 Statement (org.wikidata.wdtk.datamodel.interfaces.Statement)56 TermedStatementEntityEdit (org.openrefine.wikidata.updates.TermedStatementEntityEdit)52 TermedStatementEntityEditBuilder (org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder)52 ItemIdValue (org.wikidata.wdtk.datamodel.interfaces.ItemIdValue)52 Snak (org.wikidata.wdtk.datamodel.interfaces.Snak)51 StatementImpl (org.wikidata.wdtk.datamodel.implementation.StatementImpl)48 SnakGroup (org.wikidata.wdtk.datamodel.interfaces.SnakGroup)36 ValueSnak (org.wikidata.wdtk.datamodel.interfaces.ValueSnak)18 NoValueSnak (org.wikidata.wdtk.datamodel.interfaces.NoValueSnak)5 ArrayList (java.util.ArrayList)4 TimeValueImpl (org.wikidata.wdtk.datamodel.implementation.TimeValueImpl)2 TimeValue (org.wikidata.wdtk.datamodel.interfaces.TimeValue)2