Revert "Reused Constraint IDs and Parameter PIDs (#2893)"
This introduces a build failure since other refactorings took place.
This reverts commit f41ce3a752
.
This commit is contained in:
parent
f41ce3a752
commit
4c739be843
@ -21,16 +21,12 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.openrefine.wikidata.qa.Constraint.CONSTRAINT_EXCEPTIONS;
|
|
||||||
import static org.openrefine.wikidata.qa.Constraint.CONSTRAINT_STATUS;
|
|
||||||
import static org.openrefine.wikidata.qa.WikidataConstraintFetcher.SINGLE_VALUE_CONSTRAINT_QID;
|
|
||||||
|
|
||||||
public class ConstraintTest {
|
public class ConstraintTest {
|
||||||
|
|
||||||
public static ItemIdValue itemIdValue = Datamodel.makeWikidataItemIdValue(SINGLE_VALUE_CONSTRAINT_QID);
|
public static ItemIdValue itemIdValue = Datamodel.makeWikidataItemIdValue("Q19474404");
|
||||||
public static PropertyIdValue constraintException = Datamodel.makeWikidataPropertyIdValue(CONSTRAINT_EXCEPTIONS);
|
public static PropertyIdValue constraintException = Datamodel.makeWikidataPropertyIdValue("P2303");
|
||||||
public static Value exceptionValue = Datamodel.makeWikidataItemIdValue("Q7409772");
|
public static Value exceptionValue = Datamodel.makeWikidataItemIdValue("Q7409772");
|
||||||
public static PropertyIdValue constraintStatus = Datamodel.makeWikidataPropertyIdValue(CONSTRAINT_STATUS);
|
public static PropertyIdValue constraintStatus = Datamodel.makeWikidataPropertyIdValue("P2316");
|
||||||
public static Value statusValue = Datamodel.makeWikidataItemIdValue("Q62026391");
|
public static Value statusValue = Datamodel.makeWikidataItemIdValue("Q62026391");
|
||||||
|
|
||||||
public static Constraint constraint;
|
public static Constraint constraint;
|
||||||
|
@ -23,10 +23,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
import static org.openrefine.wikidata.qa.scrutinizers.DifferenceWithinRangeScrutinizer.DIFFERENCE_WITHIN_RANGE_CONSTRAINT_PID;
|
|
||||||
import static org.openrefine.wikidata.qa.scrutinizers.DifferenceWithinRangeScrutinizer.DIFFERENCE_WITHIN_RANGE_CONSTRAINT_QID;
|
|
||||||
import static org.openrefine.wikidata.qa.scrutinizers.DifferenceWithinRangeScrutinizer.MAXIMUM_VALUE_PID;
|
|
||||||
import static org.openrefine.wikidata.qa.scrutinizers.DifferenceWithinRangeScrutinizer.MINIMUM_VALUE_PID;
|
|
||||||
|
|
||||||
public class DifferenceWithinScrutinizerTest extends ScrutinizerTest{
|
public class DifferenceWithinScrutinizerTest extends ScrutinizerTest{
|
||||||
|
|
||||||
@ -34,11 +30,11 @@ public class DifferenceWithinScrutinizerTest extends ScrutinizerTest{
|
|||||||
public static PropertyIdValue lowerBoundPid = Datamodel.makeWikidataPropertyIdValue("P569");
|
public static PropertyIdValue lowerBoundPid = Datamodel.makeWikidataPropertyIdValue("P569");
|
||||||
public static QuantityValue minValue = Datamodel.makeQuantityValue(new BigDecimal(0));
|
public static QuantityValue minValue = Datamodel.makeQuantityValue(new BigDecimal(0));
|
||||||
public static QuantityValue maxValue = Datamodel.makeQuantityValue(new BigDecimal(150));
|
public static QuantityValue maxValue = Datamodel.makeQuantityValue(new BigDecimal(150));
|
||||||
public static ItemIdValue entityIdValue = Datamodel.makeWikidataItemIdValue(DIFFERENCE_WITHIN_RANGE_CONSTRAINT_QID);
|
public static ItemIdValue entityIdValue = Datamodel.makeWikidataItemIdValue("Q21510854");
|
||||||
|
|
||||||
public static PropertyIdValue propertyParameterPID = Datamodel.makeWikidataPropertyIdValue(DIFFERENCE_WITHIN_RANGE_CONSTRAINT_PID);
|
public static PropertyIdValue propertyParameterPID = Datamodel.makeWikidataPropertyIdValue("P2306");
|
||||||
public static PropertyIdValue minimumValuePID = Datamodel.makeWikidataPropertyIdValue(MINIMUM_VALUE_PID);
|
public static PropertyIdValue minimumValuePID = Datamodel.makeWikidataPropertyIdValue("P2313");
|
||||||
public static PropertyIdValue maximumValuePID = Datamodel.makeWikidataPropertyIdValue(MAXIMUM_VALUE_PID);
|
public static PropertyIdValue maximumValuePID = Datamodel.makeWikidataPropertyIdValue("P2312");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditScrutinizer getScrutinizer() {
|
public EditScrutinizer getScrutinizer() {
|
||||||
@ -63,10 +59,10 @@ public class DifferenceWithinScrutinizerTest extends ScrutinizerTest{
|
|||||||
List<Statement> constraintDefinitions = constraintParameterStatementList(entityIdValue, constraintQualifiers);
|
List<Statement> constraintDefinitions = constraintParameterStatementList(entityIdValue, constraintQualifiers);
|
||||||
|
|
||||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||||
when(fetcher.getConstraintsByType(upperBoundPid, DIFFERENCE_WITHIN_RANGE_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
|
when(fetcher.getConstraintsByType(upperBoundPid, "Q21510854")).thenReturn(constraintDefinitions);
|
||||||
when(fetcher.findValues(constraintQualifiers, DIFFERENCE_WITHIN_RANGE_CONSTRAINT_PID)).thenReturn(Collections.singletonList(lowerBoundPid));
|
when(fetcher.findValues(constraintQualifiers, "P2306")).thenReturn(Collections.singletonList(lowerBoundPid));
|
||||||
when(fetcher.findValues(constraintQualifiers, MINIMUM_VALUE_PID)).thenReturn(Collections.singletonList(minValue));
|
when(fetcher.findValues(constraintQualifiers, "P2313")).thenReturn(Collections.singletonList(minValue));
|
||||||
when(fetcher.findValues(constraintQualifiers, MAXIMUM_VALUE_PID)).thenReturn(Collections.singletonList(maxValue));
|
when(fetcher.findValues(constraintQualifiers, "P2312")).thenReturn(Collections.singletonList(maxValue));
|
||||||
setFetcher(fetcher);
|
setFetcher(fetcher);
|
||||||
|
|
||||||
scrutinize(updateA);
|
scrutinize(updateA);
|
||||||
@ -91,10 +87,10 @@ public class DifferenceWithinScrutinizerTest extends ScrutinizerTest{
|
|||||||
List<Statement> constraintDefinitions = constraintParameterStatementList(entityIdValue, constraintQualifiers);
|
List<Statement> constraintDefinitions = constraintParameterStatementList(entityIdValue, constraintQualifiers);
|
||||||
|
|
||||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||||
when(fetcher.getConstraintsByType(upperBoundPid, DIFFERENCE_WITHIN_RANGE_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
|
when(fetcher.getConstraintsByType(upperBoundPid, "Q21510854")).thenReturn(constraintDefinitions);
|
||||||
when(fetcher.findValues(constraintQualifiers, DIFFERENCE_WITHIN_RANGE_CONSTRAINT_PID)).thenReturn(Collections.singletonList(lowerBoundPid));
|
when(fetcher.findValues(constraintQualifiers, "P2306")).thenReturn(Collections.singletonList(lowerBoundPid));
|
||||||
when(fetcher.findValues(constraintQualifiers, MINIMUM_VALUE_PID)).thenReturn(Collections.singletonList(minValue));
|
when(fetcher.findValues(constraintQualifiers, "P2313")).thenReturn(Collections.singletonList(minValue));
|
||||||
when(fetcher.findValues(constraintQualifiers, MAXIMUM_VALUE_PID)).thenReturn(Collections.singletonList(maxValue));
|
when(fetcher.findValues(constraintQualifiers, "P2312")).thenReturn(Collections.singletonList(maxValue));
|
||||||
setFetcher(fetcher);
|
setFetcher(fetcher);
|
||||||
|
|
||||||
scrutinize(updateA);
|
scrutinize(updateA);
|
||||||
|
@ -42,7 +42,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
import static org.openrefine.wikidata.qa.scrutinizers.DistinctValuesScrutinizer.DISTINCT_VALUES_CONSTRAINT_QID;
|
|
||||||
|
|
||||||
public class DistinctValuesScrutinizerTest extends StatementScrutinizerTest {
|
public class DistinctValuesScrutinizerTest extends StatementScrutinizerTest {
|
||||||
|
|
||||||
@ -50,7 +49,7 @@ public class DistinctValuesScrutinizerTest extends StatementScrutinizerTest {
|
|||||||
public static Value value1 = Datamodel.makeWikidataItemIdValue("Q41673");
|
public static Value value1 = Datamodel.makeWikidataItemIdValue("Q41673");
|
||||||
public static Value value2 = Datamodel.makeWikidataItemIdValue("Q43175");
|
public static Value value2 = Datamodel.makeWikidataItemIdValue("Q43175");
|
||||||
|
|
||||||
public static ItemIdValue entityIdValue = Datamodel.makeWikidataItemIdValue(DISTINCT_VALUES_CONSTRAINT_QID);
|
public static ItemIdValue entityIdValue = Datamodel.makeWikidataItemIdValue("Q19474404");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditScrutinizer getScrutinizer() {
|
public EditScrutinizer getScrutinizer() {
|
||||||
@ -70,7 +69,7 @@ public class DistinctValuesScrutinizerTest extends StatementScrutinizerTest {
|
|||||||
List<Statement> statementList = constraintParameterStatementList(entityIdValue, snakGroupList);
|
List<Statement> statementList = constraintParameterStatementList(entityIdValue, snakGroupList);
|
||||||
|
|
||||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||||
when(fetcher.getConstraintsByType(propertyIdValue, DISTINCT_VALUES_CONSTRAINT_QID)).thenReturn(statementList);
|
when(fetcher.getConstraintsByType(propertyIdValue, "Q21502410")).thenReturn(statementList);
|
||||||
setFetcher(fetcher);
|
setFetcher(fetcher);
|
||||||
|
|
||||||
scrutinize(update);
|
scrutinize(update);
|
||||||
@ -91,7 +90,7 @@ public class DistinctValuesScrutinizerTest extends StatementScrutinizerTest {
|
|||||||
List<Statement> statementList = constraintParameterStatementList(entityIdValue, snakGroupList);
|
List<Statement> statementList = constraintParameterStatementList(entityIdValue, snakGroupList);
|
||||||
|
|
||||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||||
when(fetcher.getConstraintsByType(propertyIdValue, DISTINCT_VALUES_CONSTRAINT_QID)).thenReturn(statementList);
|
when(fetcher.getConstraintsByType(propertyIdValue, "Q21502410")).thenReturn(statementList);
|
||||||
setFetcher(fetcher);
|
setFetcher(fetcher);
|
||||||
|
|
||||||
scrutinize(update);
|
scrutinize(update);
|
||||||
|
@ -57,8 +57,8 @@ public class EntityTypeScrutinizerTest extends StatementScrutinizerTest {
|
|||||||
List<Statement> statementList = constraintParameterStatementList(entityIdValue, snakGroupList);
|
List<Statement> statementList = constraintParameterStatementList(entityIdValue, snakGroupList);
|
||||||
|
|
||||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||||
when(fetcher.getConstraintsByType(propertyIdValue,ALLOWED_ENTITY_TYPES_QID)).thenReturn(statementList);
|
when(fetcher.getConstraintsByType(propertyIdValue,"Q52004125")).thenReturn(statementList);
|
||||||
when(fetcher.findValues(snakGroupList, ALLOWED_ENTITY_TYPES_PID)).thenReturn(Collections.singletonList(allowedValue));
|
when(fetcher.findValues(snakGroupList, "P2305")).thenReturn(Collections.singletonList(allowedValue));
|
||||||
setFetcher(fetcher);
|
setFetcher(fetcher);
|
||||||
|
|
||||||
scrutinize(update);
|
scrutinize(update);
|
||||||
@ -81,8 +81,8 @@ public class EntityTypeScrutinizerTest extends StatementScrutinizerTest {
|
|||||||
List<Statement> statementList = constraintParameterStatementList(entityIdValue, snakGroupList);
|
List<Statement> statementList = constraintParameterStatementList(entityIdValue, snakGroupList);
|
||||||
|
|
||||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||||
when(fetcher.getConstraintsByType(propertyIdValue,ALLOWED_ENTITY_TYPES_QID)).thenReturn(statementList);
|
when(fetcher.getConstraintsByType(propertyIdValue,"Q52004125")).thenReturn(statementList);
|
||||||
when(fetcher.findValues(snakGroupList, ALLOWED_ENTITY_TYPES_PID)).thenReturn(Collections.singletonList(itemValue));
|
when(fetcher.findValues(snakGroupList, "P2305")).thenReturn(Collections.singletonList(itemValue));
|
||||||
setFetcher(fetcher);
|
setFetcher(fetcher);
|
||||||
|
|
||||||
scrutinize(update);
|
scrutinize(update);
|
||||||
|
@ -43,8 +43,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
import static org.openrefine.wikidata.qa.scrutinizers.FormatScrutinizer.FORMAT_CONSTRAINT_QID;
|
|
||||||
import static org.openrefine.wikidata.qa.scrutinizers.FormatScrutinizer.FORMAT_REGEX_PID;
|
|
||||||
|
|
||||||
public class FormatScrutinizerTest extends ScrutinizerTest {
|
public class FormatScrutinizerTest extends ScrutinizerTest {
|
||||||
|
|
||||||
@ -54,8 +52,8 @@ public class FormatScrutinizerTest extends ScrutinizerTest {
|
|||||||
public static Value incompleteMatchValue = Datamodel.makeStringValue(".jpg");
|
public static Value incompleteMatchValue = Datamodel.makeStringValue(".jpg");
|
||||||
public static String regularExpression = "(?i).+\\.(jpg|jpeg|jpe|png|svg|tif|tiff|gif|xcf|pdf|djvu|webp)";
|
public static String regularExpression = "(?i).+\\.(jpg|jpeg|jpe|png|svg|tif|tiff|gif|xcf|pdf|djvu|webp)";
|
||||||
|
|
||||||
public static ItemIdValue entityIdValue = Datamodel.makeWikidataItemIdValue(FORMAT_CONSTRAINT_QID);
|
public static ItemIdValue entityIdValue = Datamodel.makeWikidataItemIdValue("Q21502404");
|
||||||
public static PropertyIdValue regularExpressionParameter = Datamodel.makeWikidataPropertyIdValue(FORMAT_REGEX_PID);
|
public static PropertyIdValue regularExpressionParameter = Datamodel.makeWikidataPropertyIdValue("P1793");
|
||||||
public static Value regularExpressionFormat = Datamodel.makeStringValue(regularExpression);
|
public static Value regularExpressionFormat = Datamodel.makeStringValue(regularExpression);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -78,8 +76,8 @@ public class FormatScrutinizerTest extends ScrutinizerTest {
|
|||||||
List<Statement> statementList = constraintParameterStatementList(entityIdValue, snakGroupList);
|
List<Statement> statementList = constraintParameterStatementList(entityIdValue, snakGroupList);
|
||||||
|
|
||||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||||
when(fetcher.getConstraintsByType(propertyIdValue, FORMAT_CONSTRAINT_QID)).thenReturn(statementList);
|
when(fetcher.getConstraintsByType(propertyIdValue, "Q21502404")).thenReturn(statementList);
|
||||||
when(fetcher.findValues(snakGroupList, FORMAT_REGEX_PID)).thenReturn(Collections.singletonList(regularExpressionFormat));
|
when(fetcher.findValues(snakGroupList, "P1793")).thenReturn(Collections.singletonList(regularExpressionFormat));
|
||||||
setFetcher(fetcher);
|
setFetcher(fetcher);
|
||||||
scrutinize(updateA);
|
scrutinize(updateA);
|
||||||
assertWarningsRaised(FormatScrutinizer.type);
|
assertWarningsRaised(FormatScrutinizer.type);
|
||||||
@ -99,8 +97,8 @@ public class FormatScrutinizerTest extends ScrutinizerTest {
|
|||||||
List<Statement> statementList = constraintParameterStatementList(entityIdValue, snakGroupList);
|
List<Statement> statementList = constraintParameterStatementList(entityIdValue, snakGroupList);
|
||||||
|
|
||||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||||
when(fetcher.getConstraintsByType(propertyIdValue, FORMAT_CONSTRAINT_QID)).thenReturn(statementList);
|
when(fetcher.getConstraintsByType(propertyIdValue, "Q21502404")).thenReturn(statementList);
|
||||||
when(fetcher.findValues(snakGroupList, FORMAT_REGEX_PID)).thenReturn(Collections.singletonList(regularExpressionFormat));
|
when(fetcher.findValues(snakGroupList, "P1793")).thenReturn(Collections.singletonList(regularExpressionFormat));
|
||||||
setFetcher(fetcher);
|
setFetcher(fetcher);
|
||||||
scrutinize(updateA);
|
scrutinize(updateA);
|
||||||
assertNoWarningRaised();
|
assertNoWarningRaised();
|
||||||
@ -120,8 +118,8 @@ public class FormatScrutinizerTest extends ScrutinizerTest {
|
|||||||
List<Statement> statementList = constraintParameterStatementList(entityIdValue, snakGroupList);
|
List<Statement> statementList = constraintParameterStatementList(entityIdValue, snakGroupList);
|
||||||
|
|
||||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||||
when(fetcher.getConstraintsByType(propertyIdValue, FORMAT_CONSTRAINT_QID)).thenReturn(statementList);
|
when(fetcher.getConstraintsByType(propertyIdValue, "Q21502404")).thenReturn(statementList);
|
||||||
when(fetcher.findValues(snakGroupList, FORMAT_REGEX_PID)).thenReturn(Collections.singletonList(regularExpressionFormat));
|
when(fetcher.findValues(snakGroupList, "P1793")).thenReturn(Collections.singletonList(regularExpressionFormat));
|
||||||
setFetcher(fetcher);
|
setFetcher(fetcher);
|
||||||
scrutinize(updateA);
|
scrutinize(updateA);
|
||||||
assertWarningsRaised(FormatScrutinizer.type);
|
assertWarningsRaised(FormatScrutinizer.type);
|
||||||
|
@ -41,9 +41,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
import static org.openrefine.wikidata.qa.scrutinizers.InverseConstraintScrutinizer.INVERSE_CONSTRAINT_QID;
|
|
||||||
import static org.openrefine.wikidata.qa.scrutinizers.InverseConstraintScrutinizer.INVERSE_PROPERTY_PID;
|
|
||||||
import static org.openrefine.wikidata.qa.scrutinizers.InverseConstraintScrutinizer.SYMMETRIC_CONSTRAINT_QID;
|
|
||||||
|
|
||||||
public class InverseConstaintScrutinizerTest extends StatementScrutinizerTest {
|
public class InverseConstaintScrutinizerTest extends StatementScrutinizerTest {
|
||||||
|
|
||||||
@ -53,9 +50,9 @@ public class InverseConstaintScrutinizerTest extends StatementScrutinizerTest {
|
|||||||
public static PropertyIdValue symmetricPropertyID = Datamodel.makeWikidataPropertyIdValue("P3373");
|
public static PropertyIdValue symmetricPropertyID = Datamodel.makeWikidataPropertyIdValue("P3373");
|
||||||
public static ItemIdValue symmetricPropertyValue = Datamodel.makeWikidataItemIdValue("Q9545711");
|
public static ItemIdValue symmetricPropertyValue = Datamodel.makeWikidataItemIdValue("Q9545711");
|
||||||
|
|
||||||
public static ItemIdValue inverseEntityIdValue = Datamodel.makeWikidataItemIdValue(INVERSE_CONSTRAINT_QID);
|
public static ItemIdValue inverseEntityIdValue = Datamodel.makeWikidataItemIdValue("Q21510855");
|
||||||
public static ItemIdValue symmetricEntityIdValue = Datamodel.makeWikidataItemIdValue(SYMMETRIC_CONSTRAINT_QID);
|
public static ItemIdValue symmetricEntityIdValue = Datamodel.makeWikidataItemIdValue("Q21510862");
|
||||||
public static PropertyIdValue propertyParameter = Datamodel.makeWikidataPropertyIdValue(INVERSE_PROPERTY_PID);
|
public static PropertyIdValue propertyParameter = Datamodel.makeWikidataPropertyIdValue("P2306");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditScrutinizer getScrutinizer() {
|
public EditScrutinizer getScrutinizer() {
|
||||||
@ -76,8 +73,8 @@ public class InverseConstaintScrutinizerTest extends StatementScrutinizerTest {
|
|||||||
List<Statement> statementList = constraintParameterStatementList(inverseEntityIdValue, snakGroupList);
|
List<Statement> statementList = constraintParameterStatementList(inverseEntityIdValue, snakGroupList);
|
||||||
|
|
||||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||||
when(fetcher.getConstraintsByType(propertyId, INVERSE_CONSTRAINT_QID)).thenReturn(statementList);
|
when(fetcher.getConstraintsByType(propertyId, "Q21510855")).thenReturn(statementList);
|
||||||
when(fetcher.findValues(snakGroupList, INVERSE_PROPERTY_PID)).thenReturn(Collections.singletonList(inversePropertyID));
|
when(fetcher.findValues(snakGroupList, "P2306")).thenReturn(Collections.singletonList(inversePropertyID));
|
||||||
setFetcher(fetcher);
|
setFetcher(fetcher);
|
||||||
scrutinize(update);
|
scrutinize(update);
|
||||||
assertWarningsRaised(InverseConstraintScrutinizer.type);
|
assertWarningsRaised(InverseConstraintScrutinizer.type);
|
||||||
@ -97,8 +94,8 @@ public class InverseConstaintScrutinizerTest extends StatementScrutinizerTest {
|
|||||||
List<Statement> statementList = constraintParameterStatementList(symmetricEntityIdValue, snakGroupList);
|
List<Statement> statementList = constraintParameterStatementList(symmetricEntityIdValue, snakGroupList);
|
||||||
|
|
||||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||||
when(fetcher.getConstraintsByType(symmetricPropertyID, SYMMETRIC_CONSTRAINT_QID)).thenReturn(statementList);
|
when(fetcher.getConstraintsByType(symmetricPropertyID, "Q21510862")).thenReturn(statementList);
|
||||||
when(fetcher.findValues(snakGroupList, INVERSE_PROPERTY_PID)).thenReturn(Collections.singletonList(symmetricPropertyID));
|
when(fetcher.findValues(snakGroupList, "P2306")).thenReturn(Collections.singletonList(symmetricPropertyID));
|
||||||
setFetcher(fetcher);
|
setFetcher(fetcher);
|
||||||
scrutinize(update);
|
scrutinize(update);
|
||||||
assertWarningsRaised(InverseConstraintScrutinizer.type);
|
assertWarningsRaised(InverseConstraintScrutinizer.type);
|
||||||
@ -118,8 +115,8 @@ public class InverseConstaintScrutinizerTest extends StatementScrutinizerTest {
|
|||||||
List<Statement> statementList = constraintParameterStatementList(inverseEntityIdValue, snakGroupList);
|
List<Statement> statementList = constraintParameterStatementList(inverseEntityIdValue, snakGroupList);
|
||||||
|
|
||||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||||
when(fetcher.getConstraintsByType(propertyId, INVERSE_CONSTRAINT_QID)).thenReturn(statementList);
|
when(fetcher.getConstraintsByType(propertyId, "Q21510855")).thenReturn(statementList);
|
||||||
when(fetcher.findValues(snakGroupList, INVERSE_PROPERTY_PID)).thenReturn(Collections.singletonList(inversePropertyID));
|
when(fetcher.findValues(snakGroupList, "P2306")).thenReturn(Collections.singletonList(inversePropertyID));
|
||||||
setFetcher(fetcher);
|
setFetcher(fetcher);
|
||||||
scrutinize(update);
|
scrutinize(update);
|
||||||
assertNoWarningRaised();
|
assertNoWarningRaised();
|
||||||
|
@ -10,21 +10,24 @@ import org.wikidata.wdtk.datamodel.implementation.StatementImpl;
|
|||||||
import org.wikidata.wdtk.datamodel.interfaces.ItemIdValue;
|
import org.wikidata.wdtk.datamodel.interfaces.ItemIdValue;
|
||||||
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue;
|
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue;
|
||||||
import org.wikidata.wdtk.datamodel.interfaces.Snak;
|
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.Statement;
|
||||||
import org.wikidata.wdtk.datamodel.interfaces.Value;
|
import org.wikidata.wdtk.datamodel.interfaces.Value;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
import static org.openrefine.wikidata.qa.scrutinizers.MultiValueScrutinizer.MULTI_VALUE_CONSTRAINT_QID;
|
|
||||||
|
|
||||||
public class MultiValueScrutinizerTest extends ScrutinizerTest {
|
public class MultiValueScrutinizerTest extends ScrutinizerTest {
|
||||||
|
|
||||||
public static PropertyIdValue propertyIdValue = Datamodel.makeWikidataPropertyIdValue("P1963");
|
public static PropertyIdValue propertyIdValue = Datamodel.makeWikidataPropertyIdValue("P1963");
|
||||||
public static Value valueSnak = Datamodel.makeWikidataItemIdValue("Q5");
|
public static Value valueSnak1 = Datamodel.makeWikidataItemIdValue("Q5");
|
||||||
public static ItemIdValue entityIdValue = Datamodel.makeWikidataItemIdValue(MULTI_VALUE_CONSTRAINT_QID);
|
public static Value valueSnak2 = Datamodel.makeWikidataItemIdValue("Q4");
|
||||||
|
public static ItemIdValue entityIdValue = Datamodel.makeWikidataItemIdValue("Q21510857");
|
||||||
|
public static PropertyIdValue constraintParameter = Datamodel.makeWikidataPropertyIdValue("P2316");
|
||||||
|
public static Value constraintStatus = Datamodel.makeWikidataItemIdValue("Q62026391");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditScrutinizer getScrutinizer() {
|
public EditScrutinizer getScrutinizer() {
|
||||||
@ -42,9 +45,13 @@ public class MultiValueScrutinizerTest extends ScrutinizerTest {
|
|||||||
ItemUpdate update = new ItemUpdateBuilder(idA).addStatement(TestingData.generateStatement(idA, idB))
|
ItemUpdate update = new ItemUpdateBuilder(idA).addStatement(TestingData.generateStatement(idA, idB))
|
||||||
.addStatement(TestingData.generateStatement(idA, idB)).addStatement(statement1).addStatement(statement2).build();
|
.addStatement(TestingData.generateStatement(idA, idB)).addStatement(statement1).addStatement(statement2).build();
|
||||||
|
|
||||||
List<Statement> statementList = constraintParameterStatementList(entityIdValue, new ArrayList<>());
|
Snak snak = Datamodel.makeValueSnak(constraintParameter, constraintStatus);
|
||||||
|
List<Snak> snakList1 = Collections.singletonList(snak);
|
||||||
|
SnakGroup snakGroup = Datamodel.makeSnakGroup(snakList1);
|
||||||
|
List<SnakGroup> snakGroupList = Collections.singletonList(snakGroup);
|
||||||
|
List<Statement> statementList = constraintParameterStatementList(entityIdValue, snakGroupList);
|
||||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||||
when(fetcher.getConstraintsByType(propertyIdValue, MULTI_VALUE_CONSTRAINT_QID)).thenReturn(statementList);
|
when(fetcher.getConstraintsByType(propertyIdValue, "Q21510857")).thenReturn(statementList);
|
||||||
setFetcher(fetcher);
|
setFetcher(fetcher);
|
||||||
|
|
||||||
scrutinize(update);
|
scrutinize(update);
|
||||||
@ -55,14 +62,18 @@ public class MultiValueScrutinizerTest extends ScrutinizerTest {
|
|||||||
public void testNewItemTrigger() {
|
public void testNewItemTrigger() {
|
||||||
ItemIdValue idA = TestingData.newIdA;
|
ItemIdValue idA = TestingData.newIdA;
|
||||||
ItemIdValue idB = TestingData.newIdB;
|
ItemIdValue idB = TestingData.newIdB;
|
||||||
Snak mainSnakValue = Datamodel.makeValueSnak(propertyIdValue, valueSnak);
|
Snak mainSnakValue = Datamodel.makeValueSnak(propertyIdValue, valueSnak1);
|
||||||
Statement statement = new StatementImpl("P1963", mainSnakValue, idA);
|
Statement statement = new StatementImpl("P1963", mainSnakValue, idA);
|
||||||
ItemUpdate updateA = new ItemUpdateBuilder(idA).addStatement(TestingData.generateStatement(idA, idB)).addStatement(statement).build();
|
ItemUpdate updateA = new ItemUpdateBuilder(idA).addStatement(TestingData.generateStatement(idA, idB)).addStatement(statement).build();
|
||||||
ItemUpdate updateB = new ItemUpdateBuilder(idB).addStatement(TestingData.generateStatement(idB, idB)).build();
|
ItemUpdate updateB = new ItemUpdateBuilder(idB).addStatement(TestingData.generateStatement(idB, idB)).build();
|
||||||
|
|
||||||
List<Statement> statementList = constraintParameterStatementList(entityIdValue, new ArrayList<>());
|
Snak snak = Datamodel.makeValueSnak(constraintParameter, constraintStatus);
|
||||||
|
List<Snak> snakList1 = Collections.singletonList(snak);
|
||||||
|
SnakGroup snakGroup = Datamodel.makeSnakGroup(snakList1);
|
||||||
|
List<SnakGroup> snakGroupList = Collections.singletonList(snakGroup);
|
||||||
|
List<Statement> statementList = constraintParameterStatementList(entityIdValue, snakGroupList);
|
||||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||||
when(fetcher.getConstraintsByType(propertyIdValue, MULTI_VALUE_CONSTRAINT_QID)).thenReturn(statementList);
|
when(fetcher.getConstraintsByType(propertyIdValue, "Q21510857")).thenReturn(statementList);
|
||||||
setFetcher(fetcher);
|
setFetcher(fetcher);
|
||||||
|
|
||||||
scrutinize(updateA, updateB);
|
scrutinize(updateA, updateB);
|
||||||
@ -73,14 +84,18 @@ public class MultiValueScrutinizerTest extends ScrutinizerTest {
|
|||||||
public void testExistingItemTrigger() {
|
public void testExistingItemTrigger() {
|
||||||
ItemIdValue idA = TestingData.existingId;
|
ItemIdValue idA = TestingData.existingId;
|
||||||
ItemIdValue idB = TestingData.matchedId;
|
ItemIdValue idB = TestingData.matchedId;
|
||||||
Snak mainSnakValue = Datamodel.makeValueSnak(propertyIdValue, valueSnak);
|
Snak mainSnakValue = Datamodel.makeValueSnak(propertyIdValue, valueSnak1);
|
||||||
Statement statement = new StatementImpl("P1963", mainSnakValue, idA);
|
Statement statement = new StatementImpl("P1963", mainSnakValue, idA);
|
||||||
ItemUpdate updateA = new ItemUpdateBuilder(idA).addStatement(TestingData.generateStatement(idA, idB)).addStatement(statement).build();
|
ItemUpdate updateA = new ItemUpdateBuilder(idA).addStatement(TestingData.generateStatement(idA, idB)).addStatement(statement).build();
|
||||||
ItemUpdate updateB = new ItemUpdateBuilder(idB).addStatement(TestingData.generateStatement(idB, idB)).build();
|
ItemUpdate updateB = new ItemUpdateBuilder(idB).addStatement(TestingData.generateStatement(idB, idB)).build();
|
||||||
|
|
||||||
List<Statement> statementList = constraintParameterStatementList(entityIdValue, new ArrayList<>());
|
Snak snak = Datamodel.makeValueSnak(constraintParameter, constraintStatus);
|
||||||
|
List<Snak> snakList1 = Collections.singletonList(snak);
|
||||||
|
SnakGroup snakGroup = Datamodel.makeSnakGroup(snakList1);
|
||||||
|
List<SnakGroup> snakGroupList = Collections.singletonList(snakGroup);
|
||||||
|
List<Statement> statementList = constraintParameterStatementList(entityIdValue, snakGroupList);
|
||||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||||
when(fetcher.getConstraintsByType(propertyIdValue, MULTI_VALUE_CONSTRAINT_QID)).thenReturn(statementList);
|
when(fetcher.getConstraintsByType(propertyIdValue, "Q21510857")).thenReturn(statementList);
|
||||||
setFetcher(fetcher);
|
setFetcher(fetcher);
|
||||||
|
|
||||||
scrutinize(updateA, updateB);
|
scrutinize(updateA, updateB);
|
||||||
|
@ -44,16 +44,12 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
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 {
|
public class QualifierCompatibilityScrutinizerTest extends StatementScrutinizerTest {
|
||||||
|
|
||||||
public static ItemIdValue allowedQualifierEntity = Datamodel.makeWikidataItemIdValue(ALLOWED_QUALIFIERS_CONSTRAINT_QID);
|
public static ItemIdValue allowedQualifierEntity = Datamodel.makeWikidataItemIdValue("Q21510851");
|
||||||
public static ItemIdValue mandatoryQualifierEntity = Datamodel.makeWikidataItemIdValue(MANDATORY_QUALIFIERS_CONSTRAINT_QID);
|
public static ItemIdValue mandatoryQualifierEntity = Datamodel.makeWikidataItemIdValue("Q21510856");
|
||||||
public static PropertyIdValue propertyParameterPID = Datamodel.makeWikidataPropertyIdValue(ALLOWED_QUALIFIERS_CONSTRAINT_PID);
|
public static PropertyIdValue propertyParameterPID = Datamodel.makeWikidataPropertyIdValue("P2306");
|
||||||
public static PropertyIdValue propertyParameterValue = Datamodel.makeWikidataPropertyIdValue("P585");
|
public static PropertyIdValue propertyParameterValue = Datamodel.makeWikidataPropertyIdValue("P585");
|
||||||
|
|
||||||
public static PropertyIdValue allowedPropertyIdValue = Datamodel.makeWikidataPropertyIdValue("P2196");
|
public static PropertyIdValue allowedPropertyIdValue = Datamodel.makeWikidataPropertyIdValue("P2196");
|
||||||
@ -81,8 +77,8 @@ public class QualifierCompatibilityScrutinizerTest extends StatementScrutinizerT
|
|||||||
List<Statement> statementList = constraintParameterStatementList(allowedQualifierEntity, snakGroupList);
|
List<Statement> statementList = constraintParameterStatementList(allowedQualifierEntity, snakGroupList);
|
||||||
|
|
||||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||||
when(fetcher.getConstraintsByType(allowedPropertyIdValue, ALLOWED_QUALIFIERS_CONSTRAINT_QID)).thenReturn(statementList);
|
when(fetcher.getConstraintsByType(allowedPropertyIdValue, "Q21510851")).thenReturn(statementList);
|
||||||
when(fetcher.findValues(snakGroupList, ALLOWED_QUALIFIERS_CONSTRAINT_PID)).thenReturn(Collections.singletonList(qualifierProperty));
|
when(fetcher.findValues(snakGroupList, "P2306")).thenReturn(Collections.singletonList(qualifierProperty));
|
||||||
setFetcher(fetcher);
|
setFetcher(fetcher);
|
||||||
|
|
||||||
scrutinize(update);
|
scrutinize(update);
|
||||||
@ -103,8 +99,8 @@ public class QualifierCompatibilityScrutinizerTest extends StatementScrutinizerT
|
|||||||
List<Statement> statementList = constraintParameterStatementList(mandatoryQualifierEntity, snakGroupList);
|
List<Statement> statementList = constraintParameterStatementList(mandatoryQualifierEntity, snakGroupList);
|
||||||
|
|
||||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||||
when(fetcher.getConstraintsByType(mandatoryPropertyIdValue, MANDATORY_QUALIFIERS_CONSTRAINT_QID)).thenReturn(statementList);
|
when(fetcher.getConstraintsByType(mandatoryPropertyIdValue, "Q21510856")).thenReturn(statementList);
|
||||||
when(fetcher.findValues(snakGroupList, MANDATORY_QUALIFIERS_CONSTRAINT_PID)).thenReturn(Collections.singletonList(qualifierProperty));
|
when(fetcher.findValues(snakGroupList, "P2306")).thenReturn(Collections.singletonList(qualifierProperty));
|
||||||
setFetcher(fetcher);
|
setFetcher(fetcher);
|
||||||
|
|
||||||
scrutinize(update);
|
scrutinize(update);
|
||||||
@ -126,8 +122,8 @@ public class QualifierCompatibilityScrutinizerTest extends StatementScrutinizerT
|
|||||||
List<Statement> statementList = constraintParameterStatementList(allowedQualifierEntity, snakGroupList);
|
List<Statement> statementList = constraintParameterStatementList(allowedQualifierEntity, snakGroupList);
|
||||||
|
|
||||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||||
when(fetcher.getConstraintsByType(allowedPropertyIdValue, ALLOWED_QUALIFIERS_CONSTRAINT_QID)).thenReturn(statementList);
|
when(fetcher.getConstraintsByType(allowedPropertyIdValue, "Q21510851")).thenReturn(statementList);
|
||||||
when(fetcher.findValues(snakGroupList, ALLOWED_QUALIFIERS_CONSTRAINT_PID)).thenReturn(Collections.singletonList(qualifierProperty));
|
when(fetcher.findValues(snakGroupList, "P2306")).thenReturn(Collections.singletonList(qualifierProperty));
|
||||||
setFetcher(fetcher);
|
setFetcher(fetcher);
|
||||||
|
|
||||||
scrutinize(update);
|
scrutinize(update);
|
||||||
|
@ -24,7 +24,6 @@ import static org.mockito.ArgumentMatchers.any;
|
|||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
import static org.openrefine.wikidata.qa.scrutinizers.QuantityScrutinizer.ALLOWED_UNITS_CONSTRAINT_PID;
|
|
||||||
import static org.openrefine.wikidata.qa.scrutinizers.QuantityScrutinizer.ALLOWED_UNITS_CONSTRAINT_QID;
|
import static org.openrefine.wikidata.qa.scrutinizers.QuantityScrutinizer.ALLOWED_UNITS_CONSTRAINT_QID;
|
||||||
import static org.openrefine.wikidata.qa.scrutinizers.QuantityScrutinizer.INTEGER_VALUED_CONSTRAINT_QID;
|
import static org.openrefine.wikidata.qa.scrutinizers.QuantityScrutinizer.INTEGER_VALUED_CONSTRAINT_QID;
|
||||||
import static org.openrefine.wikidata.qa.scrutinizers.QuantityScrutinizer.NO_BOUNDS_CONSTRAINT_QID;
|
import static org.openrefine.wikidata.qa.scrutinizers.QuantityScrutinizer.NO_BOUNDS_CONSTRAINT_QID;
|
||||||
@ -56,7 +55,7 @@ public class QuantityScrutinizerTest extends ValueScrutinizerTest{
|
|||||||
public static ItemIdValue noBoundsEntity = Datamodel.makeWikidataItemIdValue(NO_BOUNDS_CONSTRAINT_QID);
|
public static ItemIdValue noBoundsEntity = Datamodel.makeWikidataItemIdValue(NO_BOUNDS_CONSTRAINT_QID);
|
||||||
public static ItemIdValue integerValueEntity = Datamodel.makeWikidataItemIdValue(INTEGER_VALUED_CONSTRAINT_QID);
|
public static ItemIdValue integerValueEntity = Datamodel.makeWikidataItemIdValue(INTEGER_VALUED_CONSTRAINT_QID);
|
||||||
public static ItemIdValue allowedUnitEntity = Datamodel.makeWikidataItemIdValue(ALLOWED_UNITS_CONSTRAINT_QID);
|
public static ItemIdValue allowedUnitEntity = Datamodel.makeWikidataItemIdValue(ALLOWED_UNITS_CONSTRAINT_QID);
|
||||||
public static PropertyIdValue itemParameterPID = Datamodel.makeWikidataPropertyIdValue(ALLOWED_UNITS_CONSTRAINT_PID);
|
public static PropertyIdValue itemParameterPID = Datamodel.makeWikidataPropertyIdValue("P2305");
|
||||||
public static Value allowedUnit = Datamodel.makeWikidataItemIdValue("Q5");
|
public static Value allowedUnit = Datamodel.makeWikidataItemIdValue("Q5");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -212,7 +211,7 @@ public class QuantityScrutinizerTest extends ValueScrutinizerTest{
|
|||||||
List<Statement> constraintDefinitions = constraintParameterStatementList(allowedUnitEntity, constraintQualifiers);
|
List<Statement> constraintDefinitions = constraintParameterStatementList(allowedUnitEntity, constraintQualifiers);
|
||||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||||
when(fetcher.getConstraintsByType(propertyIdValue, ALLOWED_UNITS_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
|
when(fetcher.getConstraintsByType(propertyIdValue, ALLOWED_UNITS_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
|
||||||
when(fetcher.findValues(constraintQualifiers, ALLOWED_UNITS_CONSTRAINT_PID)).thenReturn(Collections.singletonList(allowedUnit));
|
when(fetcher.findValues(constraintQualifiers, "P2305")).thenReturn(Collections.singletonList(allowedUnit));
|
||||||
setFetcher(fetcher);
|
setFetcher(fetcher);
|
||||||
|
|
||||||
scrutinize(update);
|
scrutinize(update);
|
||||||
@ -229,7 +228,7 @@ public class QuantityScrutinizerTest extends ValueScrutinizerTest{
|
|||||||
List<Statement> constraintDefinitions = constraintParameterStatementList(allowedUnitEntity, new ArrayList<>());
|
List<Statement> constraintDefinitions = constraintParameterStatementList(allowedUnitEntity, new ArrayList<>());
|
||||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||||
when(fetcher.getConstraintsByType(propertyIdValue, ALLOWED_UNITS_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
|
when(fetcher.getConstraintsByType(propertyIdValue, ALLOWED_UNITS_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
|
||||||
when(fetcher.findValues(any(), eq(ALLOWED_UNITS_CONSTRAINT_PID))).thenReturn(new ArrayList<>());
|
when(fetcher.findValues(any(), eq("P2305"))).thenReturn(new ArrayList<>());
|
||||||
setFetcher(fetcher);
|
setFetcher(fetcher);
|
||||||
|
|
||||||
scrutinize(update);
|
scrutinize(update);
|
||||||
@ -245,7 +244,7 @@ public class QuantityScrutinizerTest extends ValueScrutinizerTest{
|
|||||||
|
|
||||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||||
when(fetcher.getConstraintsByType(propertyIdValue, ALLOWED_UNITS_CONSTRAINT_QID)).thenReturn(new ArrayList<>());
|
when(fetcher.getConstraintsByType(propertyIdValue, ALLOWED_UNITS_CONSTRAINT_QID)).thenReturn(new ArrayList<>());
|
||||||
when(fetcher.findValues(any(), eq(ALLOWED_UNITS_CONSTRAINT_PID))).thenReturn(new ArrayList<>());
|
when(fetcher.findValues(any(), eq("P2305"))).thenReturn(new ArrayList<>());
|
||||||
setFetcher(fetcher);
|
setFetcher(fetcher);
|
||||||
|
|
||||||
scrutinize(update);
|
scrutinize(update);
|
||||||
|
@ -46,15 +46,18 @@ import static org.mockito.Mockito.when;
|
|||||||
import static org.openrefine.wikidata.qa.scrutinizers.RestrictedPositionScrutinizer.SCOPE_CONSTRAINT_PID;
|
import static org.openrefine.wikidata.qa.scrutinizers.RestrictedPositionScrutinizer.SCOPE_CONSTRAINT_PID;
|
||||||
import static org.openrefine.wikidata.qa.scrutinizers.RestrictedPositionScrutinizer.SCOPE_CONSTRAINT_QID;
|
import static org.openrefine.wikidata.qa.scrutinizers.RestrictedPositionScrutinizer.SCOPE_CONSTRAINT_QID;
|
||||||
import static org.openrefine.wikidata.qa.scrutinizers.RestrictedPositionScrutinizer.SCOPE_CONSTRAINT_QUALIFIER_QID;
|
import static org.openrefine.wikidata.qa.scrutinizers.RestrictedPositionScrutinizer.SCOPE_CONSTRAINT_QUALIFIER_QID;
|
||||||
|
import static org.openrefine.wikidata.qa.scrutinizers.RestrictedPositionScrutinizer.SCOPE_CONSTRAINT_REFERENCE_QID;
|
||||||
import static org.openrefine.wikidata.qa.scrutinizers.RestrictedPositionScrutinizer.SCOPE_CONSTRAINT_VALUE_QID;
|
import static org.openrefine.wikidata.qa.scrutinizers.RestrictedPositionScrutinizer.SCOPE_CONSTRAINT_VALUE_QID;
|
||||||
|
|
||||||
public class RestrictedPositionScrutinizerTest extends SnakScrutinizerTest {
|
public class RestrictedPositionScrutinizerTest extends SnakScrutinizerTest {
|
||||||
|
|
||||||
public static PropertyIdValue propertyIdValue = Datamodel.makeWikidataPropertyIdValue("P22");
|
public static PropertyIdValue propertyIdValue = Datamodel.makeWikidataPropertyIdValue("P22");
|
||||||
public static PropertyIdValue propertyScopeParameter = Datamodel.makeWikidataPropertyIdValue(SCOPE_CONSTRAINT_PID);
|
public static PropertyIdValue mainSnakPid = Datamodel.makeWikidataPropertyIdValue("P1234");
|
||||||
|
public static PropertyIdValue propertyScopeParameter = Datamodel.makeWikidataPropertyIdValue("P5314");
|
||||||
public static ItemIdValue entityIdValue = Datamodel.makeWikidataItemIdValue(SCOPE_CONSTRAINT_QID);
|
public static ItemIdValue entityIdValue = Datamodel.makeWikidataItemIdValue(SCOPE_CONSTRAINT_QID);
|
||||||
public static ItemIdValue asMainSnak = Datamodel.makeWikidataItemIdValue(SCOPE_CONSTRAINT_VALUE_QID);
|
public static ItemIdValue asMainSnak = Datamodel.makeWikidataItemIdValue(SCOPE_CONSTRAINT_VALUE_QID);
|
||||||
public static ItemIdValue asQualifier = Datamodel.makeWikidataItemIdValue(SCOPE_CONSTRAINT_QUALIFIER_QID);
|
public static ItemIdValue asQualifier = Datamodel.makeWikidataItemIdValue(SCOPE_CONSTRAINT_QUALIFIER_QID);
|
||||||
|
public static ItemIdValue asReference = Datamodel.makeWikidataItemIdValue(SCOPE_CONSTRAINT_REFERENCE_QID);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditScrutinizer getScrutinizer() {
|
public EditScrutinizer getScrutinizer() {
|
||||||
|
@ -34,7 +34,7 @@ public class RestrictedValuesScrutinizerTest extends SnakScrutinizerTest {
|
|||||||
public static ItemIdValue allowedValueEntity = Datamodel.makeWikidataItemIdValue(ALLOWED_VALUES_CONSTRAINT_QID);
|
public static ItemIdValue allowedValueEntity = Datamodel.makeWikidataItemIdValue(ALLOWED_VALUES_CONSTRAINT_QID);
|
||||||
public static ItemIdValue disallowedValueEntity = Datamodel.makeWikidataItemIdValue(DISALLOWED_VALUES_CONSTRAINT_QID);
|
public static ItemIdValue disallowedValueEntity = Datamodel.makeWikidataItemIdValue(DISALLOWED_VALUES_CONSTRAINT_QID);
|
||||||
|
|
||||||
public static PropertyIdValue itemParameterPID = Datamodel.makeWikidataPropertyIdValue(ALLOWED_VALUES_CONSTRAINT_PID);
|
public static PropertyIdValue itemParameterPID = Datamodel.makeWikidataPropertyIdValue("P2305");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditScrutinizer getScrutinizer() {
|
public EditScrutinizer getScrutinizer() {
|
||||||
|
@ -33,15 +33,15 @@ import org.wikidata.wdtk.datamodel.implementation.StatementImpl;
|
|||||||
import org.wikidata.wdtk.datamodel.interfaces.ItemIdValue;
|
import org.wikidata.wdtk.datamodel.interfaces.ItemIdValue;
|
||||||
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue;
|
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue;
|
||||||
import org.wikidata.wdtk.datamodel.interfaces.Snak;
|
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.Statement;
|
||||||
import org.wikidata.wdtk.datamodel.interfaces.Value;
|
import org.wikidata.wdtk.datamodel.interfaces.Value;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
import static org.openrefine.wikidata.qa.scrutinizers.SingleValueScrutinizer.SINGLE_VALUE_CONSTRAINT_QID;
|
|
||||||
|
|
||||||
public class SingleValueScrutinizerTest extends ScrutinizerTest {
|
public class SingleValueScrutinizerTest extends ScrutinizerTest {
|
||||||
|
|
||||||
@ -49,7 +49,9 @@ public class SingleValueScrutinizerTest extends ScrutinizerTest {
|
|||||||
public static Value value1 = Datamodel.makeWikidataItemIdValue("Q6581072");
|
public static Value value1 = Datamodel.makeWikidataItemIdValue("Q6581072");
|
||||||
public static Value value2 = Datamodel.makeWikidataItemIdValue("Q6581097");
|
public static Value value2 = Datamodel.makeWikidataItemIdValue("Q6581097");
|
||||||
|
|
||||||
public static ItemIdValue entityIdValue = Datamodel.makeWikidataItemIdValue(SINGLE_VALUE_CONSTRAINT_QID);
|
public static ItemIdValue entityIdValue = Datamodel.makeWikidataItemIdValue("Q19474404");
|
||||||
|
public static PropertyIdValue constraintException = Datamodel.makeWikidataPropertyIdValue("P2303");
|
||||||
|
public static Value exceptionValue = Datamodel.makeWikidataItemIdValue("Q7409772");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditScrutinizer getScrutinizer() {
|
public EditScrutinizer getScrutinizer() {
|
||||||
@ -65,10 +67,14 @@ public class SingleValueScrutinizerTest extends ScrutinizerTest {
|
|||||||
Statement statement2 = new StatementImpl("P21", snak2, idA);
|
Statement statement2 = new StatementImpl("P21", snak2, idA);
|
||||||
ItemUpdate update = new ItemUpdateBuilder(idA).addStatement(statement1).addStatement(statement2).build();
|
ItemUpdate update = new ItemUpdateBuilder(idA).addStatement(statement1).addStatement(statement2).build();
|
||||||
|
|
||||||
List<Statement> statementList = constraintParameterStatementList(entityIdValue, new ArrayList<>());
|
Snak snak = Datamodel.makeValueSnak(constraintException, exceptionValue);
|
||||||
|
List<Snak> snakList = Collections.singletonList(snak);
|
||||||
|
SnakGroup snakGroup = Datamodel.makeSnakGroup(snakList);
|
||||||
|
List<SnakGroup> snakGroupList = Collections.singletonList(snakGroup);
|
||||||
|
List<Statement> statementList = constraintParameterStatementList(entityIdValue, snakGroupList);
|
||||||
|
|
||||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||||
when(fetcher.getConstraintsByType(propertyIdValue, SINGLE_VALUE_CONSTRAINT_QID)).thenReturn(statementList);
|
when(fetcher.getConstraintsByType(propertyIdValue, "Q19474404")).thenReturn(statementList);
|
||||||
setFetcher(fetcher);
|
setFetcher(fetcher);
|
||||||
scrutinize(update);
|
scrutinize(update);
|
||||||
assertWarningsRaised(SingleValueScrutinizer.type);
|
assertWarningsRaised(SingleValueScrutinizer.type);
|
||||||
@ -81,10 +87,14 @@ public class SingleValueScrutinizerTest extends ScrutinizerTest {
|
|||||||
Statement statement1 = new StatementImpl("P21", snak1, idA);
|
Statement statement1 = new StatementImpl("P21", snak1, idA);
|
||||||
ItemUpdate updateA = new ItemUpdateBuilder(idA).addStatement(statement1).build();
|
ItemUpdate updateA = new ItemUpdateBuilder(idA).addStatement(statement1).build();
|
||||||
|
|
||||||
List<Statement> statementList = constraintParameterStatementList(entityIdValue, new ArrayList<>());
|
Snak snak = Datamodel.makeValueSnak(constraintException, exceptionValue);
|
||||||
|
List<Snak> snakList = Collections.singletonList(snak);
|
||||||
|
SnakGroup snakGroup = Datamodel.makeSnakGroup(snakList);
|
||||||
|
List<SnakGroup> snakGroupList = Collections.singletonList(snakGroup);
|
||||||
|
List<Statement> statementList = constraintParameterStatementList(entityIdValue, snakGroupList);
|
||||||
|
|
||||||
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
|
||||||
when(fetcher.getConstraintsByType(propertyIdValue, SINGLE_VALUE_CONSTRAINT_QID)).thenReturn(statementList);
|
when(fetcher.getConstraintsByType(propertyIdValue, "Q19474404")).thenReturn(statementList);
|
||||||
setFetcher(fetcher);
|
setFetcher(fetcher);
|
||||||
scrutinize(updateA);
|
scrutinize(updateA);
|
||||||
assertNoWarningRaised();
|
assertNoWarningRaised();
|
||||||
|
Loading…
Reference in New Issue
Block a user