use of org.openforis.idm.model.Entity in project collect by openforis.
the class ModelPathExpressionTest method testThis.
@Test
public void testThis() throws InvalidExpressionException {
Entity plot = EntityBuilder.addEntity(cluster, "plot");
CodeAttribute plotNum = EntityBuilder.addValue(plot, "no", new Code("1"));
List<Node<?>> plotNums = iterateExpression("$this", plot, plotNum);
Assert.assertEquals(1, plotNums.size());
}
use of org.openforis.idm.model.Entity in project collect by openforis.
the class ModelPathExpressionTest method testAttributeParent.
@Test
public void testAttributeParent() throws InvalidExpressionException {
Entity plot = EntityBuilder.addEntity(cluster, "plot");
RealAttribute canopyCover = EntityBuilder.addValue(plot, "canopy_cover", 12.56);
List<Node<?>> plots = iterateExpression("parent()", canopyCover);
Assert.assertEquals(1, plots.size());
}
use of org.openforis.idm.model.Entity in project collect by openforis.
the class RelevanceExpressionTest method testBooleanValue3.
@Test
@Ignore
public void testBooleanValue3() {
Entity plot = EntityBuilder.addEntity(cluster, "plot");
EntityBuilder.addValue(plot, "accessibility", new Code("1"));
EntityBuilder.addValue(plot, "permanent", true);
EntityBuilder.addEntity(plot, "soil");
assertFalse(plot.isRelevant("soil"));
}
use of org.openforis.idm.model.Entity in project collect by openforis.
the class RequiredExpressionTest method testSubPlotRequired.
@Test
public void testSubPlotRequired() throws InvalidExpressionException {
Entity plot = EntityBuilder.addEntity(cluster, "plot");
EntityBuilder.addValue(plot, "share", 12.4);
String expr = "share < 100";
boolean b = evaluateExpression(expr, plot);
Assert.assertTrue(b);
}
use of org.openforis.idm.model.Entity in project collect by openforis.
the class PathTest method testSingleAttributeWithIndex.
@Test
public void testSingleAttributeWithIndex() throws InvalidPathException {
Entity cluster = getRootEntity();
Entity plot = EntityBuilder.addEntity(cluster, "plot");
Entity tree1 = EntityBuilder.addEntity(plot, "tree");
EntityBuilder.addValue(tree1, "dbh", 12.2);
Entity tree2 = EntityBuilder.addEntity(plot, "tree");
RealAttribute dbh2 = EntityBuilder.addValue(tree2, "dbh", 15.7);
Path path = Path.parse("tree[2]/dbh[1]");
// Node
List<Node<?>> res = path.evaluate(plot);
Assert.assertEquals(1, res.size());
Assert.assertEquals(dbh2, res.get(0));
// Defn
NodeDefinition def = path.evaluate(plot.getDefinition());
Assert.assertEquals(dbh2.getDefinition(), def);
}
Aggregations