Search in sources :

Example 36 with RealAttribute

use of org.openforis.idm.model.RealAttribute in project collect by openforis.

the class CustomCheckTest method testPass.

@Test
public void testPass() {
    Entity plot = EntityBuilder.addEntity(cluster, "plot");
    Entity tree = EntityBuilder.addEntity(plot, "tree");
    RealAttribute totalHeight = EntityBuilder.addValue(tree, "total_height", 16.0);
    EntityBuilder.addValue(tree, "dbh", 2.0);
    ValidationResults results = validate(totalHeight);
    assertFalse(containsCustomCheck(results.getWarnings()));
}
Also used : Entity(org.openforis.idm.model.Entity) RealAttribute(org.openforis.idm.model.RealAttribute) Test(org.junit.Test)

Example 37 with RealAttribute

use of org.openforis.idm.model.RealAttribute in project collect by openforis.

the class CustomCheckTest method testPassLtEq.

@Test
public void testPassLtEq() {
    Entity plot = EntityBuilder.addEntity(cluster, "plot");
    Entity tree = EntityBuilder.addEntity(plot, "tree");
    RealAttribute totalHeight = EntityBuilder.addValue(tree, "total_height", 16.0);
    EntityBuilder.addValue(tree, "dbh", 16.0);
    ValidationResults results = validate(totalHeight);
    assertFalse(containsCustomCheck(results.getWarnings()));
}
Also used : Entity(org.openforis.idm.model.Entity) RealAttribute(org.openforis.idm.model.RealAttribute) Test(org.junit.Test)

Example 38 with RealAttribute

use of org.openforis.idm.model.RealAttribute in project collect by openforis.

the class CustomCheckTest method testCustomMessageWithoutExpressions.

@Test
public void testCustomMessageWithoutExpressions() {
    Entity plot = EntityBuilder.addEntity(cluster, "plot");
    Entity tree = EntityBuilder.addEntity(plot, "tree");
    RealAttribute totalHeight = EntityBuilder.addValue(tree, "total_height", 2.0);
    RealAttribute dbh = EntityBuilder.addValue(tree, "dbh", 16.5);
    EntityBuilder.addValue(tree, "health", new Code("1"));
    ValidationResults results = validate(dbh);
    CustomCheck check = (CustomCheck) results.getWarnings().get(0).getValidator();
    String message = check.getMessageWithEvaluatedExpressions(totalHeight);
    Assert.assertEquals("Unusual relationship between DBH and total height.", message);
}
Also used : Entity(org.openforis.idm.model.Entity) RealAttribute(org.openforis.idm.model.RealAttribute) Code(org.openforis.idm.model.Code) Test(org.junit.Test)

Example 39 with RealAttribute

use of org.openforis.idm.model.RealAttribute in project collect by openforis.

the class CustomCheckTest method testFailLtEqWithCondition.

@Test
public void testFailLtEqWithCondition() {
    Entity plot = EntityBuilder.addEntity(cluster, "plot");
    Entity tree = EntityBuilder.addEntity(plot, "tree");
    RealAttribute totalHeight = EntityBuilder.addValue(tree, "total_height", 2.0);
    EntityBuilder.addValue(tree, "dbh", 16.5);
    EntityBuilder.addValue(tree, "health", new Code("1"));
    ValidationResults results = validate(totalHeight);
    assertTrue(containsCustomCheck(results.getWarnings()));
    CustomCheck check = (CustomCheck) results.getWarnings().get(0).getValidator();
    String message = check.getMessageWithEvaluatedExpressions(totalHeight, Locale.ENGLISH.getLanguage());
    System.out.println(message);
}
Also used : Entity(org.openforis.idm.model.Entity) RealAttribute(org.openforis.idm.model.RealAttribute) Code(org.openforis.idm.model.Code) Test(org.junit.Test)

Aggregations

RealAttribute (org.openforis.idm.model.RealAttribute)39 Test (org.junit.Test)33 Entity (org.openforis.idm.model.Entity)25 AbstractTest (org.openforis.idm.AbstractTest)14 CollectRecord (org.openforis.collect.model.CollectRecord)9 Code (org.openforis.idm.model.Code)9 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)8 CollectIntegrationTest (org.openforis.collect.CollectIntegrationTest)6 Node (org.openforis.idm.model.Node)6 RealValue (org.openforis.idm.model.RealValue)6 ParsingError (org.openforis.collect.io.metadata.parsing.ParsingError)5 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)5 Coordinate (org.openforis.idm.model.Coordinate)4 Date (org.openforis.idm.model.Date)4 Time (org.openforis.idm.model.Time)4 Unit (org.openforis.idm.metamodel.Unit)2 IntegerAttribute (org.openforis.idm.model.IntegerAttribute)2 TextAttribute (org.openforis.idm.model.TextAttribute)2 GregorianCalendar (java.util.GregorianCalendar)1 Ignore (org.junit.Ignore)1