use of org.openforis.idm.model.TextAttribute in project collect by openforis.
the class CSVDataImportProcessIntegrationTest method validTest.
@Test
public void validTest() throws Exception {
{
CollectRecord record = createTestRecord(survey, "10_111");
recordDao.insert(record);
assertEquals(Integer.valueOf(0), record.getErrors());
}
{
CollectRecord record = createTestRecord(survey, "10_114");
recordDao.insert(record);
}
EntityDefinition clusterDefn = survey.getSchema().getRootEntityDefinition("cluster");
CSVDataImportProcess process = importCSVFile(VALID_TEST_CSV, clusterDefn.getId());
ReferenceDataImportStatus<ParsingError> status = process.getStatus();
assertTrue(status.isComplete());
assertTrue(status.getSkippedRows().isEmpty());
assertEquals(3, status.getProcessed());
{
CollectRecord reloadedRecord = loadRecord("10_111");
assertEquals(Integer.valueOf(1), reloadedRecord.getErrors());
Entity cluster = reloadedRecord.getRootEntity();
RealAttribute plotDirection = (RealAttribute) cluster.getChild("plot_direction");
RealValue plotDirectionVal = plotDirection.getValue();
assertEquals(Double.valueOf(50d), plotDirectionVal.getValue());
RealAttribute plotDistance = (RealAttribute) cluster.getChild("plot_distance");
RealValue plotDistanceVal = plotDistance.getValue();
assertEquals(Double.valueOf(200d), plotDistanceVal.getValue());
assertEquals(meterUnit, plotDistanceVal.getUnit());
TextAttribute gpsModel = (TextAttribute) cluster.getChild("gps_model");
assertEquals("GPS MAP 62S", gpsModel.getValue().getValue());
assertEquals(2, cluster.getCount("map_sheet"));
{
TextAttribute mapSheet = (TextAttribute) cluster.getChild("map_sheet", 0);
assertEquals("new map sheet 1", mapSheet.getValue().getValue());
}
{
TextAttribute mapSheet = (TextAttribute) cluster.getChild("map_sheet", 1);
assertEquals("new map sheet 2", mapSheet.getValue().getValue());
}
}
{
CollectRecord reloadedRecord = loadRecord("10_114");
Entity cluster = reloadedRecord.getRootEntity();
RealAttribute plotDirection = (RealAttribute) cluster.getChild("plot_direction");
RealValue plotDirectionVal = plotDirection.getValue();
assertEquals(Double.valueOf(40d), plotDirectionVal.getValue());
RealAttribute plotDistance = (RealAttribute) cluster.getChild("plot_distance");
RealValue plotDistanceVal = plotDistance.getValue();
assertEquals(Double.valueOf(0.3d), plotDistanceVal.getValue());
assertEquals(kilometerUnit, plotDistanceVal.getUnit());
TextAttribute gpsModel = (TextAttribute) cluster.getChild("gps_model");
assertEquals("GPS MAP 62S", gpsModel.getValue().getValue());
}
}
use of org.openforis.idm.model.TextAttribute in project collect by openforis.
the class PatternCheckTest method testValidPattern.
// household id: (X-)?[1-9][0-9]*
@Test
public void testValidPattern() {
TextAttribute id = EntityBuilder.addValue(household, "id", "X-1");
ValidationResults results = validate(id);
assertFalse(containsPatternCheck(results.getErrors()));
}
use of org.openforis.idm.model.TextAttribute in project collect by openforis.
the class UniquenessCheckTest method testNotUniqueMapSheet2.
@Test
public void testNotUniqueMapSheet2() {
TextAttribute mapSheet1 = EntityBuilder.addValue(cluster, MAP_SHEET, "TomTom1");
EntityBuilder.addValue(cluster, MAP_SHEET, "TomTom1");
ValidationResults results = validate(mapSheet1);
Assert.assertTrue(containsUniquenessError(results.getErrors(), MAP_SHEET));
}
use of org.openforis.idm.model.TextAttribute in project collect by openforis.
the class UniquenessCheckTest method testUniqueMapSheet2.
@Test
public void testUniqueMapSheet2() {
TextAttribute mapSheet1 = EntityBuilder.addValue(cluster, MAP_SHEET, "TomTom1");
EntityBuilder.addValue(cluster, MAP_SHEET, "TomTom2");
EntityBuilder.addValue(cluster, MAP_SHEET, "TomTom2");
ValidationResults results = validate(mapSheet1);
Assert.assertFalse(containsUniquenessError(results.getErrors(), MAP_SHEET));
}
use of org.openforis.idm.model.TextAttribute in project collect by openforis.
the class UniquenessCheckTest method testUniqueMapSheet.
@Test
public void testUniqueMapSheet() {
TextAttribute mapSheet1 = EntityBuilder.addValue(cluster, MAP_SHEET, "TomTom1");
EntityBuilder.addValue(cluster, MAP_SHEET, "TomTom2");
ValidationResults results = validate(mapSheet1);
Assert.assertFalse(containsUniquenessError(results.getErrors(), MAP_SHEET));
}
Aggregations