Skip to content

Commit

Permalink
Work in progress checking implementation of DwCGeoRefDQ methods again…
Browse files Browse the repository at this point in the history
…st current (2023-06-12) test descriptions. Addressed implementation of tdwg/bdq#108 VALIDATION_MINELEVATION_LESSTHAN_MAXELEVATION   Adding ProvidesVersion annotations.   Removing now empty file stubs for checked methods.  Adding some unit tests.
  • Loading branch information
chicoreus committed Jun 16, 2023
1 parent 944d4be commit 2e83ea7
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1311,20 +1311,20 @@ public static DQResponse<ComplianceValue> validationMindepthInrange(
return result;
}


//TODO: Implement specification

/**
* Is the value of dwc:minimumElevationInMeters a number less than or equal to the value of dwc:maximumElevationInMeters?
*
* Provides: #108 VALIDATION_MINELEVATION_LESSTHAN_MAXELEVATION
* Version: 2022-03-22
*
* @param minimumElevationInMeters the provided dwc:minimumElevationInMeters to evaluate
* @param maximumElevationInMeters the provided dwc:maximumElevationInMeters to evaluate
* @return DQResponse the response of type ComplianceValue to return
*/
@Validation(label="VALIDATION_MINELEVATION_LESSTHAN_MAXELEVATION", description="Is the value of dwc:minimumElevationInMeters a number less than or equal to the value of dwc:maximumElevationInMeters?")
@Provides("d708526b-6561-438e-aa1a-82cd80b06396")
@ProvidesVersion("https://rs.tdwg.org/bdq/terms/d708526b-6561-438e-aa1a-82cd80b06396/2022-03-22")
@Specification("INTERNAL_PREREQUISITES_NOT_MET if dwc:maximumlevationInMeters or dwc:minimumElevationInMeters is EMPTY, or if either is not a number; COMPLIANT if the value of dwc:minimumElevationInMeters is a number less than or equal to the value of the number dwc:maximumElevationInMeters, otherwise NOT_COMPLIANT ")
public static DQResponse<ComplianceValue> validationMinelevationLessthanMaxelevation(
@ActedUpon("dwc:minimumElevationInMeters") String minimumElevationInMeters,
@ActedUpon("dwc:maximumElevationInMeters") String maximumElevationInMeters) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -739,33 +739,6 @@ public DQResponse<ComplianceValue> validationMindepthInrange(@ActedUpon("dwc:min
return result;
}

/**
* Is the value of dwc:minimumElevationInMeters a number less than or equal to the value of dwc:maximumElevationInMeters?
*
* Provides: VALIDATION_MINELEVATION_LESSTHAN_MAXELEVATION
* Version: 2022-03-22
*
* @param minimumElevationInMeters the provided dwc:minimumElevationInMeters to evaluate
* @param maximumElevationInMeters the provided dwc:maximumElevationInMeters to evaluate
* @return DQResponse the response of type ComplianceValue to return
*/
@Validation(label="VALIDATION_MINELEVATION_LESSTHAN_MAXELEVATION", description="Is the value of dwc:minimumElevationInMeters a number less than or equal to the value of dwc:maximumElevationInMeters?")
@Provides("d708526b-6561-438e-aa1a-82cd80b06396")
@ProvidesVersion("https://rs.tdwg.org/bdq/terms/d708526b-6561-438e-aa1a-82cd80b06396/2022-03-22")
@Specification("INTERNAL_PREREQUISITES_NOT_MET if dwc:maximumlevationInMeters or dwc:minimumElevationInMeters is EMPTY, or if either is not a number; COMPLIANT if the value of dwc:minimumElevationInMeters is a number less than or equal to the value of the number dwc:maximumElevationInMeters, otherwise NOT_COMPLIANT ")
public DQResponse<ComplianceValue> validationMinelevationLessthanMaxelevation(@ActedUpon("dwc:minimumElevationInMeters") String minimumElevationInMeters, @ActedUpon("dwc:maximumElevationInMeters") String maximumElevationInMeters) {
DQResponse<ComplianceValue> result = new DQResponse<ComplianceValue>();

//TODO: Implement specification
// INTERNAL_PREREQUISITES_NOT_MET if dwc:maximumlevationInMeters
// or dwc:minimumElevationInMeters is EMPTY, or if either is
// not a number; COMPLIANT if the value of dwc:minimumElevationInMeters
// is a number less than or equal to the value of the number
// dwc:maximumElevationInMeters, otherwise NOT_COMPLIANT

return result;
}

/**
* Is the value of dwc:coordinateUncertaintyInMeters a number between 1 and 20,037,509?
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,17 +244,6 @@ public void testValidationMindepthInrange() {
@Test
public void testValidationMinelevationGreaterthanMaxelevation() {

// Specification
// INTERNAL_PREREQUISITES_NOT_MET if dwc:maximumlevationInMeters
// or dwc:minimumElevationInMeters is EMPTY; COMPLIANT if the
// value of dwc:minimumElevationInMeters is a number less than
// or equal to the value of the number dwc:maximumElevationInMeters,
//otherwise NOT_COMPLIANT

// TODO: Implementation follows change proposed in issue as of 2022Feb19, internal prerequsites not met if
// either of the provided values is not a number rather than not compliant, consistent with other
// elevation/depth validations.

DQResponse<ComplianceValue> result = DwCGeoRefDQ.validationMinelevationLessthanMaxelevation(null,null);
logger.debug(result.getComment());
assertEquals(ResultState.INTERNAL_PREREQUISITES_NOT_MET, result.getResultState());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -807,5 +807,83 @@ public void testValidationMaxdepthOutofrange() {

}

/**
* Test method for {@link org.filteredpush.qc.georeference.DwCGeoRefDQ#validationMinelevationLessthanMaxelevation(java.lang.String, java.lang.String)}.
*/
@Test
public void testValidationMinelevationGreaterthanMaxelevation() {

DQResponse<ComplianceValue> result = DwCGeoRefDQ.validationMinelevationLessthanMaxelevation(null,null);
logger.debug(result.getComment());
assertEquals(ResultState.INTERNAL_PREREQUISITES_NOT_MET, result.getResultState());
assertNull(result.getValue());

result = DwCGeoRefDQ.validationMinelevationLessthanMaxelevation("a","10");
logger.debug(result.getComment());
assertEquals(ResultState.INTERNAL_PREREQUISITES_NOT_MET, result.getResultState());
assertNull(result.getValue());

result = DwCGeoRefDQ.validationMinelevationLessthanMaxelevation("10","XX");
logger.debug(result.getComment());
assertEquals(ResultState.INTERNAL_PREREQUISITES_NOT_MET, result.getResultState());
assertNull(result.getValue());

result = DwCGeoRefDQ.validationMinelevationLessthanMaxelevation(null,null);
logger.debug(result.getComment());
assertEquals(ResultState.INTERNAL_PREREQUISITES_NOT_MET, result.getResultState());
assertNull(result.getValue());

result = DwCGeoRefDQ.validationMinelevationLessthanMaxelevation("-1","10");
logger.debug(result.getComment());
assertEquals(ResultState.RUN_HAS_RESULT, result.getResultState());
assertEquals(ComplianceValue.COMPLIANT, result.getValue());

result = DwCGeoRefDQ.validationMinelevationLessthanMaxelevation("10","100");
logger.debug(result.getComment());
assertEquals(ResultState.RUN_HAS_RESULT, result.getResultState());
assertEquals(ComplianceValue.COMPLIANT, result.getValue());

result = DwCGeoRefDQ.validationMinelevationLessthanMaxelevation("100","10");
logger.debug(result.getComment());
assertEquals(ResultState.RUN_HAS_RESULT, result.getResultState());
assertEquals(ComplianceValue.NOT_COMPLIANT, result.getValue());

String minElevation = Integer.toString(Integer.MIN_VALUE);
String maxElevation = Integer.toString(Integer.MAX_VALUE);
result = DwCGeoRefDQ.validationMinelevationLessthanMaxelevation(minElevation,maxElevation);
logger.debug(result.getComment());
assertEquals(ResultState.RUN_HAS_RESULT, result.getResultState());
assertEquals(ComplianceValue.COMPLIANT, result.getValue());

minElevation = Integer.toString(Integer.MAX_VALUE);
maxElevation = Integer.toString(Integer.MIN_VALUE);
result = DwCGeoRefDQ.validationMinelevationLessthanMaxelevation(minElevation,maxElevation);
logger.debug(result.getComment());
assertEquals(ResultState.RUN_HAS_RESULT, result.getResultState());
assertEquals(ComplianceValue.NOT_COMPLIANT, result.getValue());

minElevation = "10m";
maxElevation = "15m";
result = DwCGeoRefDQ.validationMinelevationLessthanMaxelevation(minElevation,maxElevation);
logger.debug(result.getComment());
assertEquals(ResultState.INTERNAL_PREREQUISITES_NOT_MET, result.getResultState());
assertNull(result.getValue());

minElevation = " 10 ";
maxElevation = " 15 ";
result = DwCGeoRefDQ.validationMinelevationLessthanMaxelevation(minElevation,maxElevation);
logger.debug(result.getComment());
assertEquals(ResultState.RUN_HAS_RESULT, result.getResultState());
assertEquals(ComplianceValue.COMPLIANT, result.getValue());
assertNotNull(result.getComment());

minElevation = " 15 ";
maxElevation = " 10 ";
result = DwCGeoRefDQ.validationMinelevationLessthanMaxelevation(minElevation,maxElevation);
logger.debug(result.getComment());
assertEquals(ResultState.RUN_HAS_RESULT, result.getResultState());
assertEquals(ComplianceValue.NOT_COMPLIANT, result.getValue());
assertNotNull(result.getComment());
}

}

0 comments on commit 2e83ea7

Please sign in to comment.