use of org.openforis.collect.io.data.CSVDataImportJob.DataParsingError in project collect by openforis.
the class CSVDataImportJobIntegrationTest method missingRequiredColumnsTest.
@Test
public void missingRequiredColumnsTest() throws Exception {
EntityDefinition clusterDefn = survey.getSchema().getRootEntityDefinition("cluster");
EntityDefinition plotDefn = (EntityDefinition) clusterDefn.getChildDefinition("plot");
CSVDataImportJob process = importCSVFile(MISSING_REQUIRED_COLUMNS_TEST_CSV, plotDefn.getId());
assertFalse(process.isCompleted());
assertTrue(process.isFailed());
List<DataParsingError> errors = process.getParsingErrors();
assertEquals(1, errors.size());
ParsingError headerError = errors.get(0);
assertEquals(ErrorType.MISSING_REQUIRED_COLUMNS, headerError.getErrorType());
}
use of org.openforis.collect.io.data.CSVDataImportJob.DataParsingError in project collect by openforis.
the class CSVDataImportJobIntegrationTest method invalidHeaderTest.
@Test
public void invalidHeaderTest() throws Exception {
EntityDefinition clusterDefn = survey.getSchema().getRootEntityDefinition("cluster");
EntityDefinition plotDefn = (EntityDefinition) clusterDefn.getChildDefinition("plot");
CSVDataImportJob process = importCSVFile(INVALID_HEADER_TEST_CSV, plotDefn.getId());
assertFalse(process.isCompleted());
assertTrue(process.isFailed());
List<DataParsingError> errors = process.getParsingErrors();
assertEquals(1, errors.size());
ParsingError headerError = errors.get(0);
assertEquals(ErrorType.WRONG_COLUMN_NAME, headerError.getErrorType());
assertTrue(Arrays.equals(new String[] { "land_usage" }, headerError.getColumns()));
}
use of org.openforis.collect.io.data.CSVDataImportJob.DataParsingError in project collect by openforis.
the class CSVDataImportJobIntegrationTest method invalidValuesTest.
@Test
public void invalidValuesTest() 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(INVALID_VALUES_TEST_CSV, clusterDefn.getId());
assertFalse(process.isCompleted());
assertTrue(process.isFailed());
List<DataParsingError> errors = process.getParsingErrors();
assertEquals(4, errors.size());
{
ParsingError error = errors.get(0);
assertEquals(2, error.getRow());
assertEquals(ErrorType.INVALID_VALUE, error.getErrorType());
assertTrue(Arrays.equals(new String[] { "vehicle_location_srs" }, error.getColumns()));
}
{
ParsingError error = errors.get(1);
assertEquals(4, error.getRow());
assertEquals(ErrorType.INVALID_VALUE, error.getErrorType());
assertTrue(Arrays.equals(new String[] { "vehicle_location_x" }, error.getColumns()));
}
{
ParsingError error = errors.get(2);
assertEquals(4, error.getRow());
assertEquals(ErrorType.INVALID_VALUE, error.getErrorType());
assertTrue(Arrays.equals(new String[] { "plot_distance" }, error.getColumns()));
}
{
ParsingError error = errors.get(3);
assertEquals(5, error.getRow());
assertEquals(ErrorType.INVALID_VALUE, error.getErrorType());
assertTrue(Arrays.equals(new String[] { "vehicle_location_y" }, error.getColumns()));
}
}
Aggregations