use of org.openforis.idm.model.Code in project collect by openforis.
the class CustomCheckTest method testFailLtEqWithCondition.
@Test
public void testFailLtEqWithCondition() {
Entity plot = EntityBuilder.addEntity(cluster, "plot");
Entity tree = EntityBuilder.addEntity(plot, "tree");
RealAttribute totalHeight = EntityBuilder.addValue(tree, "total_height", 2.0);
EntityBuilder.addValue(tree, "dbh", 16.5);
EntityBuilder.addValue(tree, "health", new Code("1"));
ValidationResults results = validate(totalHeight);
assertTrue(containsCustomCheck(results.getWarnings()));
CustomCheck check = (CustomCheck) results.getWarnings().get(0).getValidator();
String message = check.getMessageWithEvaluatedExpressions(totalHeight, Locale.ENGLISH.getLanguage());
System.out.println(message);
}
use of org.openforis.idm.model.Code in project collect by openforis.
the class EntityKeyValidationTest method test.
@Test
public void test() {
Entity plot1 = EntityBuilder.addEntity(cluster, "plot");
CodeAttribute plotNo1 = EntityBuilder.addValue(plot1, "no", new Code("1"));
Entity plot2 = EntityBuilder.addEntity(cluster, "plot");
CodeAttribute plotNo2 = EntityBuilder.addValue(plot2, "no", new Code("1"));
ValidationResults results1 = validate(plotNo1);
assertTrue(containsEntityKeyValidator(results1.getErrors()));
ValidationResults results2 = validate(plotNo2);
assertTrue(containsEntityKeyValidator(results2.getErrors()));
}
use of org.openforis.idm.model.Code in project collect by openforis.
the class MinCountValidatorTest method testSpecifiedRequiredSingleAttribute.
@Test
public void testSpecifiedRequiredSingleAttribute() {
updateMinCount(cluster, "region");
EntityBuilder.addValue(cluster, "region", new Code("001"));
ValidationResultFlag result = validator.validateMinCount(cluster, "region");
assertTrue(result.isOk());
// ValidationResults results = validate(cluster);
// List<ValidationResult> errors = results.getErrors();
// assertFalse(containsMinCountError(errors, "region"));
}
Aggregations