use of org.activityinfo.store.testing.Survey in project activityinfo by bedatadriven.
the class SurveyTest method setupForm.
@Before
public void setupForm() {
TestDatabase database = harness.createDatabase();
client = harness.client();
survey = new Survey(new SiteIds(database));
client.createForm(survey.getFormClass());
}
use of org.activityinfo.store.testing.Survey in project activityinfo by bedatadriven.
the class OfflineStoreGwtTest method testStoreForm.
public void testStoreForm() {
survey = new Survey();
FormMetadata surveyMetadata = FormMetadata.of(1L, survey.getFormClass(), FormPermissions.readWrite());
// First put the schema to the store
Snapshot snapshot = new Snapshot(Collections.singletonList(surveyMetadata), Collections.singletonList(toFormRecordSet(survey)));
offlineStore = new OfflineStore(httpStore, IDBFactoryImpl.create());
httpStore = new HttpStore(new OfflineClientStub());
formStore = new FormStoreImpl(httpStore, offlineStore, Scheduler.get());
offlineStore.store(snapshot).then(new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable caught) {
fail();
}
@Override
public void onSuccess(Void result) {
// Once the store is complete,
// verify that the Form Schema can be read...
verifyWeCanReadFormSchemas().join(OfflineStoreGwtTest.this::verifyWeCanQueryRecords).join(OfflineStoreGwtTest.this::verifyWeCanMakeChangesOffline).join(OfflineStoreGwtTest.this::verifyWeCanLoadCurrentSnapshot).join(OfflineStoreGwtTest.this::verifyWeCanQuery).then(new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable caught) {
LOGGER.log(Level.SEVERE, "Operation failed", caught);
fail();
}
@Override
public void onSuccess(Void result) {
finishTest();
}
});
}
});
delayTestFinish(5000);
}
use of org.activityinfo.store.testing.Survey in project activityinfo by bedatadriven.
the class FormulaValidatorTest method validate.
private FormulaValidator validate(String formula) {
Survey surveyForm = catalog.getSurvey();
FormulaValidator validator = new FormulaValidator(catalog.getFormTree(surveyForm.getFormId()));
validator.validate(FormulaParser.parse(formula));
for (FormulaError error : validator.getErrors()) {
System.out.println("Error at " + error.getSourceRange() + ": " + error.getMessage());
}
return validator;
}
use of org.activityinfo.store.testing.Survey in project activityinfo by bedatadriven.
the class RecordTreeLoaderTest method simpleSurvey.
@Test
public void simpleSurvey() {
Survey survey = setup.getSurveyForm();
Observable<Maybe<RecordTree>> recordTree = setup.getFormStore().getRecordTree(survey.getRecordRef(0));
Connection<Maybe<RecordTree>> recordTreeView = setup.connect(recordTree);
RecordTree tree = recordTreeView.assertLoaded().get();
assertThat(tree.getRoot().get(survey.getNameFieldId()), equalTo(TextValue.valueOf("Melanie")));
}
Aggregations