use of org.activityinfo.ui.client.store.http.HttpStore 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.ui.client.store.http.HttpStore in project activityinfo by bedatadriven.
the class FormStoreTest method newRecordHitsQuery.
@Test
public void newRecordHitsQuery() {
TestingStorageProvider catalog = new TestingStorageProvider();
Survey survey = catalog.getSurvey();
AsyncClientStub client = new AsyncClientStub(catalog);
HttpStore httpStore = new HttpStore(client, scheduler);
OfflineStore offlineStore = new OfflineStore(httpStore, new IDBFactoryStub());
FormStoreImpl formStore = new FormStoreImpl(httpStore, offlineStore, scheduler);
// Open a query on a set of records
QueryModel queryModel = new QueryModel(survey.getFormId());
queryModel.selectResourceId().as("id");
Connection<ColumnSet> tableView = connect(formStore.query(queryModel));
tableView.assertLoaded();
// Add an new record to Survey
tableView.resetChangeCounter();
formStore.updateRecords(new RecordTransactionBuilder().add(catalog.addNew(survey.getFormId())).build());
// Verify that the table view has been updated
tableView.assertLoaded();
tableView.assertChanged();
assertThat(tableView.assertLoaded().getNumRows(), equalTo(survey.getRowCount() + 1));
}
Aggregations