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));
}
Aggregations