Search in sources :

Example 46 with Code

use of org.openforis.idm.model.Code in project collect by openforis.

the class IDMFunctionsTest method testBlankWithBlankValue.

@Test
public void testBlankWithBlankValue() throws InvalidExpressionException {
    EntityBuilder.addValue(cluster, "id", new Code(""));
    assertTrue(evaluateBooleanExpression(cluster, null, "idm:blank(id)"));
}
Also used : Code(org.openforis.idm.model.Code) Test(org.junit.Test)

Example 47 with Code

use of org.openforis.idm.model.Code in project collect by openforis.

the class IDMFunctionsTest method testCountDistinctFunction.

// start of distinct-count test
@Test
public void testCountDistinctFunction() throws InvalidExpressionException {
    Entity plot1 = EntityBuilder.addEntity(cluster, "plot");
    EntityBuilder.addValue(plot1, "no", new Code("1"));
    Entity plot2 = EntityBuilder.addEntity(cluster, "plot");
    EntityBuilder.addValue(plot2, "no", new Code("2"));
    String expr = ExpressionFactory.IDM_PREFIX + ":" + "count-distinct(plot/no)";
    Object result = evaluateExpression(expr);
    Assert.assertEquals(2, result);
}
Also used : Entity(org.openforis.idm.model.Entity) Code(org.openforis.idm.model.Code) Test(org.junit.Test)

Example 48 with Code

use of org.openforis.idm.model.Code in project collect by openforis.

the class IDMFunctionsTest method testBlankValidCode.

@Test
public void testBlankValidCode() throws InvalidExpressionException {
    EntityBuilder.addValue(cluster, "id", new Code("001"));
    Assert.assertFalse(evaluateBooleanExpression(cluster, null, "idm:blank(id)"));
}
Also used : Code(org.openforis.idm.model.Code) Test(org.junit.Test)

Example 49 with Code

use of org.openforis.idm.model.Code in project collect by openforis.

the class LookupFunctionTest method testSamplingPointLookupFunction.

@Test
public void testSamplingPointLookupFunction() throws InvalidExpressionException {
    EntityBuilder.addValue(cluster, "id", new Code("205_128"));
    String expr = "idm:samplingPointData('region', id)";
    Object object = expressionEvaluator.evaluateValue(cluster, null, expr);
    Assert.assertEquals(TEST_SAMPLING_POINT_DATA, object);
}
Also used : Code(org.openforis.idm.model.Code) AbstractTest(org.openforis.idm.AbstractTest) Test(org.junit.Test)

Example 50 with Code

use of org.openforis.idm.model.Code in project collect by openforis.

the class LookupFunctionTest method testLookupFunctionWithPath.

@Test
public void testLookupFunctionWithPath() throws InvalidExpressionException {
    EntityBuilder.addValue(cluster, "id", new Code("205_128"));
    String expr = "idm:lookup('sampling_design', 'location', 'cluster', id, 'plot', '0')";
    Object object = expressionEvaluator.evaluateValue(cluster, null, expr);
    Assert.assertEquals(TEST_COORDINATE, object);
}
Also used : Code(org.openforis.idm.model.Code) AbstractTest(org.openforis.idm.AbstractTest) Test(org.junit.Test)

Aggregations

Code (org.openforis.idm.model.Code)68 Test (org.junit.Test)45 Entity (org.openforis.idm.model.Entity)35 CodeAttribute (org.openforis.idm.model.CodeAttribute)16 AbstractTest (org.openforis.idm.AbstractTest)14 Coordinate (org.openforis.idm.model.Coordinate)14 Date (org.openforis.idm.model.Date)10 Time (org.openforis.idm.model.Time)10 CollectRecord (org.openforis.collect.model.CollectRecord)9 RealAttribute (org.openforis.idm.model.RealAttribute)9 GregorianCalendar (java.util.GregorianCalendar)8 CodeAttributeDefinition (org.openforis.idm.metamodel.CodeAttributeDefinition)6 CodeList (org.openforis.idm.metamodel.CodeList)6 CollectIntegrationTest (org.openforis.collect.CollectIntegrationTest)5 CoordinateAttribute (org.openforis.idm.model.CoordinateAttribute)5 RecordUpdater (org.openforis.collect.model.RecordUpdater)4 ModelVersion (org.openforis.idm.metamodel.ModelVersion)4 ValidationResults (org.openforis.idm.metamodel.validation.ValidationResults)4 Node (org.openforis.idm.model.Node)4 User (org.openforis.collect.model.User)3