use of org.openforis.idm.model.RealAttribute in project collect by openforis.
the class CustomCheckTest method testPass.
@Test
public void testPass() {
Entity plot = EntityBuilder.addEntity(cluster, "plot");
Entity tree = EntityBuilder.addEntity(plot, "tree");
RealAttribute totalHeight = EntityBuilder.addValue(tree, "total_height", 16.0);
EntityBuilder.addValue(tree, "dbh", 2.0);
ValidationResults results = validate(totalHeight);
assertFalse(containsCustomCheck(results.getWarnings()));
}
use of org.openforis.idm.model.RealAttribute in project collect by openforis.
the class CustomCheckTest method testPassLtEq.
@Test
public void testPassLtEq() {
Entity plot = EntityBuilder.addEntity(cluster, "plot");
Entity tree = EntityBuilder.addEntity(plot, "tree");
RealAttribute totalHeight = EntityBuilder.addValue(tree, "total_height", 16.0);
EntityBuilder.addValue(tree, "dbh", 16.0);
ValidationResults results = validate(totalHeight);
assertFalse(containsCustomCheck(results.getWarnings()));
}
use of org.openforis.idm.model.RealAttribute in project collect by openforis.
the class CustomCheckTest method testCustomMessageWithoutExpressions.
@Test
public void testCustomMessageWithoutExpressions() {
Entity plot = EntityBuilder.addEntity(cluster, "plot");
Entity tree = EntityBuilder.addEntity(plot, "tree");
RealAttribute totalHeight = EntityBuilder.addValue(tree, "total_height", 2.0);
RealAttribute dbh = EntityBuilder.addValue(tree, "dbh", 16.5);
EntityBuilder.addValue(tree, "health", new Code("1"));
ValidationResults results = validate(dbh);
CustomCheck check = (CustomCheck) results.getWarnings().get(0).getValidator();
String message = check.getMessageWithEvaluatedExpressions(totalHeight);
Assert.assertEquals("Unusual relationship between DBH and total height.", message);
}
use of org.openforis.idm.model.RealAttribute 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);
}
Aggregations