From fe275ae634f6fcd74a9234ac7439a68cc37efaa7 Mon Sep 17 00:00:00 2001 From: Ekta Mishra Date: Wed, 15 Jul 2020 15:16:06 +0530 Subject: [PATCH] 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 --- .../wikidata/qa/ConstraintFetcher.java | 13 ---------- .../qa/WikidataConstraintFetcher.java | 23 ---------------- .../DifferenceWithinRangeScrutinizer.java | 6 ++--- .../qa/scrutinizers/EditScrutinizer.java | 26 +++++++++++++++++++ .../scrutinizers/EntityTypeScrutinizer.java | 2 +- .../qa/scrutinizers/FormatScrutinizer.java | 2 +- .../InverseConstraintScrutinizer.java | 2 +- .../QualifierCompatibilityScrutinizer.java | 4 +-- .../qa/scrutinizers/QuantityScrutinizer.java | 2 +- .../RestrictedPositionScrutinizer.java | 2 +- .../RestrictedValuesScrutinizer.java | 4 +-- .../DifferenceWithinScrutinizerTest.java | 7 ----- .../EntityTypeScrutinizerTest.java | 4 +-- .../scrutinizers/FormatScrutinizerTest.java | 3 --- .../InverseConstaintScrutinizerTest.java | 5 +--- ...QualifierCompatibilityScrutinizerTest.java | 4 --- .../scrutinizers/QuantityScrutinizerTest.java | 5 ---- .../RestrictedPositionScrutinizerTest.java | 3 --- .../RestrictedValuesScrutinizerTest.java | 6 ----- 19 files changed, 40 insertions(+), 83 deletions(-) diff --git a/extensions/wikidata/src/org/openrefine/wikidata/qa/ConstraintFetcher.java b/extensions/wikidata/src/org/openrefine/wikidata/qa/ConstraintFetcher.java index 8b6c2fc8d..99c157296 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/qa/ConstraintFetcher.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/qa/ConstraintFetcher.java @@ -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 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 findValues(List groups, String pid); - } diff --git a/extensions/wikidata/src/org/openrefine/wikidata/qa/WikidataConstraintFetcher.java b/extensions/wikidata/src/org/openrefine/wikidata/qa/WikidataConstraintFetcher.java index 11804543a..1ac27f862 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/qa/WikidataConstraintFetcher.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/qa/WikidataConstraintFetcher.java @@ -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 findValues(List groups, String pid) { - List results = new ArrayList<>(); - for (SnakGroup group : groups) { - if (group.getProperty().getId().equals(pid)) { - for (Snak snak : group.getSnaks()) - results.add(snak.getValue()); - } - } - return results; - } - } diff --git a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/DifferenceWithinRangeScrutinizer.java b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/DifferenceWithinRangeScrutinizer.java index b8dcec168..065166fc2 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/DifferenceWithinRangeScrutinizer.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/DifferenceWithinRangeScrutinizer.java @@ -23,9 +23,9 @@ public class DifferenceWithinRangeScrutinizer extends EditScrutinizer { DifferenceWithinRangeConstraint(Statement statement) { List specs = statement.getClaim().getQualifiers(); if (specs != null) { - List lowerValueProperty = _fetcher.findValues(specs, DIFFERENCE_WITHIN_RANGE_CONSTRAINT_PID); - List minValue = _fetcher.findValues(specs, MINIMUM_VALUE_PID); - List maxValue = _fetcher.findValues(specs, MAXIMUM_VALUE_PID); + List lowerValueProperty = findValues(specs, DIFFERENCE_WITHIN_RANGE_CONSTRAINT_PID); + List minValue = findValues(specs, MINIMUM_VALUE_PID); + List maxValue = findValues(specs, MAXIMUM_VALUE_PID); if (!lowerValueProperty.isEmpty()) { lowerPropertyIdValue = (PropertyIdValue) lowerValueProperty.get(0); } diff --git a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/EditScrutinizer.java b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/EditScrutinizer.java index 44ab9cff5..fdf3534ce 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/EditScrutinizer.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/EditScrutinizer.java @@ -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 findValues(List groups, String pid) { + List results = new ArrayList<>(); + for (SnakGroup group : groups) { + if (group.getProperty().getId().equals(pid)) { + for (Snak snak : group.getSnaks()) + results.add(snak.getValue()); + } + } + return results; + } } diff --git a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/EntityTypeScrutinizer.java b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/EntityTypeScrutinizer.java index 49b1a9f7b..fd6090e64 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/EntityTypeScrutinizer.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/EntityTypeScrutinizer.java @@ -26,7 +26,7 @@ public class EntityTypeScrutinizer extends SnakScrutinizer { List 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) { diff --git a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/FormatScrutinizer.java b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/FormatScrutinizer.java index 687ac44f7..edd8995a3 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/FormatScrutinizer.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/FormatScrutinizer.java @@ -60,7 +60,7 @@ public class FormatScrutinizer extends SnakScrutinizer { FormatConstraint(Statement statement) { List constraint = statement.getClaim().getQualifiers(); if (constraint != null) { - List regexes = _fetcher.findValues(constraint, FORMAT_REGEX_PID); + List regexes = findValues(constraint, FORMAT_REGEX_PID); if (!regexes.isEmpty()) { regularExpressionFormat = ((StringValue) regexes.get(0)).getString(); } diff --git a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/InverseConstraintScrutinizer.java b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/InverseConstraintScrutinizer.java index 62eaf4f6d..7e599e7ea 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/InverseConstraintScrutinizer.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/InverseConstraintScrutinizer.java @@ -58,7 +58,7 @@ public class InverseConstraintScrutinizer extends StatementScrutinizer { List specs = statement.getClaim().getQualifiers(); if (specs != null) { - List inverses = _fetcher.findValues(specs, INVERSE_PROPERTY_PID); + List inverses = findValues(specs, INVERSE_PROPERTY_PID); if (!inverses.isEmpty()) { propertyParameterValue = (PropertyIdValue) inverses.get(0); } diff --git a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/QualifierCompatibilityScrutinizer.java b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/QualifierCompatibilityScrutinizer.java index 51ee47277..330acb9bd 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/QualifierCompatibilityScrutinizer.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/QualifierCompatibilityScrutinizer.java @@ -59,7 +59,7 @@ public class QualifierCompatibilityScrutinizer extends StatementScrutinizer { allowedProperties = new HashSet<>(); List specs = statement.getClaim().getQualifiers(); if (specs != null) { - List properties = _fetcher.findValues(specs, ALLOWED_QUALIFIERS_CONSTRAINT_PID); + List 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 specs = statement.getClaim().getQualifiers(); if (specs != null) { - List properties = _fetcher.findValues(specs, MANDATORY_QUALIFIERS_CONSTRAINT_PID); + List properties = findValues(specs, MANDATORY_QUALIFIERS_CONSTRAINT_PID); mandatoryProperties = properties.stream() .filter(e -> e != null) .map(e -> (PropertyIdValue) e) diff --git a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/QuantityScrutinizer.java b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/QuantityScrutinizer.java index 784bd26c1..816d48d9f 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/QuantityScrutinizer.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/QuantityScrutinizer.java @@ -38,7 +38,7 @@ public class QuantityScrutinizer extends SnakScrutinizer { AllowedUnitsConstraint(Statement statement) { List specs = statement.getClaim().getQualifiers(); if (specs != null) { - List properties = _fetcher.findValues(specs, ALLOWED_UNITS_CONSTRAINT_PID); + List properties = findValues(specs, ALLOWED_UNITS_CONSTRAINT_PID); allowedUnits = properties.stream() .map(e -> e == null ? null : (ItemIdValue) e) .collect(Collectors.toSet()); diff --git a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/RestrictedPositionScrutinizer.java b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/RestrictedPositionScrutinizer.java index ac674dcea..ea76c53e9 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/RestrictedPositionScrutinizer.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/RestrictedPositionScrutinizer.java @@ -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 snakValues = _fetcher.findValues(specs, SCOPE_CONSTRAINT_PID); + List snakValues = findValues(specs, SCOPE_CONSTRAINT_PID); isAllowedAsValue = snakValues.contains(targetValue); isAllowedAsQualifier = snakValues.contains(targetQualifier); isAllowedAsReference = snakValues.contains(targetReference); diff --git a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/RestrictedValuesScrutinizer.java b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/RestrictedValuesScrutinizer.java index 734c41066..a0c346444 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/RestrictedValuesScrutinizer.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/RestrictedValuesScrutinizer.java @@ -27,7 +27,7 @@ public class RestrictedValuesScrutinizer extends SnakScrutinizer { AllowedValueConstraint(Statement statement) { List specs = statement.getClaim().getQualifiers(); if (specs != null) { - List properties = _fetcher.findValues(specs, ALLOWED_VALUES_CONSTRAINT_PID); + List 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 specs = statement.getClaim().getQualifiers(); if (specs != null) { - List properties = _fetcher.findValues(specs, DISALLOWED_VALUES_CONSTRAINT_PID); + List properties = findValues(specs, DISALLOWED_VALUES_CONSTRAINT_PID); disallowedValues = properties.stream().collect(Collectors.toSet()); } } diff --git a/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/DifferenceWithinScrutinizerTest.java b/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/DifferenceWithinScrutinizerTest.java index e4b4f7d40..63f304554 100644 --- a/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/DifferenceWithinScrutinizerTest.java +++ b/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/DifferenceWithinScrutinizerTest.java @@ -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); diff --git a/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/EntityTypeScrutinizerTest.java b/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/EntityTypeScrutinizerTest.java index 52c506141..3dbbb3e8d 100644 --- a/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/EntityTypeScrutinizerTest.java +++ b/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/EntityTypeScrutinizerTest.java @@ -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 qualifierSnakList = Collections.singletonList(qualifierSnak); SnakGroup qualifierSnakGroup = Datamodel.makeSnakGroup(qualifierSnakList); List 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); diff --git a/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/FormatScrutinizerTest.java b/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/FormatScrutinizerTest.java index 0febbc44b..67189d4fd 100644 --- a/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/FormatScrutinizerTest.java +++ b/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/FormatScrutinizerTest.java @@ -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); diff --git a/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/InverseConstaintScrutinizerTest.java b/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/InverseConstaintScrutinizerTest.java index 6981e48b9..202a55558 100644 --- a/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/InverseConstaintScrutinizerTest.java +++ b/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/InverseConstaintScrutinizerTest.java @@ -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 qualifierSnakList = Collections.singletonList(qualifierSnak); SnakGroup qualifierSnakGroup = Datamodel.makeSnakGroup(qualifierSnakList); List 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(); diff --git a/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/QualifierCompatibilityScrutinizerTest.java b/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/QualifierCompatibilityScrutinizerTest.java index d9023f363..7e8be2745 100644 --- a/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/QualifierCompatibilityScrutinizerTest.java +++ b/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/QualifierCompatibilityScrutinizerTest.java @@ -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); diff --git a/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/QuantityScrutinizerTest.java b/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/QuantityScrutinizerTest.java index ac90bdc60..d9c843547 100644 --- a/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/QuantityScrutinizerTest.java +++ b/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/QuantityScrutinizerTest.java @@ -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 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 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); diff --git a/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/RestrictedPositionScrutinizerTest.java b/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/RestrictedPositionScrutinizerTest.java index 8129dcfc5..5c8117b14 100644 --- a/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/RestrictedPositionScrutinizerTest.java +++ b/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/RestrictedPositionScrutinizerTest.java @@ -73,7 +73,6 @@ public class RestrictedPositionScrutinizerTest extends SnakScrutinizerTest { List 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 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 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); diff --git a/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/RestrictedValuesScrutinizerTest.java b/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/RestrictedValuesScrutinizerTest.java index 2e45600ab..691dd5999 100644 --- a/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/RestrictedValuesScrutinizerTest.java +++ b/extensions/wikidata/tests/src/org/openrefine/wikidata/qa/scrutinizers/RestrictedValuesScrutinizerTest.java @@ -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);