Search in sources :

Example 6 with UserDatabaseDTO

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));
}
Also used : AttributeGroupDTO(org.activityinfo.legacy.shared.model.AttributeGroupDTO) ActivityFormDTO(org.activityinfo.legacy.shared.model.ActivityFormDTO) UserDatabaseDTO(org.activityinfo.legacy.shared.model.UserDatabaseDTO) SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 7 with UserDatabaseDTO

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)));
}
Also used : CreateEntity(org.activityinfo.legacy.shared.command.CreateEntity) UserDatabaseDTO(org.activityinfo.legacy.shared.model.UserDatabaseDTO) CountryDTO(org.activityinfo.legacy.shared.model.CountryDTO) GetSchema(org.activityinfo.legacy.shared.command.GetSchema) Capture(org.easymock.Capture) Test(org.junit.Test)

Example 8 with UserDatabaseDTO

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"));
}
Also used : ActivityFormDTO(org.activityinfo.legacy.shared.model.ActivityFormDTO) UserDatabaseDTO(org.activityinfo.legacy.shared.model.UserDatabaseDTO) GetActivityForm(org.activityinfo.legacy.shared.command.GetActivityForm) Test(org.junit.Test)

Example 9 with UserDatabaseDTO

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();
}
Also used : SiteExporter(org.activityinfo.server.endpoint.export.SiteExporter) User(org.activityinfo.server.database.hibernate.entity.User) TaskContext(org.activityinfo.server.endpoint.export.TaskContext) UserDatabaseDTO(org.activityinfo.legacy.shared.model.UserDatabaseDTO) Filter(org.activityinfo.legacy.shared.command.Filter) FileOutputStream(java.io.FileOutputStream) ActivityDTO(org.activityinfo.legacy.shared.model.ActivityDTO) SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO) GetSchema(org.activityinfo.legacy.shared.command.GetSchema) GetActivityForm(org.activityinfo.legacy.shared.command.GetActivityForm) File(java.io.File) NullStorageProvider(org.activityinfo.server.report.NullStorageProvider) Test(org.junit.Test)

Example 10 with UserDatabaseDTO

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);
}
Also used : UserDatabaseDTO(org.activityinfo.legacy.shared.model.UserDatabaseDTO) GetSchema(org.activityinfo.legacy.shared.command.GetSchema) Test(org.junit.Test)

Aggregations

UserDatabaseDTO (org.activityinfo.legacy.shared.model.UserDatabaseDTO)18 GetSchema (org.activityinfo.legacy.shared.command.GetSchema)11 SchemaDTO (org.activityinfo.legacy.shared.model.SchemaDTO)9 Test (org.junit.Test)8 CreateEntity (org.activityinfo.legacy.shared.command.CreateEntity)4 GetActivityForm (org.activityinfo.legacy.shared.command.GetActivityForm)4 ActivityDTO (org.activityinfo.legacy.shared.model.ActivityDTO)4 ActivityFormDTO (org.activityinfo.legacy.shared.model.ActivityFormDTO)4 OnDataSet (org.activityinfo.server.database.OnDataSet)3 CreateResult (org.activityinfo.legacy.shared.command.result.CreateResult)2 AttributeGroupDTO (org.activityinfo.legacy.shared.model.AttributeGroupDTO)2 Before (org.junit.Before)2 BaseListLoadResult (com.extjs.gxt.ui.client.data.BaseListLoadResult)1 Function (com.google.common.base.Function)1 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 XFormList (org.activityinfo.io.xform.formList.XFormList)1