Move findValues method to EditScrtuinzer (#2941)
* Move findValues method to EditScrtuinzer As findValues method is not concerned with fetching, therefore moving it to EditScrtuinizer * updated test classes accordingly * updated test classes accordingly * test files updated after shifting the findValues method
This commit is contained in:
parent
a3fab26cca
commit
fe275ae634
@ -24,9 +24,7 @@
|
||||
package org.openrefine.wikidata.qa;
|
||||
|
||||
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.SnakGroup;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Statement;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Value;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -49,15 +47,4 @@ public interface ConstraintFetcher {
|
||||
*/
|
||||
List<Statement> getConstraintsByType(PropertyIdValue pid, String qid);
|
||||
|
||||
/**
|
||||
* Returns the values of a given property in qualifiers
|
||||
*
|
||||
* @param groups
|
||||
* the qualifiers
|
||||
* @param pid
|
||||
* the property to filter on
|
||||
* @return
|
||||
*/
|
||||
List<Value> findValues(List<SnakGroup> groups, String pid);
|
||||
|
||||
}
|
||||
|
@ -27,12 +27,10 @@ import org.openrefine.wikidata.utils.EntityCache;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.PropertyDocument;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Snak;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.SnakGroup;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Statement;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.StatementGroup;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.StatementRank;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Value;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -118,25 +116,4 @@ public class WikidataConstraintFetcher implements ConstraintFetcher {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the values of a given property in qualifiers
|
||||
*
|
||||
* @param groups
|
||||
* the qualifiers
|
||||
* @param pid
|
||||
* the property to filter on
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Value> findValues(List<SnakGroup> groups, String pid) {
|
||||
List<Value> results = new ArrayList<>();
|
||||
for (SnakGroup group : groups) {
|
||||
if (group.getProperty().getId().equals(pid)) {
|
||||
for (Snak snak : group.getSnaks())
|
||||
results.add(snak.getValue());
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,9 +23,9 @@ public class DifferenceWithinRangeScrutinizer extends EditScrutinizer {
|
||||
DifferenceWithinRangeConstraint(Statement statement) {
|
||||
List<SnakGroup> specs = statement.getClaim().getQualifiers();
|
||||
if (specs != null) {
|
||||
List<Value> lowerValueProperty = _fetcher.findValues(specs, DIFFERENCE_WITHIN_RANGE_CONSTRAINT_PID);
|
||||
List<Value> minValue = _fetcher.findValues(specs, MINIMUM_VALUE_PID);
|
||||
List<Value> maxValue = _fetcher.findValues(specs, MAXIMUM_VALUE_PID);
|
||||
List<Value> lowerValueProperty = findValues(specs, DIFFERENCE_WITHIN_RANGE_CONSTRAINT_PID);
|
||||
List<Value> minValue = findValues(specs, MINIMUM_VALUE_PID);
|
||||
List<Value> maxValue = findValues(specs, MAXIMUM_VALUE_PID);
|
||||
if (!lowerValueProperty.isEmpty()) {
|
||||
lowerPropertyIdValue = (PropertyIdValue) lowerValueProperty.get(0);
|
||||
}
|
||||
|
@ -28,6 +28,12 @@ import org.openrefine.wikidata.qa.QAWarning;
|
||||
import org.openrefine.wikidata.qa.QAWarning.Severity;
|
||||
import org.openrefine.wikidata.qa.QAWarningStore;
|
||||
import org.openrefine.wikidata.updates.ItemUpdate;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Snak;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.SnakGroup;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Value;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Inspects an edit batch and emits warnings.
|
||||
@ -125,4 +131,24 @@ public abstract class EditScrutinizer {
|
||||
protected void critical(String type) {
|
||||
addIssue(type, null, QAWarning.Severity.CRITICAL, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the values of a given property in qualifiers
|
||||
*
|
||||
* @param groups
|
||||
* the qualifiers
|
||||
* @param pid
|
||||
* the property to filter on
|
||||
* @return
|
||||
*/
|
||||
protected List<Value> findValues(List<SnakGroup> groups, String pid) {
|
||||
List<Value> results = new ArrayList<>();
|
||||
for (SnakGroup group : groups) {
|
||||
if (group.getProperty().getId().equals(pid)) {
|
||||
for (Snak snak : group.getSnaks())
|
||||
results.add(snak.getValue());
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class EntityTypeScrutinizer extends SnakScrutinizer {
|
||||
List<SnakGroup> constraint = statementList.get(0).getClaim().getQualifiers();
|
||||
boolean isUsable = true;
|
||||
if (constraint != null) {
|
||||
isUsable = _fetcher.findValues(constraint, ALLOWED_ENTITY_TYPES_PID).contains(
|
||||
isUsable = findValues(constraint, ALLOWED_ENTITY_TYPES_PID).contains(
|
||||
Datamodel.makeWikidataItemIdValue(ALLOWED_ITEM_TYPE_QID));
|
||||
}
|
||||
if (!isUsable) {
|
||||
|
@ -60,7 +60,7 @@ public class FormatScrutinizer extends SnakScrutinizer {
|
||||
FormatConstraint(Statement statement) {
|
||||
List<SnakGroup> constraint = statement.getClaim().getQualifiers();
|
||||
if (constraint != null) {
|
||||
List<Value> regexes = _fetcher.findValues(constraint, FORMAT_REGEX_PID);
|
||||
List<Value> regexes = findValues(constraint, FORMAT_REGEX_PID);
|
||||
if (!regexes.isEmpty()) {
|
||||
regularExpressionFormat = ((StringValue) regexes.get(0)).getString();
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class InverseConstraintScrutinizer extends StatementScrutinizer {
|
||||
List<SnakGroup> specs = statement.getClaim().getQualifiers();
|
||||
|
||||
if (specs != null) {
|
||||
List<Value> inverses = _fetcher.findValues(specs, INVERSE_PROPERTY_PID);
|
||||
List<Value> inverses = findValues(specs, INVERSE_PROPERTY_PID);
|
||||
if (!inverses.isEmpty()) {
|
||||
propertyParameterValue = (PropertyIdValue) inverses.get(0);
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public class QualifierCompatibilityScrutinizer extends StatementScrutinizer {
|
||||
allowedProperties = new HashSet<>();
|
||||
List<SnakGroup> specs = statement.getClaim().getQualifiers();
|
||||
if (specs != null) {
|
||||
List<Value> properties = _fetcher.findValues(specs, ALLOWED_QUALIFIERS_CONSTRAINT_PID);
|
||||
List<Value> properties = findValues(specs, ALLOWED_QUALIFIERS_CONSTRAINT_PID);
|
||||
allowedProperties = properties.stream()
|
||||
.filter(e -> e != null)
|
||||
.map(e -> (PropertyIdValue) e)
|
||||
@ -75,7 +75,7 @@ public class QualifierCompatibilityScrutinizer extends StatementScrutinizer {
|
||||
mandatoryProperties = new HashSet<>();
|
||||
List<SnakGroup> specs = statement.getClaim().getQualifiers();
|
||||
if (specs != null) {
|
||||
List<Value> properties = _fetcher.findValues(specs, MANDATORY_QUALIFIERS_CONSTRAINT_PID);
|
||||
List<Value> properties = findValues(specs, MANDATORY_QUALIFIERS_CONSTRAINT_PID);
|
||||
mandatoryProperties = properties.stream()
|
||||
.filter(e -> e != null)
|
||||
.map(e -> (PropertyIdValue) e)
|
||||
|
@ -38,7 +38,7 @@ public class QuantityScrutinizer extends SnakScrutinizer {
|
||||
AllowedUnitsConstraint(Statement statement) {
|
||||
List<SnakGroup> specs = statement.getClaim().getQualifiers();
|
||||
if (specs != null) {
|
||||
List<Value> properties = _fetcher.findValues(specs, ALLOWED_UNITS_CONSTRAINT_PID);
|
||||
List<Value> properties = findValues(specs, ALLOWED_UNITS_CONSTRAINT_PID);
|
||||
allowedUnits = properties.stream()
|
||||
.map(e -> e == null ? null : (ItemIdValue) e)
|
||||
.collect(Collectors.toSet());
|
||||
|
@ -57,7 +57,7 @@ public class RestrictedPositionScrutinizer extends StatementScrutinizer {
|
||||
ItemIdValue targetValue = Datamodel.makeWikidataItemIdValue(SCOPE_CONSTRAINT_VALUE_QID);
|
||||
ItemIdValue targetQualifier = Datamodel.makeWikidataItemIdValue(SCOPE_CONSTRAINT_QUALIFIER_QID);
|
||||
ItemIdValue targetReference = Datamodel.makeWikidataItemIdValue(SCOPE_CONSTRAINT_REFERENCE_QID);
|
||||
List<Value> snakValues = _fetcher.findValues(specs, SCOPE_CONSTRAINT_PID);
|
||||
List<Value> snakValues = findValues(specs, SCOPE_CONSTRAINT_PID);
|
||||
isAllowedAsValue = snakValues.contains(targetValue);
|
||||
isAllowedAsQualifier = snakValues.contains(targetQualifier);
|
||||
isAllowedAsReference = snakValues.contains(targetReference);
|
||||
|
@ -27,7 +27,7 @@ public class RestrictedValuesScrutinizer extends SnakScrutinizer {
|
||||
AllowedValueConstraint(Statement statement) {
|
||||
List<SnakGroup> specs = statement.getClaim().getQualifiers();
|
||||
if (specs != null) {
|
||||
List<Value> properties = _fetcher.findValues(specs, ALLOWED_VALUES_CONSTRAINT_PID);
|
||||
List<Value> properties = findValues(specs, ALLOWED_VALUES_CONSTRAINT_PID);
|
||||
allowedValues = properties.stream().collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
@ -38,7 +38,7 @@ public class RestrictedValuesScrutinizer extends SnakScrutinizer {
|
||||
DisallowedValueConstraint(Statement statement) {
|
||||
List<SnakGroup> specs = statement.getClaim().getQualifiers();
|
||||
if (specs != null) {
|
||||
List<Value> properties = _fetcher.findValues(specs, DISALLOWED_VALUES_CONSTRAINT_PID);
|
||||
List<Value> properties = findValues(specs, DISALLOWED_VALUES_CONSTRAINT_PID);
|
||||
disallowedValues = properties.stream().collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ import org.wikidata.wdtk.datamodel.interfaces.TimeValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.ValueSnak;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
@ -64,9 +63,6 @@ public class DifferenceWithinScrutinizerTest extends ScrutinizerTest{
|
||||
|
||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||
when(fetcher.getConstraintsByType(upperBoundPid, DIFFERENCE_WITHIN_RANGE_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
|
||||
when(fetcher.findValues(constraintQualifiers, DIFFERENCE_WITHIN_RANGE_CONSTRAINT_PID)).thenReturn(Collections.singletonList(lowerBoundPid));
|
||||
when(fetcher.findValues(constraintQualifiers, MINIMUM_VALUE_PID)).thenReturn(Collections.singletonList(minValue));
|
||||
when(fetcher.findValues(constraintQualifiers, MAXIMUM_VALUE_PID)).thenReturn(Collections.singletonList(maxValue));
|
||||
setFetcher(fetcher);
|
||||
|
||||
scrutinize(updateA);
|
||||
@ -92,9 +88,6 @@ public class DifferenceWithinScrutinizerTest extends ScrutinizerTest{
|
||||
|
||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||
when(fetcher.getConstraintsByType(upperBoundPid, DIFFERENCE_WITHIN_RANGE_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
|
||||
when(fetcher.findValues(constraintQualifiers, DIFFERENCE_WITHIN_RANGE_CONSTRAINT_PID)).thenReturn(Collections.singletonList(lowerBoundPid));
|
||||
when(fetcher.findValues(constraintQualifiers, MINIMUM_VALUE_PID)).thenReturn(Collections.singletonList(minValue));
|
||||
when(fetcher.findValues(constraintQualifiers, MAXIMUM_VALUE_PID)).thenReturn(Collections.singletonList(maxValue));
|
||||
setFetcher(fetcher);
|
||||
|
||||
scrutinize(updateA);
|
||||
|
@ -50,7 +50,7 @@ public class EntityTypeScrutinizerTest extends StatementScrutinizerTest {
|
||||
|
||||
ItemUpdate update = new ItemUpdateBuilder(idA).addStatement(statement).build();
|
||||
|
||||
Snak qualifierSnak = Datamodel.makeValueSnak(itemParameterPID, itemValue);
|
||||
Snak qualifierSnak = Datamodel.makeValueSnak(itemParameterPID, allowedValue);
|
||||
List<Snak> qualifierSnakList = Collections.singletonList(qualifierSnak);
|
||||
SnakGroup qualifierSnakGroup = Datamodel.makeSnakGroup(qualifierSnakList);
|
||||
List<SnakGroup> snakGroupList = Collections.singletonList(qualifierSnakGroup);
|
||||
@ -58,7 +58,6 @@ public class EntityTypeScrutinizerTest extends StatementScrutinizerTest {
|
||||
|
||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||
when(fetcher.getConstraintsByType(propertyIdValue,ALLOWED_ENTITY_TYPES_QID)).thenReturn(statementList);
|
||||
when(fetcher.findValues(snakGroupList, ALLOWED_ENTITY_TYPES_PID)).thenReturn(Collections.singletonList(allowedValue));
|
||||
setFetcher(fetcher);
|
||||
|
||||
scrutinize(update);
|
||||
@ -82,7 +81,6 @@ public class EntityTypeScrutinizerTest extends StatementScrutinizerTest {
|
||||
|
||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||
when(fetcher.getConstraintsByType(propertyIdValue,ALLOWED_ENTITY_TYPES_QID)).thenReturn(statementList);
|
||||
when(fetcher.findValues(snakGroupList, ALLOWED_ENTITY_TYPES_PID)).thenReturn(Collections.singletonList(itemValue));
|
||||
setFetcher(fetcher);
|
||||
|
||||
scrutinize(update);
|
||||
|
@ -79,7 +79,6 @@ public class FormatScrutinizerTest extends ScrutinizerTest {
|
||||
|
||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||
when(fetcher.getConstraintsByType(propertyIdValue, FORMAT_CONSTRAINT_QID)).thenReturn(statementList);
|
||||
when(fetcher.findValues(snakGroupList, FORMAT_REGEX_PID)).thenReturn(Collections.singletonList(regularExpressionFormat));
|
||||
setFetcher(fetcher);
|
||||
scrutinize(updateA);
|
||||
assertWarningsRaised(FormatScrutinizer.type);
|
||||
@ -100,7 +99,6 @@ public class FormatScrutinizerTest extends ScrutinizerTest {
|
||||
|
||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||
when(fetcher.getConstraintsByType(propertyIdValue, FORMAT_CONSTRAINT_QID)).thenReturn(statementList);
|
||||
when(fetcher.findValues(snakGroupList, FORMAT_REGEX_PID)).thenReturn(Collections.singletonList(regularExpressionFormat));
|
||||
setFetcher(fetcher);
|
||||
scrutinize(updateA);
|
||||
assertNoWarningRaised();
|
||||
@ -121,7 +119,6 @@ public class FormatScrutinizerTest extends ScrutinizerTest {
|
||||
|
||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||
when(fetcher.getConstraintsByType(propertyIdValue, FORMAT_CONSTRAINT_QID)).thenReturn(statementList);
|
||||
when(fetcher.findValues(snakGroupList, FORMAT_REGEX_PID)).thenReturn(Collections.singletonList(regularExpressionFormat));
|
||||
setFetcher(fetcher);
|
||||
scrutinize(updateA);
|
||||
assertWarningsRaised(FormatScrutinizer.type);
|
||||
|
@ -69,7 +69,7 @@ public class InverseConstaintScrutinizerTest extends StatementScrutinizerTest {
|
||||
Statement statement = new StatementImpl("P25", mainSnak, idA);
|
||||
ItemUpdate update = new ItemUpdateBuilder(idA).addStatement(statement).build();
|
||||
|
||||
Snak qualifierSnak = Datamodel.makeValueSnak(propertyParameter, inverseEntityIdValue);
|
||||
Snak qualifierSnak = Datamodel.makeValueSnak(propertyParameter, inversePropertyID);
|
||||
List<Snak> qualifierSnakList = Collections.singletonList(qualifierSnak);
|
||||
SnakGroup qualifierSnakGroup = Datamodel.makeSnakGroup(qualifierSnakList);
|
||||
List<SnakGroup> snakGroupList = Collections.singletonList(qualifierSnakGroup);
|
||||
@ -77,7 +77,6 @@ public class InverseConstaintScrutinizerTest extends StatementScrutinizerTest {
|
||||
|
||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||
when(fetcher.getConstraintsByType(propertyId, INVERSE_CONSTRAINT_QID)).thenReturn(statementList);
|
||||
when(fetcher.findValues(snakGroupList, INVERSE_PROPERTY_PID)).thenReturn(Collections.singletonList(inversePropertyID));
|
||||
setFetcher(fetcher);
|
||||
scrutinize(update);
|
||||
assertWarningsRaised(InverseConstraintScrutinizer.type);
|
||||
@ -98,7 +97,6 @@ public class InverseConstaintScrutinizerTest extends StatementScrutinizerTest {
|
||||
|
||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||
when(fetcher.getConstraintsByType(symmetricPropertyID, SYMMETRIC_CONSTRAINT_QID)).thenReturn(statementList);
|
||||
when(fetcher.findValues(snakGroupList, INVERSE_PROPERTY_PID)).thenReturn(Collections.singletonList(symmetricPropertyID));
|
||||
setFetcher(fetcher);
|
||||
scrutinize(update);
|
||||
assertWarningsRaised(InverseConstraintScrutinizer.type);
|
||||
@ -119,7 +117,6 @@ public class InverseConstaintScrutinizerTest extends StatementScrutinizerTest {
|
||||
|
||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||
when(fetcher.getConstraintsByType(propertyId, INVERSE_CONSTRAINT_QID)).thenReturn(statementList);
|
||||
when(fetcher.findValues(snakGroupList, INVERSE_PROPERTY_PID)).thenReturn(Collections.singletonList(inversePropertyID));
|
||||
setFetcher(fetcher);
|
||||
scrutinize(update);
|
||||
assertNoWarningRaised();
|
||||
|
@ -46,7 +46,6 @@ import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.openrefine.wikidata.qa.scrutinizers.QualifierCompatibilityScrutinizer.ALLOWED_QUALIFIERS_CONSTRAINT_PID;
|
||||
import static org.openrefine.wikidata.qa.scrutinizers.QualifierCompatibilityScrutinizer.ALLOWED_QUALIFIERS_CONSTRAINT_QID;
|
||||
import static org.openrefine.wikidata.qa.scrutinizers.QualifierCompatibilityScrutinizer.MANDATORY_QUALIFIERS_CONSTRAINT_PID;
|
||||
import static org.openrefine.wikidata.qa.scrutinizers.QualifierCompatibilityScrutinizer.MANDATORY_QUALIFIERS_CONSTRAINT_QID;
|
||||
|
||||
public class QualifierCompatibilityScrutinizerTest extends StatementScrutinizerTest {
|
||||
@ -82,7 +81,6 @@ public class QualifierCompatibilityScrutinizerTest extends StatementScrutinizerT
|
||||
|
||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||
when(fetcher.getConstraintsByType(allowedPropertyIdValue, ALLOWED_QUALIFIERS_CONSTRAINT_QID)).thenReturn(statementList);
|
||||
when(fetcher.findValues(snakGroupList, ALLOWED_QUALIFIERS_CONSTRAINT_PID)).thenReturn(Collections.singletonList(qualifierProperty));
|
||||
setFetcher(fetcher);
|
||||
|
||||
scrutinize(update);
|
||||
@ -104,7 +102,6 @@ public class QualifierCompatibilityScrutinizerTest extends StatementScrutinizerT
|
||||
|
||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||
when(fetcher.getConstraintsByType(mandatoryPropertyIdValue, MANDATORY_QUALIFIERS_CONSTRAINT_QID)).thenReturn(statementList);
|
||||
when(fetcher.findValues(snakGroupList, MANDATORY_QUALIFIERS_CONSTRAINT_PID)).thenReturn(Collections.singletonList(qualifierProperty));
|
||||
setFetcher(fetcher);
|
||||
|
||||
scrutinize(update);
|
||||
@ -127,7 +124,6 @@ public class QualifierCompatibilityScrutinizerTest extends StatementScrutinizerT
|
||||
|
||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||
when(fetcher.getConstraintsByType(allowedPropertyIdValue, ALLOWED_QUALIFIERS_CONSTRAINT_QID)).thenReturn(statementList);
|
||||
when(fetcher.findValues(snakGroupList, ALLOWED_QUALIFIERS_CONSTRAINT_PID)).thenReturn(Collections.singletonList(qualifierProperty));
|
||||
setFetcher(fetcher);
|
||||
|
||||
scrutinize(update);
|
||||
|
@ -20,8 +20,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.openrefine.wikidata.qa.scrutinizers.QuantityScrutinizer.ALLOWED_UNITS_CONSTRAINT_PID;
|
||||
@ -212,7 +210,6 @@ public class QuantityScrutinizerTest extends ValueScrutinizerTest{
|
||||
List<Statement> constraintDefinitions = constraintParameterStatementList(allowedUnitEntity, constraintQualifiers);
|
||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||
when(fetcher.getConstraintsByType(propertyIdValue, ALLOWED_UNITS_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
|
||||
when(fetcher.findValues(constraintQualifiers, ALLOWED_UNITS_CONSTRAINT_PID)).thenReturn(Collections.singletonList(allowedUnit));
|
||||
setFetcher(fetcher);
|
||||
|
||||
scrutinize(update);
|
||||
@ -229,7 +226,6 @@ public class QuantityScrutinizerTest extends ValueScrutinizerTest{
|
||||
List<Statement> constraintDefinitions = constraintParameterStatementList(allowedUnitEntity, new ArrayList<>());
|
||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||
when(fetcher.getConstraintsByType(propertyIdValue, ALLOWED_UNITS_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
|
||||
when(fetcher.findValues(any(), eq(ALLOWED_UNITS_CONSTRAINT_PID))).thenReturn(new ArrayList<>());
|
||||
setFetcher(fetcher);
|
||||
|
||||
scrutinize(update);
|
||||
@ -245,7 +241,6 @@ public class QuantityScrutinizerTest extends ValueScrutinizerTest{
|
||||
|
||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||
when(fetcher.getConstraintsByType(propertyIdValue, ALLOWED_UNITS_CONSTRAINT_QID)).thenReturn(new ArrayList<>());
|
||||
when(fetcher.findValues(any(), eq(ALLOWED_UNITS_CONSTRAINT_PID))).thenReturn(new ArrayList<>());
|
||||
setFetcher(fetcher);
|
||||
|
||||
scrutinize(update);
|
||||
|
@ -73,7 +73,6 @@ public class RestrictedPositionScrutinizerTest extends SnakScrutinizerTest {
|
||||
List<Statement> constraintDefinitions = constraintParameterStatementList(entityIdValue, constraintQualifiers);
|
||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||
when(fetcher.getConstraintsByType(propertyIdValue, SCOPE_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
|
||||
when(fetcher.findValues(constraintQualifiers, SCOPE_CONSTRAINT_PID)).thenReturn(Collections.singletonList(asQualifier));
|
||||
setFetcher(fetcher);
|
||||
|
||||
scrutinize(update);
|
||||
@ -92,7 +91,6 @@ public class RestrictedPositionScrutinizerTest extends SnakScrutinizerTest {
|
||||
List<Statement> constraintDefinitions = constraintParameterStatementList(entityIdValue, constraintQualifiers);
|
||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||
when(fetcher.getConstraintsByType(propertyIdValue, SCOPE_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
|
||||
when(fetcher.findValues(constraintQualifiers, SCOPE_CONSTRAINT_PID)).thenReturn(Collections.singletonList(asMainSnak));
|
||||
setFetcher(fetcher);
|
||||
|
||||
scrutinize(update);
|
||||
@ -130,7 +128,6 @@ public class RestrictedPositionScrutinizerTest extends SnakScrutinizerTest {
|
||||
List<Statement> constraintDefinitions = constraintParameterStatementList(entityIdValue, constraintQualifiers);
|
||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||
when(fetcher.getConstraintsByType(propertyIdValue, SCOPE_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
|
||||
when(fetcher.findValues(constraintQualifiers, SCOPE_CONSTRAINT_PID)).thenReturn(Collections.singletonList(asMainSnak));
|
||||
setFetcher(fetcher);
|
||||
|
||||
scrutinize(update);
|
||||
|
@ -12,7 +12,6 @@ import org.wikidata.wdtk.datamodel.interfaces.SnakGroup;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Statement;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
@ -21,7 +20,6 @@ import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.openrefine.wikidata.qa.scrutinizers.RestrictedValuesScrutinizer.ALLOWED_VALUES_CONSTRAINT_PID;
|
||||
import static org.openrefine.wikidata.qa.scrutinizers.RestrictedValuesScrutinizer.ALLOWED_VALUES_CONSTRAINT_QID;
|
||||
import static org.openrefine.wikidata.qa.scrutinizers.RestrictedValuesScrutinizer.DISALLOWED_VALUES_CONSTRAINT_PID;
|
||||
import static org.openrefine.wikidata.qa.scrutinizers.RestrictedValuesScrutinizer.DISALLOWED_VALUES_CONSTRAINT_QID;
|
||||
|
||||
public class RestrictedValuesScrutinizerTest extends SnakScrutinizerTest {
|
||||
@ -64,7 +62,6 @@ public class RestrictedValuesScrutinizerTest extends SnakScrutinizerTest {
|
||||
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<>());
|
||||
when(fetcher.findValues(constraintQualifiers, ALLOWED_VALUES_CONSTRAINT_PID)).thenReturn(Collections.singletonList(allowedValue));
|
||||
setFetcher(fetcher);
|
||||
|
||||
scrutinize(statement);
|
||||
@ -82,7 +79,6 @@ public class RestrictedValuesScrutinizerTest extends SnakScrutinizerTest {
|
||||
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<>());
|
||||
when(fetcher.findValues(constraintQualifiers, ALLOWED_VALUES_CONSTRAINT_PID)).thenReturn(Collections.singletonList(allowedValue));
|
||||
setFetcher(fetcher);
|
||||
|
||||
scrutinize(statement);
|
||||
@ -100,7 +96,6 @@ public class RestrictedValuesScrutinizerTest extends SnakScrutinizerTest {
|
||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||
when(fetcher.getConstraintsByType(disallowedPropertyIdValue, ALLOWED_VALUES_CONSTRAINT_QID)).thenReturn(new ArrayList<>());
|
||||
when(fetcher.getConstraintsByType(disallowedPropertyIdValue, DISALLOWED_VALUES_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
|
||||
when(fetcher.findValues(constraintQualifiers, DISALLOWED_VALUES_CONSTRAINT_PID)).thenReturn(Collections.singletonList(disallowedValue));
|
||||
setFetcher(fetcher);
|
||||
|
||||
scrutinize(statement);
|
||||
@ -118,7 +113,6 @@ public class RestrictedValuesScrutinizerTest extends SnakScrutinizerTest {
|
||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||
when(fetcher.getConstraintsByType(disallowedPropertyIdValue, ALLOWED_VALUES_CONSTRAINT_QID)).thenReturn(new ArrayList<>());
|
||||
when(fetcher.getConstraintsByType(disallowedPropertyIdValue, DISALLOWED_VALUES_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
|
||||
when(fetcher.findValues(constraintQualifiers, DISALLOWED_VALUES_CONSTRAINT_PID)).thenReturn(Collections.singletonList(disallowedValue));
|
||||
setFetcher(fetcher);
|
||||
|
||||
scrutinize(statement);
|
||||
|
Loading…
Reference in New Issue
Block a user