Search in sources :

Example 1 with TestSurveyContext

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

the class SurveyBuilder method survey.

public static Survey survey(NodeDefinitionBuilder... builders) {
    String rootEntityName = "root";
    Survey survey = new TestSurveyContext().createSurvey();
    EntityDefinitionBuilder entityBuilder = new EntityDefinitionBuilder(rootEntityName, builders);
    EntityDefinition rootEntityDef = (EntityDefinition) entityBuilder.buildInternal(survey);
    Schema schema = survey.getSchema();
    if (schema.getRootEntityDefinition(rootEntityName) != null) {
        schema.removeRootEntityDefinition(rootEntityName);
    }
    schema.addRootEntityDefinition(rootEntityDef);
    survey.refreshSurveyDependencies();
    return survey;
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) Survey(org.openforis.idm.metamodel.Survey) EntityDefinitionBuilder(org.openforis.idm.testfixture.NodeDefinitionBuilder.EntityDefinitionBuilder) TestSurveyContext(org.openforis.idm.model.TestSurveyContext) Schema(org.openforis.idm.metamodel.Schema)

Example 2 with TestSurveyContext

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

the class TestFixture method survey.

public static TestFixture survey(NodeDefinitionBuilder.EntityDefinitionBuilder entityDefinitionBuilder, RecordBuilder... recordBuilders) {
    SurveyContext surveyContext = new TestSurveyContext();
    Survey survey = surveyContext.createSurvey();
    EntityDefinition rootEntityDef = (EntityDefinition) entityDefinitionBuilder.buildInternal(survey);
    survey.getSchema().addRootEntityDefinition(rootEntityDef);
    survey.refreshSurveyDependencies();
    List<Record> records = new ArrayList<Record>();
    for (RecordBuilder recordBuilder : recordBuilders) {
        Record record = recordBuilder.build(survey);
        records.add(record);
    }
    return new TestFixture(survey, Collections.unmodifiableList(records));
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) Survey(org.openforis.idm.metamodel.Survey) TestSurveyContext(org.openforis.idm.model.TestSurveyContext) ArrayList(java.util.ArrayList) Record(org.openforis.idm.model.Record) SurveyContext(org.openforis.idm.metamodel.SurveyContext) TestSurveyContext(org.openforis.idm.model.TestSurveyContext)

Example 3 with TestSurveyContext

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

the class LookupFunctionTest method setup.

@Before
public void setup() {
    TestSurveyContext surveyContext = (TestSurveyContext) record.getSurveyContext();
    surveyContext.lookupProvider.coordinate = TEST_COORDINATE;
    surveyContext.lookupProvider.samplingPointData = TEST_SAMPLING_POINT_DATA;
}
Also used : TestSurveyContext(org.openforis.idm.model.TestSurveyContext) Before(org.junit.Before)

Example 4 with TestSurveyContext

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

the class AbstractTest method createTestSurvey.

protected static Survey createTestSurvey() throws IdmlParseException {
    InputStream is = AbstractTest.class.getClassLoader().getResourceAsStream("test.idm.xml");
    SurveyContext surveyContext = new TestSurveyContext();
    SurveyIdmlBinder parser = new SurveyIdmlBinder(surveyContext);
    Survey survey = parser.unmarshal(is);
    return survey;
}
Also used : Survey(org.openforis.idm.metamodel.Survey) InputStream(java.io.InputStream) TestSurveyContext(org.openforis.idm.model.TestSurveyContext) SurveyIdmlBinder(org.openforis.idm.metamodel.xml.SurveyIdmlBinder) SurveyContext(org.openforis.idm.metamodel.SurveyContext) TestSurveyContext(org.openforis.idm.model.TestSurveyContext)

Aggregations

TestSurveyContext (org.openforis.idm.model.TestSurveyContext)4 Survey (org.openforis.idm.metamodel.Survey)3 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)2 SurveyContext (org.openforis.idm.metamodel.SurveyContext)2 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 Schema (org.openforis.idm.metamodel.Schema)1 SurveyIdmlBinder (org.openforis.idm.metamodel.xml.SurveyIdmlBinder)1 Record (org.openforis.idm.model.Record)1 EntityDefinitionBuilder (org.openforis.idm.testfixture.NodeDefinitionBuilder.EntityDefinitionBuilder)1