use of org.openforis.idm.model.Entity in project collect by openforis.
the class ComparisonCheckTest method testTimeGtFailOnEq.
@Test
public void testTimeGtFailOnEq() {
Entity timeStudy = EntityBuilder.addEntity(cluster, "time_study");
EntityBuilder.addValue(timeStudy, "start_time", new Time(10, 00));
TimeAttribute endTime = EntityBuilder.addValue(timeStudy, "end_time", new Time(10, 00));
ValidationResults results = validate(endTime);
assertTrue(containsComparisonCheck(results.getErrors()));
}
use of org.openforis.idm.model.Entity in project collect by openforis.
the class ComparisonCheckTest method testDateNotGreaterThanCurrentDate.
@Test
public void testDateNotGreaterThanCurrentDate() {
Entity timeStudy = EntityBuilder.addEntity(cluster, "time_study");
DateAttribute date = EntityBuilder.addValue(timeStudy, "date", new Date(2015, 9, 20));
ValidationResults results = validate(date);
assertFalse(containsComparisonCheck(results.getErrors()));
}
use of org.openforis.idm.model.Entity in project collect by openforis.
the class ComparisonCheckTest method testTimeGtPassOnGt.
@Test
public void testTimeGtPassOnGt() {
Entity timeStudy = EntityBuilder.addEntity(cluster, "time_study");
EntityBuilder.addValue(timeStudy, "start_time", new Time(10, 00));
TimeAttribute endTime = EntityBuilder.addValue(timeStudy, "end_time", new Time(10, 01));
ValidationResults results = validate(endTime);
assertFalse(containsComparisonCheck(results.getErrors()));
}
use of org.openforis.idm.model.Entity in project collect by openforis.
the class CustomCheckTest method testCustomMessageWithExpressions.
@Test
public void testCustomMessageWithExpressions() {
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);
CustomCheck check = (CustomCheck) results.getWarnings().get(0).getValidator();
String message = check.getMessageWithEvaluatedExpressions(totalHeight, Locale.ENGLISH.getLanguage());
Assert.assertEquals("Unusual relationship between dbh (16.5) and total height (2.0).", message);
}
use of org.openforis.idm.model.Entity in project collect by openforis.
the class PathElement method evaluate.
@Override
public List<Node<?>> evaluate(Record context) {
Entity root = context.getRootEntity();
if (root.getName().equals(name) && (index == null || index == 1)) {
List<Node<?>> nodes = new ArrayList<Node<?>>(1);
nodes.add(root);
return Collections.unmodifiableList(nodes);
} else {
return Collections.emptyList();
}
}
Aggregations