use of org.openforis.idm.model.DateAttribute in project collect by openforis.
the class CSVDataImportJobIntegrationTest method validEntityPositionTest.
@Test
public void validEntityPositionTest() 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");
EntityDefinition timeStudyDefn = clusterDefn.getChildDefinition("time_study", EntityDefinition.class);
CSVDataImportJob process = importCSVFile(VALID_ENTITY_POSITION_TEST_CSV, timeStudyDefn.getId());
assertEquals(Status.COMPLETED, process.getStatus());
assertTrue(process.getParsingErrors().isEmpty());
{
CollectRecord reloadedRecord = loadRecord("10_111");
Entity cluster = reloadedRecord.getRootEntity();
{
Entity timeStudy = (Entity) cluster.getChild("time_study", 0);
DateAttribute date = (DateAttribute) timeStudy.getChild("date");
Date dateVal = date.getValue();
assertEquals(Integer.valueOf(2013), dateVal.getYear());
assertEquals(Integer.valueOf(2), dateVal.getMonth());
assertEquals(Integer.valueOf(24), dateVal.getDay());
}
{
Entity timeStudy = (Entity) cluster.getChild("time_study", 1);
DateAttribute date = (DateAttribute) timeStudy.getChild("date");
Date dateVal = date.getValue();
assertEquals(Integer.valueOf(2013), dateVal.getYear());
assertEquals(Integer.valueOf(3), dateVal.getMonth());
assertEquals(Integer.valueOf(15), dateVal.getDay());
}
}
}
use of org.openforis.idm.model.DateAttribute in project collect by openforis.
the class CSVDataImportProcessIntegrationTest method validEntityPositionTest.
@Test
public void validEntityPositionTest() 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");
EntityDefinition timeStudyDefn = clusterDefn.getChildDefinition("time_study", EntityDefinition.class);
CSVDataImportProcess process = importCSVFile(VALID_ENTITY_POSITION_TEST_CSV, timeStudyDefn.getId());
ReferenceDataImportStatus<ParsingError> status = process.getStatus();
assertTrue(status.isComplete());
assertTrue(status.getSkippedRows().isEmpty());
assertEquals(3, status.getProcessed());
{
CollectRecord reloadedRecord = loadRecord("10_111");
Entity cluster = reloadedRecord.getRootEntity();
{
Entity timeStudy = (Entity) cluster.getChild("time_study", 0);
DateAttribute date = (DateAttribute) timeStudy.getChild("date");
Date dateVal = date.getValue();
assertEquals(Integer.valueOf(2013), dateVal.getYear());
assertEquals(Integer.valueOf(2), dateVal.getMonth());
assertEquals(Integer.valueOf(24), dateVal.getDay());
}
{
Entity timeStudy = (Entity) cluster.getChild("time_study", 1);
DateAttribute date = (DateAttribute) timeStudy.getChild("date");
Date dateVal = date.getValue();
assertEquals(Integer.valueOf(2013), dateVal.getYear());
assertEquals(Integer.valueOf(3), dateVal.getMonth());
assertEquals(Integer.valueOf(15), dateVal.getDay());
}
}
}
use of org.openforis.idm.model.DateAttribute in project collect by openforis.
the class ComparisonCheckTest method testDateGreaterThanCurrentDate.
@Test
public void testDateGreaterThanCurrentDate() {
Entity timeStudy = EntityBuilder.addEntity(cluster, "time_study");
DateAttribute date = EntityBuilder.addValue(timeStudy, "date", new Date(3015, 10, 20));
ValidationResults results = validate(date);
assertTrue(containsComparisonCheck(results.getErrors()));
}
use of org.openforis.idm.model.DateAttribute in project collect by openforis.
the class ComparisonCheckTest method testDateNotGreaterThanCurrentDate.
@Test
public void testDateNotGreaterThanCurrentDate() {
Entity timeStudy = EntityBuilder.addEntity(cluster, "time_study");
DateAttribute date = EntityBuilder.addValue(timeStudy, "date", new Date(2015, 9, 20));
ValidationResults results = validate(date);
assertFalse(containsComparisonCheck(results.getErrors()));
}
use of org.openforis.idm.model.DateAttribute in project collect by openforis.
the class CSVDataImportJobIntegrationTest method singleEntityTest.
@Test
public void singleEntityTest() throws Exception {
{
CollectRecord record = createTestRecord(survey, "10_114");
recordDao.insert(record);
}
EntityDefinition clusterDefn = survey.getSchema().getRootEntityDefinition("cluster");
EntityDefinition plotDefn = (EntityDefinition) clusterDefn.getChildDefinition("plot");
CSVDataImportJob process = importCSVFile(VALID_SINGLE_ENTITY_TEST_CSV, plotDefn.getId());
assertTrue(process.isCompleted());
assertTrue(process.getParsingErrors().isEmpty());
{
CollectRecord reloadedRecord = loadRecord("10_114");
Entity reloadedCluster = reloadedRecord.getRootEntity();
{
Entity plot = reloadedCluster.findChildEntitiesByKeys("plot", "1", "A").get(0);
Entity timeStudy = (Entity) plot.getChild("time_study");
DateAttribute date = (DateAttribute) timeStudy.getChild("date");
assertEquals(new Date(2012, 2, 15), date.getValue());
}
{
Entity plot = reloadedCluster.findChildEntitiesByKeys("plot", "2", "B").get(0);
Entity timeStudy = (Entity) plot.getChild("time_study");
DateAttribute date = (DateAttribute) timeStudy.getChild("date");
assertEquals(new Date(2013, 5, 18), date.getValue());
}
}
}
Aggregations