use of org.openrefine.wikidata.qa.ConstraintFetcher in project OpenRefine by OpenRefine.
the class MultiValueScrutinizerTest method testExistingItemTrigger.
@Test
public void testExistingItemTrigger() {
ItemIdValue idA = TestingData.existingId;
ItemIdValue idB = TestingData.matchedId;
Snak mainSnakValue = Datamodel.makeValueSnak(propertyIdValue, valueSnak);
Statement statement = new StatementImpl("P1963", mainSnakValue, idA);
TermedStatementEntityEdit updateA = new TermedStatementEntityEditBuilder(idA).addStatement(add(TestingData.generateStatement(idA, idB))).addStatement(add(statement)).build();
TermedStatementEntityEdit updateB = new TermedStatementEntityEditBuilder(idB).addStatement(add(TestingData.generateStatement(idB, idB))).build();
List<Statement> constraintDefinitions = constraintParameterStatementList(entityIdValue, new ArrayList<>());
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
when(fetcher.getConstraintsByType(propertyIdValue, MULTI_VALUE_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
setFetcher(fetcher);
scrutinize(updateA, updateB);
assertWarningsRaised(MultiValueScrutinizer.existing_type);
}
use of org.openrefine.wikidata.qa.ConstraintFetcher in project OpenRefine by OpenRefine.
the class FormatScrutinizerTest method testIncompleteMatch.
@Test
public void testIncompleteMatch() {
ItemIdValue idA = TestingData.existingId;
ValueSnak value = Datamodel.makeValueSnak(propertyIdValue, incompleteMatchValue);
Statement statement = new StatementImpl("P18", value, idA);
TermedStatementEntityEdit updateA = new TermedStatementEntityEditBuilder(idA).addStatement(add(statement)).build();
List<Statement> constraintDefinitions = generateFormatConstraint(regularExpression);
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
when(fetcher.getConstraintsByType(propertyIdValue, FORMAT_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
setFetcher(fetcher);
scrutinize(updateA);
assertWarningsRaised(FormatScrutinizer.type);
}
use of org.openrefine.wikidata.qa.ConstraintFetcher in project OpenRefine by OpenRefine.
the class FormatScrutinizerTest method testNoIssue.
@Test
public void testNoIssue() {
ItemIdValue idA = TestingData.existingId;
ValueSnak value = Datamodel.makeValueSnak(propertyIdValue, completeMatchValue);
Statement statement = new StatementImpl("P18", value, idA);
TermedStatementEntityEdit updateA = new TermedStatementEntityEditBuilder(idA).addStatement(add(statement)).build();
List<Statement> constraintDefinitions = generateFormatConstraint(regularExpression);
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
when(fetcher.getConstraintsByType(propertyIdValue, FORMAT_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
setFetcher(fetcher);
scrutinize(updateA);
assertNoWarningRaised();
}
use of org.openrefine.wikidata.qa.ConstraintFetcher in project OpenRefine by OpenRefine.
the class FormatScrutinizerTest method testTrigger.
@Test
public void testTrigger() {
ItemIdValue idA = TestingData.existingId;
ValueSnak value = Datamodel.makeValueSnak(propertyIdValue, noMatchValue);
Statement statement = new StatementImpl("P18", value, idA);
TermedStatementEntityEdit updateA = new TermedStatementEntityEditBuilder(idA).addStatement(add(statement)).build();
List<Statement> constraintDefinitions = generateFormatConstraint(regularExpression);
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
when(fetcher.getConstraintsByType(propertyIdValue, FORMAT_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
setFetcher(fetcher);
scrutinize(updateA);
assertWarningsRaised(FormatScrutinizer.type);
}
use of org.openrefine.wikidata.qa.ConstraintFetcher in project OpenRefine by OpenRefine.
the class FormatScrutinizerTest method testInvalidRegex.
@Test
public void testInvalidRegex() {
ItemIdValue idA = TestingData.existingId;
ValueSnak value = Datamodel.makeValueSnak(propertyIdValue, incompleteMatchValue);
Statement statement = new StatementImpl("P18", value, idA);
TermedStatementEntityEdit updateA = new TermedStatementEntityEditBuilder(idA).addStatement(add(statement)).build();
List<Statement> constraintDefinitions = generateFormatConstraint(invalidRegularExpression);
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
when(fetcher.getConstraintsByType(propertyIdValue, FORMAT_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
setFetcher(fetcher);
scrutinize(updateA);
assertNoWarningRaised();
}
Aggregations