Search in sources :

Example 1 with IntegerAttribute

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

Example 2 with IntegerAttribute

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());
    }
}
Also used : CollectRecord(org.openforis.collect.model.CollectRecord) EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) Entity(org.openforis.idm.model.Entity) RealAttribute(org.openforis.idm.model.RealAttribute) IntegerAttribute(org.openforis.idm.model.IntegerAttribute) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Example 3 with IntegerAttribute

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()));
}
Also used : IntegerAttribute(org.openforis.idm.model.IntegerAttribute) Test(org.junit.Test)

Example 4 with IntegerAttribute

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()));
}
Also used : IntegerAttribute(org.openforis.idm.model.IntegerAttribute) Test(org.junit.Test)

Example 5 with IntegerAttribute

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()));
}
Also used : IntegerAttribute(org.openforis.idm.model.IntegerAttribute) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 IntegerAttribute (org.openforis.idm.model.IntegerAttribute)5 CollectIntegrationTest (org.openforis.collect.CollectIntegrationTest)2 CollectRecord (org.openforis.collect.model.CollectRecord)2 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)2 Entity (org.openforis.idm.model.Entity)2 RealAttribute (org.openforis.idm.model.RealAttribute)2 ParsingError (org.openforis.collect.io.metadata.parsing.ParsingError)1