Search in sources :

Example 1 with DataParsingError

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());
}
Also used : DataParsingError(org.openforis.collect.io.data.CSVDataImportJob.DataParsingError) EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) DataParsingError(org.openforis.collect.io.data.CSVDataImportJob.DataParsingError) ParsingError(org.openforis.collect.io.metadata.parsing.ParsingError) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Example 2 with DataParsingError

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()));
}
Also used : DataParsingError(org.openforis.collect.io.data.CSVDataImportJob.DataParsingError) EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) DataParsingError(org.openforis.collect.io.data.CSVDataImportJob.DataParsingError) ParsingError(org.openforis.collect.io.metadata.parsing.ParsingError) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Example 3 with DataParsingError

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()));
    }
}
Also used : DataParsingError(org.openforis.collect.io.data.CSVDataImportJob.DataParsingError) CollectRecord(org.openforis.collect.model.CollectRecord) EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) DataParsingError(org.openforis.collect.io.data.CSVDataImportJob.DataParsingError) ParsingError(org.openforis.collect.io.metadata.parsing.ParsingError) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 CollectIntegrationTest (org.openforis.collect.CollectIntegrationTest)3 DataParsingError (org.openforis.collect.io.data.CSVDataImportJob.DataParsingError)3 ParsingError (org.openforis.collect.io.metadata.parsing.ParsingError)3 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)3 CollectRecord (org.openforis.collect.model.CollectRecord)1