use of org.wikidata.wdtk.datamodel.implementation.TimeValueImpl in project OpenRefine by OpenRefine.
the class DifferenceWithinScrutinizerTest method testTrigger.
@Test
public void testTrigger() {
ItemIdValue idA = TestingData.existingId;
TimeValue lowerYear = new TimeValueImpl(1800, (byte) 10, (byte) 15, (byte) 0, (byte) 0, (byte) 0, (byte) 11, 0, 0, 0, TimeValue.CM_GREGORIAN_PRO);
TimeValue upperYear = new TimeValueImpl(2020, (byte) 10, (byte) 15, (byte) 0, (byte) 0, (byte) 0, (byte) 11, 0, 0, 0, TimeValue.CM_GREGORIAN_PRO);
ValueSnak value1 = Datamodel.makeValueSnak(lowerBoundPid, lowerYear);
ValueSnak value2 = Datamodel.makeValueSnak(upperBoundPid, upperYear);
Statement statement1 = new StatementImpl("P569", value1, idA);
Statement statement2 = new StatementImpl("P570", value2, idA);
TermedStatementEntityEdit updateA = new TermedStatementEntityEditBuilder(idA).addStatement(add(statement1)).addStatement(add(statement2)).build();
Snak propertyQualifier = Datamodel.makeValueSnak(propertyParameterPID, lowerBoundPid);
Snak minValueQualifier = Datamodel.makeValueSnak(minimumValuePID, minValue);
Snak maxValueQualifier = Datamodel.makeValueSnak(maximumValuePID, maxValue);
List<SnakGroup> constraintQualifiers = makeSnakGroupList(propertyQualifier, minValueQualifier, maxValueQualifier);
List<Statement> constraintDefinitions = constraintParameterStatementList(entityIdValue, constraintQualifiers);
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
when(fetcher.getConstraintsByType(upperBoundPid, DIFFERENCE_WITHIN_RANGE_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
setFetcher(fetcher);
scrutinize(updateA);
assertWarningsRaised(DifferenceWithinRangeScrutinizer.type);
}
use of org.wikidata.wdtk.datamodel.implementation.TimeValueImpl in project OpenRefine by OpenRefine.
the class DifferenceWithinScrutinizerTest method testNoIssue.
@Test
public void testNoIssue() {
ItemIdValue idA = TestingData.existingId;
TimeValue lowerYear = new TimeValueImpl(2000, (byte) 10, (byte) 15, (byte) 0, (byte) 0, (byte) 0, (byte) 11, 0, 0, 0, TimeValue.CM_GREGORIAN_PRO);
TimeValue upperYear = new TimeValueImpl(2020, (byte) 10, (byte) 15, (byte) 0, (byte) 0, (byte) 0, (byte) 11, 0, 0, 0, TimeValue.CM_GREGORIAN_PRO);
ValueSnak value1 = Datamodel.makeValueSnak(lowerBoundPid, lowerYear);
ValueSnak value2 = Datamodel.makeValueSnak(upperBoundPid, upperYear);
Statement statement1 = new StatementImpl("P569", value1, idA);
Statement statement2 = new StatementImpl("P570", value2, idA);
TermedStatementEntityEdit updateA = new TermedStatementEntityEditBuilder(idA).addStatement(add(statement1)).addStatement(add(statement2)).build();
Snak propertyQualifier = Datamodel.makeValueSnak(propertyParameterPID, lowerBoundPid);
Snak minValueQualifier = Datamodel.makeValueSnak(minimumValuePID, minValue);
Snak maxValueQualifier = Datamodel.makeValueSnak(maximumValuePID, maxValue);
List<SnakGroup> constraintQualifiers = makeSnakGroupList(propertyQualifier, minValueQualifier, maxValueQualifier);
List<Statement> constraintDefinitions = constraintParameterStatementList(entityIdValue, constraintQualifiers);
ConstraintFetcher fetcher = mock(ConstraintFetcher.class);
when(fetcher.getConstraintsByType(upperBoundPid, DIFFERENCE_WITHIN_RANGE_CONSTRAINT_QID)).thenReturn(constraintDefinitions);
setFetcher(fetcher);
scrutinize(updateA);
assertNoWarningRaised();
}
Aggregations