use of org.activityinfo.shared.command.GetSchema in project activityinfo by bedatadriven.
the class SchemaCacheTest method testSchemaCache.
@Test
public void testSchemaCache() {
CacheManager proxyMgr = new CacheManager(new MockEventBus());
new SchemaCache(proxyMgr);
SchemaDTO schema = DTOs.pear();
proxyMgr.notifyListenersOfSuccess(new GetSchema(), schema);
CacheResult<SchemaDTO> proxyResult = proxyMgr.execute(new GetSchema());
Assert.assertTrue("could execute locally", proxyResult.isCouldExecute());
Assert.assertEquals("PEAR", proxyResult.getResult().getDatabaseById(1).getName());
}
use of org.activityinfo.shared.command.GetSchema in project activityinfo by bedatadriven.
the class MockRemoteCommandService method execute.
@Override
public void execute(String authToken, List<Command> cmds, AsyncCallback<List<CommandResult>> callback) {
List<CommandResult> results = new ArrayList<CommandResult>();
for (Command cmd : cmds) {
Integer count = commandCounts.get(cmd.getClass());
commandCounts.put(cmd.getClass(), count == null ? 1 : count + 1);
if (schema != null && cmd instanceof GetSchema) {
results.add(schema);
} else {
results.add(mockExecute(cmd));
}
}
callback.onSuccess(results);
}
use of org.activityinfo.shared.command.GetSchema in project activityinfo by bedatadriven.
the class DbListPresenterTest method commandShouldBePreparedProperly.
@Test
public void commandShouldBePreparedProperly() {
Capture<CreateEntity> cmd = new Capture<CreateEntity>();
expectDispatch(new GetSchema(), schema);
captureDispatch(cmd);
replay(dispatcher);
UserDatabaseDTO newDb = new UserDatabaseDTO();
newDb.setCountry(new CountryDTO(31, "Haiti"));
newDb.setName("My Db");
createPresenter();
presenter.save(newDb, niceFormDialogMock());
assertTrue("command was dispatched", cmd.hasCaptured());
assertThat((Integer) cmd.getValue().getProperties().get("countryId"), is(equalTo(31)));
}
use of org.activityinfo.shared.command.GetSchema in project activityinfo by bedatadriven.
the class ActivityTest method updatePublished.
@Test
public void updatePublished() throws Throwable {
/* Update Sort Order */
Map<String, Object> changes = new HashMap<String, Object>();
changes.put("published", Published.ALL_ARE_PUBLISHED.getIndex());
execute(new UpdateEntity("Activity", 1, changes));
/* Confirm the order is changed */
SchemaDTO schema = execute(new GetSchema());
Assert.assertEquals(Published.ALL_ARE_PUBLISHED.getIndex(), schema.getActivityById(1).getPublished());
}
use of org.activityinfo.shared.command.GetSchema in project activityinfo by bedatadriven.
the class ActivityTest method updateSortOrderTest.
@Test
public void updateSortOrderTest() throws Throwable {
/* Update Sort Order */
Map<String, Object> changes1 = new HashMap<String, Object>();
changes1.put("sortOrder", 2);
Map<String, Object> changes2 = new HashMap<String, Object>();
changes2.put("sortOrder", 1);
execute(new BatchCommand(new UpdateEntity("Activity", 1, changes1), new UpdateEntity("Activity", 2, changes2)));
/* Confirm the order is changed */
SchemaDTO schema = execute(new GetSchema());
Assert.assertEquals(2, schema.getDatabaseById(1).getActivities().get(0).getId());
Assert.assertEquals(1, schema.getDatabaseById(1).getActivities().get(1).getId());
}
Aggregations