use of org.openforis.idm.model.IntegerAttribute in project collect by openforis.
the class CSVDataImportProcessIntegrationTest method createMissingParentEntityTest.
@Test
public void createMissingParentEntityTest() 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 plotDefn = (EntityDefinition) clusterDefn.getChildDefinition("plot");
EntityDefinition treeDefn = (EntityDefinition) plotDefn.getChildDefinition("tree");
CSVDataImportProcess process = importCSVFile(MISSING_PARENT_ENTITY_TEST_CSV, treeDefn.getId(), true, false, null, true);
ReferenceDataImportStatus<ParsingError> status = process.getStatus();
assertTrue(status.isComplete());
assertEquals(0, status.getRowsInError().size());
assertEquals(4, status.getProcessed());
{
CollectRecord reloadedRecord = loadRecord("10_111");
Entity cluster = reloadedRecord.getRootEntity();
Entity plot = (Entity) cluster.getChild("plot", 0);
assertEquals(3, plot.getCount("tree"));
Entity tree = (Entity) plot.getChild("tree", 2);
IntegerAttribute treeNo = (IntegerAttribute) tree.getChild("tree_no");
assertEquals(Integer.valueOf(2), treeNo.getValue().getValue());
IntegerAttribute stemNo = (IntegerAttribute) tree.getChild("stem_no");
assertEquals(Integer.valueOf(2), stemNo.getValue().getValue());
RealAttribute dbh = (RealAttribute) tree.getChild("dbh");
assertEquals(Double.valueOf(200), dbh.getValue().getValue());
}
}
use of org.openforis.idm.model.IntegerAttribute in project collect by openforis.
the class CSVDataImportJobIntegrationTest method createMissingParentEntityTest.
@Test
public void createMissingParentEntityTest() 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 plotDefn = (EntityDefinition) clusterDefn.getChildDefinition("plot");
EntityDefinition treeDefn = (EntityDefinition) plotDefn.getChildDefinition("tree");
CSVDataImportJob process = importCSVFile(MISSING_PARENT_ENTITY_TEST_CSV, treeDefn.getId(), true, false, null, true);
assertTrue(process.isCompleted());
assertTrue(process.getParsingErrors().isEmpty());
{
CollectRecord reloadedRecord = loadRecord("10_111");
Entity cluster = reloadedRecord.getRootEntity();
Entity plot = (Entity) cluster.getChild("plot", 0);
assertEquals(3, plot.getCount("tree"));
Entity tree = (Entity) plot.getChild("tree", 2);
IntegerAttribute treeNo = (IntegerAttribute) tree.getChild("tree_no");
assertEquals(Integer.valueOf(2), treeNo.getValue().getValue());
IntegerAttribute stemNo = (IntegerAttribute) tree.getChild("stem_no");
assertEquals(Integer.valueOf(2), stemNo.getValue().getValue());
RealAttribute dbh = (RealAttribute) tree.getChild("dbh");
assertEquals(Double.valueOf(200), dbh.getValue().getValue());
}
}
use of org.openforis.idm.model.IntegerAttribute in project collect by openforis.
the class ComparisonCheckTest method testGtePassOnEq.
@Test
public void testGtePassOnEq() {
IntegerAttribute crewNo = EntityBuilder.addValue(cluster, "crew_no", 1);
ValidationResults results = validate(crewNo);
assertFalse(containsComparisonCheck(results.getErrors()));
}
use of org.openforis.idm.model.IntegerAttribute in project collect by openforis.
the class ComparisonCheckTest method testGtePassOnGt.
@Test
public void testGtePassOnGt() {
IntegerAttribute crewNo = EntityBuilder.addValue(cluster, "crew_no", 2);
ValidationResults results = validate(crewNo);
assertFalse(containsComparisonCheck(results.getErrors()));
}
use of org.openforis.idm.model.IntegerAttribute in project collect by openforis.
the class ComparisonCheckTest method testGteFailOnLt.
@Test
public void testGteFailOnLt() {
IntegerAttribute crewNo = EntityBuilder.addValue(cluster, "crew_no", 0);
ValidationResults results = validate(crewNo);
assertTrue(containsComparisonCheck(results.getErrors()));
}
Aggregations