use of org.activityinfo.legacy.shared.model.UserDatabaseDTO in project activityinfo by bedatadriven.
the class LocalGetSchemaHandlerIntTest method forUser.
@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void forUser() throws CommandException {
// only has view access to databse 1
setUser(4);
synchronize();
SchemaDTO schema = executeLocally(new GetSchema());
assertThat(schema.getDatabases().size(), equalTo(2));
UserDatabaseDTO pearDb = schema.getDatabaseById(1);
assertThat(pearDb.getAmOwner(), equalTo(false));
assertThat(pearDb.isViewAllAllowed(), equalTo(false));
assertThat(pearDb.isEditAllowed(), equalTo(false));
assertThat(pearDb.isEditAllAllowed(), equalTo(true));
ActivityFormDTO activity = executeLocally(new GetActivityForm(1));
assertThat(activity.getAttributeGroups().size(), equalTo(3));
AttributeGroupDTO group = activity.getAttributeGroupById(1);
assertThat(group.getName(), equalTo("cause"));
assertThat(group.getAttributes().size(), equalTo(2));
}
use of org.activityinfo.legacy.shared.model.UserDatabaseDTO 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.legacy.shared.model.UserDatabaseDTO in project activityinfo by bedatadriven.
the class SchemaImporterV2Test method southSudan.
@Test
public void southSudan() throws IOException {
UserDatabaseDTO db = doImport("schema_1321.csv");
int activityId = db.getActivities().get(0).getId();
ActivityFormDTO h2 = execute(new GetActivityForm(activityId));
assertThat(h2.getName(), equalTo("H2"));
assertThat(h2.getCategory(), equalTo("Health"));
}
use of org.activityinfo.legacy.shared.model.UserDatabaseDTO in project activityinfo by bedatadriven.
the class ExportIntegrationTest method fullTest.
@Test
public void fullTest() throws Throwable {
User user = new User();
user.setId(1);
user.setName("Alex");
SchemaDTO schema = execute(new GetSchema());
TaskContext context = new TaskContext(getDispatcherSync(), new NullStorageProvider(), "XYZ");
SiteExporter export = new SiteExporter(context);
for (UserDatabaseDTO db : schema.getDatabases()) {
for (ActivityDTO activity : db.getActivities()) {
export.export(execute(new GetActivityForm(activity)), new Filter());
}
}
File outputDir = new File("target/report-test/");
outputDir.mkdirs();
FileOutputStream fos = new FileOutputStream("target/report-test/ExportTest.xls");
export.getBook().write(fos);
fos.close();
}
use of org.activityinfo.legacy.shared.model.UserDatabaseDTO 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);
}
Aggregations