use of org.activityinfo.legacy.shared.command.GetSchema in project activityinfo by bedatadriven.
the class PartnerTest method testAddPartner.
@Test
public void testAddPartner() {
PartnerDTO newPartner = new PartnerDTO();
newPartner.setName("Solidarites");
CreateResult cr = execute(new UpdatePartner(PEAR_PLUS_DB_ID, newPartner));
assertThat(cr.getNewId(), not(equalTo(SOL_ID)));
SchemaDTO schema = execute(new GetSchema());
PartnerDTO partner = schema.getDatabaseById(PEAR_PLUS_DB_ID).getPartnerById(cr.getNewId());
Assert.assertNotNull(partner);
Assert.assertEquals(newPartner.getName(), partner.getName());
}
use of org.activityinfo.legacy.shared.command.GetSchema in project activityinfo by bedatadriven.
the class DbListPresenterTest method loaderPopulatesStore.
@Test
public void loaderPopulatesStore() {
ignoreView();
expectDispatch(new GetSchema(), schema);
replay(dispatcher);
createPresenter();
ListStore<UserDatabaseDTO> store = presenter.getStore();
assertThat("store.getCount()", store.getCount(), is(equalTo(3)));
verify(dispatcher);
}
use of org.activityinfo.legacy.shared.command.GetSchema in project activityinfo by bedatadriven.
the class SchemaImporterV2Test method doImport.
private UserDatabaseDTO doImport(String resourceName) throws IOException {
Map<String, Object> dbProps = Maps.newHashMap();
dbProps.put("name", "Syria");
dbProps.put("countryId", 1);
int databaseId = execute(new CreateEntity("UserDatabase", dbProps)).getNewId();
SchemaDTO schema = execute(new GetSchema());
UserDatabaseDTO db = schema.getDatabaseById(databaseId);
if (db == null) {
throw new AssertionError("database not created");
}
SchemaImporterV2 importer = new SchemaImporterV2(getDispatcher(), db, warningTemplates());
importer.setProgressListener(new SchemaImporterV2.ProgressListener() {
@Override
public void submittingBatch(int batchNumber, int batchCount) {
System.out.println("Submitting batch " + batchNumber + " of " + batchCount);
}
});
boolean success = importer.parseColumns(source(resourceName));
if (success) {
importer.processRows();
}
for (SafeHtml warning : importer.getWarnings()) {
System.err.println(warning);
}
if (!success) {
throw new AssertionError("there were fatal errors");
}
importer.persist(new AsyncCallback<Void>() {
@Override
public void onSuccess(Void result) {
System.out.println("Success");
}
@Override
public void onFailure(Throwable caught) {
throw new AssertionError(caught);
}
});
return execute(new GetSchema()).getDatabaseById(databaseId);
}
use of org.activityinfo.legacy.shared.command.GetSchema in project activityinfo by bedatadriven.
the class RemoteDispatcherTest method commandShouldBeSentToServerIfThereAreNoProxiesAndNoPendingCommands.
@Test
public void commandShouldBeSentToServerIfThereAreNoProxiesAndNoPendingCommands() {
// define our expectations
expectRemoteCall(new GetSchema());
replay(service);
// trigger a call
dispatcher.execute(new GetSchema(), makeNullCallback());
processPendingCommands();
// verify that the command was dispatched to the server
verify(service);
}
use of org.activityinfo.legacy.shared.command.GetSchema in project activityinfo by bedatadriven.
the class RemoteDispatcherTest method duplicateCommandsShouldBeMergedWithPendingRequests.
@Test
public void duplicateCommandsShouldBeMergedWithPendingRequests() {
expectRemoteCall(new GetSchema());
replay(service);
// simulate successive dispatches of the same command from different
// components of the application
dispatcher.execute(new GetSchema(), makeNullCallback());
dispatcher.execute(new GetSchema(), makeNullCallback());
processPendingCommands();
// verify that only one command was sent
verify(service);
}
Aggregations