use of org.openforis.idm.model.RealValue in project collect by openforis.
the class DataReportGeneratorIntegrationTest method testSimpleErrorReport.
@Test
public void testSimpleErrorReport() {
EntityDefinition treeDef = (EntityDefinition) survey.getSchema().getDefinitionByPath("/cluster/plot/tree");
NumberAttributeDefinition dbhDef = (NumberAttributeDefinition) survey.getSchema().getDefinitionByPath("/cluster/plot/tree/dbh");
DataQuery query = dataQuery().title("Find trees with invalid DBH").entity(treeDef).attribute(dbhDef).conditions("dbh > 20").type(invalidAttributeErrorType).severity(ErrorSeverity.ERROR).build();
dataQueryManager.save(query, adminUser);
DataQueryGroup queryGroup = new DataQueryGroup(survey);
queryGroup.setTitle("Simple query group");
queryGroup.addQuery(query);
dataQueryGroupManager.save(queryGroup, adminUser);
DataReportGeneratorJob job = jobManager.createJob(DataReportGeneratorJob.class);
job.setQueryGroup(queryGroup);
job.setRecordStep(Step.ENTRY);
job.setActiveUser(adminUser);
jobManager.start(job, false);
DataReport report = job.getReport();
DataReport reloadedReport = dataReportManager.loadById(survey, report.getId());
List<DataReportItem> items = dataReportManager.loadItems(reloadedReport, 0, 100);
assertFalse(items.isEmpty());
assertEquals(1, items.size());
DataReportItem item = items.get(0);
CollectRecord record = recordManager.load(survey, item.getRecordId());
assertEquals(Arrays.asList("10_117"), record.getRootEntityKeyValues());
assertEquals(new RealValue(30.0d, dbhDef.getDefaultUnit()), item.extractAttributeValue());
}
use of org.openforis.idm.model.RealValue in project collect by openforis.
the class ComparisonExpressionTest method testLtEqOnNumber.
@Test
public void testLtEqOnNumber() throws InvalidExpressionException {
distanceToForest.setValue(new RealValue(8.98));
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 testGtOnNumber.
@Test
public void testGtOnNumber() throws InvalidExpressionException {
distanceToForest.setValue(new RealValue(23.5));
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 testEqOnNumber.
@Test
public void testEqOnNumber() 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 CSVDataImportJobIntegrationTest method newRecordsTest.
@Test
public void newRecordsTest() throws Exception {
EntityDefinition clusterDefn = survey.getSchema().getRootEntityDefinition("cluster");
CSVDataImportJob process = importCSVFile(VALID_TEST_CSV, clusterDefn.getId(), true, true, "2.0");
assertTrue(process.isCompleted());
assertTrue(process.getParsingErrors().isEmpty());
{
CollectRecord reloadedRecord = loadRecord("10_111");
Entity cluster = reloadedRecord.getRootEntity();
RealAttribute plotDistance = (RealAttribute) cluster.getChild("plot_distance");
RealValue plotDistanceVal = plotDistance.getValue();
assertEquals(Double.valueOf(200d), 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(0.3d), plotDistanceVal.getValue());
assertEquals(kilometerUnit, plotDistanceVal.getUnit());
}
}
Aggregations