Search in sources :

Example 1 with RecordGenerator

use of org.activityinfo.store.testing.RecordGenerator in project activityinfo by bedatadriven.

the class SurveyTest method updateAndQuery.

@Test
public void updateAndQuery() {
    // Post a number of records
    RecordGenerator generator = survey.getGenerator();
    int numRows = 20;
    for (int i = 0; i < numRows; i++) {
        client.createRecord(generator.get());
    }
    // Now query a few records
    QueryModel queryModel = new QueryModel(survey.getFormId());
    queryModel.selectField(survey.getGenderFieldId()).as("gender");
    queryModel.selectField(survey.getAgeFieldId()).as("age");
    queryModel.selectField(survey.getDobFieldId()).as("dob");
    ColumnSet columnSet = client.queryTable(queryModel);
    ColumnView gender = columnSet.getColumnView("gender");
    ColumnView age = columnSet.getColumnView("age");
    ColumnView dob = columnSet.getColumnView("dob");
    assertThat(gender.numRows(), equalTo(numRows));
    assertThat(gender.getType(), equalTo(ColumnType.STRING));
    assertThat(age.numRows(), equalTo(numRows));
}
Also used : ColumnView(org.activityinfo.model.query.ColumnView) ColumnSet(org.activityinfo.model.query.ColumnSet) RecordGenerator(org.activityinfo.store.testing.RecordGenerator) QueryModel(org.activityinfo.model.query.QueryModel) Test(org.junit.Test)

Aggregations

ColumnSet (org.activityinfo.model.query.ColumnSet)1 ColumnView (org.activityinfo.model.query.ColumnView)1 QueryModel (org.activityinfo.model.query.QueryModel)1 RecordGenerator (org.activityinfo.store.testing.RecordGenerator)1 Test (org.junit.Test)1