Skip to content

Commit

Permalink
Updating implementation of tdwg/bdq#84 and unit tests to settled upon…
Browse files Browse the repository at this point in the history
… default earlyest value for year of 1582.
  • Loading branch information
chicoreus committed Jun 17, 2023
1 parent 8721987 commit 07f5a33
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 17 deletions.
20 changes: 10 additions & 10 deletions src/main/java/org/filteredpush/qc/date/DwCEventDQ.java
Original file line number Diff line number Diff line change
Expand Up @@ -2151,18 +2151,18 @@ public static DQResponse<AmendmentValue> amendmentEventFromEventdate(
* #84 Validation SingleRecord Conformance: year outofrange
*
* Provides: VALIDATION_YEAR_INRANGE
* Version: 2022-03-22
* Version: 2022-06-17
*
* Parameters: bdq:earliestDate="1500"; bdq:latestDate=current year
* Parameters: bdq:earliestDate="1582"; bdq:latestDate=current year
*
* @param year the provided dwc:year to evaluate
* @param bdq:earliestDate integer for lower bound of range of in range years, if null 1600 will be used.
* @param bdq:earliestDate integer for lower bound of range of in range years, if null 1582 will be used.
* @param bdq:latestDate integer for upper bound of range of in range years, if null current year will be used.
* @return DQResponse the response of type ComplianceValue to return
*/
@Validation(label="VALIDATION_YEAR_INRANGE", description="Is the value of dwc:year within the Parameter range?")
@Provides("ad0c8855-de69-4843-a80c-a5387d20fbc8")
@ProvidesVersion("https://rs.tdwg.org/bdq/terms/ad0c8855-de69-4843-a80c-a5387d20fbc8/2022-03-22")
@ProvidesVersion("https://rs.tdwg.org/bdq/terms/ad0c8855-de69-4843-a80c-a5387d20fbc8/2022-06-17")
public static DQResponse<ComplianceValue> validationYearInrange(
@ActedUpon(value = "dwc:year") String year,
@Parameter(name = "bdq:earliestDate") Integer lowerBound,
Expand All @@ -2171,16 +2171,16 @@ public static DQResponse<ComplianceValue> validationYearInrange(
DQResponse<ComplianceValue> result = new DQResponse<ComplianceValue>();

// Specification
// INTERNAL_PREREQUISITES_NOT_MET if dwc:year is not present,
// or is EMPTY or cannot be interpreted as an integer; COMPLIANT
// if the value of dwc:year is within the Parameter range;
// otherwise NOT_COMPLIANT
// INTERNAL_PREREQUISITES_NOT_MET if dwc:year is not present,
// or is EMPTY or cannot be interpreted as an integer; COMPLIANT
// if the value of dwc:year is within the Parameter range;
// otherwise NOT_COMPLIANT

// This test is defined as parameterized.
// bdq:earliestDate="1500"; bdq:latestDate=current year
// bdq:earliestDate="1582"; bdq:latestDate=current year

if (lowerBound==null) {
lowerBound = 1500;
lowerBound = 1582;
}
if (upperBound==null) {
upperBound = LocalDateTime.now().getYear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ public static DQResponse<ComplianceValue> validationEventdateInrange(@ActedUpon(
* #84 Validation SingleRecord Conformance: year outofrange
*
* Provides: VALIDATION_YEAR_INRANGE
* Version: 2022-11-09
* Version: 2023-06-17
*
* @param year the provided dwc:year to evaluate
* @return DQResponse the response of type ComplianceValue to return
*/
@Validation(label="VALIDATION_YEAR_INRANGE", description="Is the value of dwc:year within the Parameter range?")
@Provides("ad0c8855-de69-4843-a80c-a5387d20fbc8")
@ProvidesVersion("https://rs.tdwg.org/bdq/terms/ad0c8855-de69-4843-a80c-a5387d20fbc8/2022-11-09")
@ProvidesVersion("https://rs.tdwg.org/bdq/terms/ad0c8855-de69-4843-a80c-a5387d20fbc8/2023-06-17")
public static DQResponse<ComplianceValue> validationYearInrange(@ActedUpon("dwc:year") String year) {
DQResponse<ComplianceValue> result = new DQResponse<ComplianceValue>();

Expand All @@ -108,11 +108,11 @@ public static DQResponse<ComplianceValue> validationYearInrange(@ActedUpon("dwc:
// otherwise NOT_COMPLIANT

// This test is defined as parameterized.
// bdq:earliestDate="1500"; bdq:latestDate=current year
// bdq:earliestDate="1582"; bdq:latestDate=current year

Integer upperBound = LocalDateTime.now().getYear();

return validationYearInrange(year, 1500, upperBound);
return validationYearInrange(year, 1582, upperBound);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ public void testValidationEventInconsistent() {
* Test method for {@link org.filteredpush.qc.date.DwCEventDQs#validationYearInrange(java.lang.String)}.
*/
@Test
public void testValidationYearOutofrange() {
public void testValidationYearInrange() {

// Specification
// INTERNAL_PREREQUISITES_NOT_MET if dwc:year is not present,
Expand All @@ -509,7 +509,7 @@ public void testValidationYearOutofrange() {
//otherwise NOT_COMPLIANT

// This test is defined as parameterized.
// bdq:earliestDate="1600"; bdq:latestDate=current year
// bdq:earliestDate="1582"; bdq:latestDate=current year

String year = "";
DQResponse<ComplianceValue> result = DwCEventDQ.validationYearInrange(year, null, null);
Expand All @@ -528,19 +528,38 @@ public void testValidationYearOutofrange() {
logger.debug(result.getComment());
assertEquals(ResultState.RUN_HAS_RESULT.getLabel(), result.getResultState().getLabel());
assertEquals(ComplianceValue.COMPLIANT.getLabel(), result.getValue().getLabel());
assertNotNull(result.getComment());

year = "1480";
result = DwCEventDQ.validationYearInrange(year, null, null);
logger.debug(result.getComment());
assertEquals(ResultState.RUN_HAS_RESULT.getLabel(), result.getResultState().getLabel());
assertEquals(ComplianceValue.NOT_COMPLIANT.getLabel(), result.getValue().getLabel());

year = "1580";
year = "1583";
result = DwCEventDQ.validationYearInrange(year, null, null);
logger.debug(result.getComment());
assertEquals(ResultState.RUN_HAS_RESULT.getLabel(), result.getResultState().getLabel());
assertEquals(ComplianceValue.COMPLIANT.getLabel(), result.getValue().getLabel());

year = "1582";
result = DwCEventDQ.validationYearInrange(year, null, null);
logger.debug(result.getComment());
assertEquals(ResultState.RUN_HAS_RESULT.getLabel(), result.getResultState().getLabel());
assertEquals(ComplianceValue.COMPLIANT.getLabel(), result.getValue().getLabel());

year = "1581";
result = DwCEventDQ.validationYearInrange(year, null, null);
logger.debug(result.getComment());
assertEquals(ResultState.RUN_HAS_RESULT.getLabel(), result.getResultState().getLabel());
assertEquals(ComplianceValue.NOT_COMPLIANT.getLabel(), result.getValue().getLabel());

year = "1580";
result = DwCEventDQ.validationYearInrange(year, null, null);
logger.debug(result.getComment());
assertEquals(ResultState.RUN_HAS_RESULT.getLabel(), result.getResultState().getLabel());
assertEquals(ComplianceValue.NOT_COMPLIANT.getLabel(), result.getValue().getLabel());

year = "2000";
result = DwCEventDQ.validationYearInrange(year, 1900, 1999);
logger.debug(result.getComment());
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/org/filteredpush/qc/date/DwcEventDQTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1966,6 +1966,16 @@ public void testYearInRange() {
assertEquals(ResultState.RUN_HAS_RESULT, result.getResultState());
assertEquals(ComplianceValue.COMPLIANT, result.getValue());

year = "1582";
result = DwCEventDQ.validationYearInrange(year, null, null);
assertEquals(ResultState.RUN_HAS_RESULT, result.getResultState());
assertEquals(ComplianceValue.COMPLIANT, result.getValue());

year = "1581";
result = DwCEventDQ.validationYearInrange(year, null, null);
assertEquals(ResultState.RUN_HAS_RESULT, result.getResultState());
assertEquals(ComplianceValue.NOT_COMPLIANT.getLabel(), result.getValue().getLabel());

year = "1499";
result = DwCEventDQ.validationYearInrange(year, null, null);
assertEquals(ResultState.RUN_HAS_RESULT, result.getResultState());
Expand Down

0 comments on commit 07f5a33

Please sign in to comment.