use of org.openforis.idm.model.RealAttribute in project collect by openforis.
the class CSVDataImportJobIntegrationTest method missingRecordTest.
// @Test
// TODO transactional process not working only in test spring context
public void missingRecordTest() throws Exception {
{
CollectRecord record = createTestRecord(survey, "10_111");
recordDao.insert(record);
}
{
CollectRecord record = createTestRecord(survey, "10_114");
recordDao.insert(record);
}
EntityDefinition clusterDefn = survey.getSchema().getRootEntityDefinition("cluster");
CSVDataImportJob process = importCSVFile(MISSING_RECORD_TEST_CSV, clusterDefn.getId());
assertTrue(process.isFailed());
assertEquals(1, process.getParsingErrors().size());
{
ParsingError error = process.getParsingErrors().get(0);
assertEquals(ErrorType.INVALID_VALUE, error.getErrorType());
assertEquals(4, error.getRow());
assertTrue(Arrays.equals(new String[] { "id" }, error.getColumns()));
}
// verify that the transaction is rolled back properly
{
CollectRecord reloadedRecord = loadRecord("10_111");
Entity cluster = reloadedRecord.getRootEntity();
RealAttribute plotDistance = (RealAttribute) cluster.getChild("plot_distance");
RealValue plotDistanceVal = plotDistance.getValue();
assertEquals(Double.valueOf(100d), plotDistanceVal.getValue());
assertEquals(meterUnit, plotDistanceVal.getUnit());
}
{
CollectRecord reloadedRecord = loadRecord("10_114");
Entity cluster = reloadedRecord.getRootEntity();
RealAttribute plotDistance = (RealAttribute) cluster.getChild("plot_distance");
RealValue plotDistanceVal = plotDistance.getValue();
assertEquals(Double.valueOf(100d), plotDistanceVal.getValue());
assertEquals(meterUnit, plotDistanceVal.getUnit());
}
}
use of org.openforis.idm.model.RealAttribute in project collect by openforis.
the class CheckConditionExpressionTest method testTrue.
@Test
public void testTrue() throws InvalidExpressionException {
RealAttribute plotDirection = EntityBuilder.addValue(cluster, "plot_direction", 345.45);
String expr = "$this >= 0 and $this <= 359";
boolean b = evaluateExpression(expr, plotDirection);
Assert.assertTrue(b);
}
use of org.openforis.idm.model.RealAttribute in project collect by openforis.
the class CheckExpressionTest method testDefaultWithInvalidPath.
@Ignore
@Test(expected = InvalidExpressionException.class)
public void testDefaultWithInvalidPath() throws InvalidExpressionException {
RealAttribute plotDirection = EntityBuilder.addValue(cluster, "plot_direction", 345.45);
String expr = "parent()/missing_attr >= 0 and $this <= 359";
boolean b = evaluateExpression(expr, plotDirection);
Assert.assertTrue(b);
}
use of org.openforis.idm.model.RealAttribute in project collect by openforis.
the class CheckExpressionTest method testStatic.
@Test
public void testStatic() throws InvalidExpressionException {
RealAttribute plotDirection = EntityBuilder.addValue(cluster, "plot_direction", 385.45);
String expr = "900 < 359";
boolean b = evaluateExpression(expr, plotDirection);
Assert.assertFalse(b);
}
use of org.openforis.idm.model.RealAttribute in project collect by openforis.
the class RelevanceExpressionTest method testRelevanceOnNodeExpression.
@Test
public void testRelevanceOnNodeExpression() throws InvalidExpressionException {
EntityBuilder.addValue(cluster, "plot_direction", 345.45);
RealAttribute plotDistance = EntityBuilder.addValue(cluster, "plot_distance", 12.2);
String expr = "parent()/plot_direction";
assertTrue(evaluateExpression(expr, plotDistance));
}
Aggregations