use of org.openforis.idm.metamodel.validation.ValidationResults in project collect by openforis.
the class DistanceCheckTest method testWarnMaxDistance.
@Test
public void testWarnMaxDistance() {
String coordStr = "SRID=EPSG:21035;POINT(885750 9333820)";
Coordinate coord = Coordinate.parseCoordinate(coordStr);
EntityBuilder.addValue(cluster, "id", new Code("001"));
CoordinateAttribute vehicleLocation = EntityBuilder.addValue(cluster, "vehicle_location", coord);
ValidationResults results = validate(vehicleLocation);
Assert.assertFalse(containsDistanceCheck(results.getErrors()));
Assert.assertTrue(containsDistanceCheck(results.getWarnings()));
}
use of org.openforis.idm.metamodel.validation.ValidationResults in project collect by openforis.
the class DistanceCheckTest method testErrorMaxDistance.
@Test
public void testErrorMaxDistance() {
String coordStr = "SRID=EPSG:21035;POINT(915750 9333820)";
Coordinate coord = Coordinate.parseCoordinate(coordStr);
EntityBuilder.addValue(cluster, "id", new Code("001"));
CoordinateAttribute vehicleLocation = EntityBuilder.addValue(cluster, "vehicle_location", coord);
ValidationResults results = validate(vehicleLocation);
Assert.assertTrue(containsDistanceCheck(results.getErrors()));
}
use of org.openforis.idm.metamodel.validation.ValidationResults in project collect by openforis.
the class CollectRecordIntegrationTest method testConfirmError.
@Test
public void testConfirmError() throws Exception {
CollectSurvey survey = loadSurvey();
CollectRecord record = createTestRecord(survey);
Entity cluster = record.getRootEntity();
CodeAttribute region = (CodeAttribute) cluster.getChild("region", 0);
// add wrong value
{
NodeChangeSet changeSet = recordUpdater.updateAttribute(region, new Code("ZZZ"));
assertFalse(changeSet.isEmpty());
NodeChange<?> regionChange = changeSet.getChange(region);
assertTrue(regionChange instanceof AttributeChange);
ValidationResults validationResults = ((AttributeChange) regionChange).getValidationResults();
List<ValidationResult> errors = validationResults.getErrors();
assertFalse(errors.isEmpty());
List<ValidationResult> warnings = validationResults.getWarnings();
assertTrue(warnings.isEmpty());
}
{
NodeChangeSet changeSet = recordUpdater.confirmError(region);
assertFalse(changeSet.isEmpty());
NodeChange<?> regionChange = changeSet.getChange(region);
assertTrue(regionChange instanceof AttributeChange);
ValidationResults validationResults = ((AttributeChange) regionChange).getValidationResults();
List<ValidationResult> errors = validationResults.getErrors();
assertTrue(errors.isEmpty());
List<ValidationResult> warnings = validationResults.getWarnings();
assertFalse(warnings.isEmpty());
}
}
use of org.openforis.idm.metamodel.validation.ValidationResults in project collect by openforis.
the class CollectRecordIntegrationTest method checkHasError.
private void checkHasError(CollectRecord record, int attributeId, Class<?> checkType) {
ValidationResults validationResults = record.getValidationCache().getAttributeValidationResults(attributeId);
List<ValidationResult> errors = validationResults.getErrors();
for (ValidationResult validationResult : errors) {
if (checkType.isAssignableFrom(validationResult.getValidator().getClass())) {
return;
}
}
Assert.fail("Error of class " + checkType + " not found in validation results");
}
use of org.openforis.idm.metamodel.validation.ValidationResults in project collect by openforis.
the class CollectRecordIntegrationTest method checkHasWarning.
private void checkHasWarning(CollectRecord record, int attributeId, Class<?> checkType) {
ValidationResults validationResults = record.getValidationCache().getAttributeValidationResults(attributeId);
List<ValidationResult> warnings = validationResults.getWarnings();
for (ValidationResult validationResult : warnings) {
if (checkType.isAssignableFrom(validationResult.getValidator().getClass())) {
return;
}
}
Assert.fail();
}
Aggregations