use of org.openforis.idm.model.RealValue 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.RealValue in project collect by openforis.
the class ComparisonExpressionTest method testGtEqOnNumber.
@Test
public void testGtEqOnNumber() throws InvalidExpressionException {
distanceToForest.setValue(new RealValue(10.0));
distanceToForest.updateSummaryInfo();
Assert.assertTrue(evaluateExpression(household, "distance_to_forest >= 10"));
}
use of org.openforis.idm.model.RealValue in project collect by openforis.
the class ComparisonExpressionTest method testLtOnNumber.
@Test
public void testLtOnNumber() throws InvalidExpressionException {
distanceToForest.setValue(new RealValue(23.5));
distanceToForest.updateSummaryInfo();
Assert.assertFalse(evaluateExpression(household, "distance_to_forest < 10"));
}
use of org.openforis.idm.model.RealValue in project collect by openforis.
the class ComparisonExpressionTest method testEqOnNumber2.
@Test
public void testEqOnNumber2() throws InvalidExpressionException {
distanceToForest.setValue(new RealValue(8.0));
distanceToForest.updateSummaryInfo();
Assert.assertFalse(evaluateExpression(household, "distance_to_forest = 10"));
}
Aggregations