Search in sources :

Example 16 with ActivityDTO

use of org.activityinfo.shared.dto.ActivityDTO in project activityinfo by bedatadriven.

the class DimensionPrunerTest method setupData.

@Before
public void setupData() {
    ActivityDTO dist = new ActivityDTO(1, "Distribution");
    IndicatorDTO nbMenages = new IndicatorDTO();
    nbMenages.setId(NB_MENAGES_INDICATOR_ID);
    nbMenages.setName("Nb Menages");
    dist.getIndicators().add(nbMenages);
    AttributeGroupDTO distFunding = new AttributeGroupDTO(NFI_FUNDING_GROUP_ID);
    distFunding.setName("Funding Source");
    dist.getAttributeGroups().add(distFunding);
    ActivityDTO fairs = new ActivityDTO(2, "Faire");
    AttributeGroupDTO fairFunding = new AttributeGroupDTO(FAIR_FUNDING_GROUP_ID);
    fairFunding.setName("Funding Source");
    fairs.getAttributeGroups().add(fairFunding);
    IndicatorDTO voucherValue = new IndicatorDTO();
    voucherValue.setId(VOUCHER_INDICATOR_ID);
    voucherValue.setName("Voucher Value");
    fairs.getIndicators().add(voucherValue);
    UserDatabaseDTO nfi = new UserDatabaseDTO(1, "NFI");
    nfi.getActivities().add(dist);
    nfi.getActivities().add(fairs);
    this.schema = new SchemaDTO();
    schema.getDatabases().add(nfi);
    dispatcher.setResult(GetSchema.class, schema);
}
Also used : IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) AttributeGroupDTO(org.activityinfo.shared.dto.AttributeGroupDTO) UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) Before(org.junit.Before)

Example 17 with ActivityDTO

use of org.activityinfo.shared.dto.ActivityDTO in project activityinfo by bedatadriven.

the class ActivityTest method testActivity.

@Test
public void testActivity() throws CommandException {
    /*
         * Initial data load
         */
    SchemaDTO schema = execute(new GetSchema());
    UserDatabaseDTO db = schema.getDatabaseById(1);
    /*
         * Create a new activity
         */
    LocationTypeDTO locType = schema.getCountryById(1).getLocationTypes().get(0);
    ActivityDTO act = new ActivityDTO();
    act.setName("Warshing the dishes");
    act.setLocationTypeId(locType.getId());
    act.setReportingFrequency(ActivityDTO.REPORT_MONTHLY);
    CreateResult cresult = execute(CreateEntity.Activity(db, act));
    int newId = cresult.getNewId();
    /*
         * Reload schema to verify the changes have stuck
         */
    schema = execute(new GetSchema());
    act = schema.getActivityById(newId);
    Assert.assertEquals("name", "Warshing the dishes", act.getName());
    Assert.assertEquals("locationType", locType.getName(), act.getLocationType().getName());
    Assert.assertEquals("reportingFrequency", ActivityDTO.REPORT_MONTHLY, act.getReportingFrequency());
    Assert.assertEquals("public", Published.NOT_PUBLISHED.getIndex(), act.getPublished());
}
Also used : CreateResult(org.activityinfo.shared.command.result.CreateResult) UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO) LocationTypeDTO(org.activityinfo.shared.dto.LocationTypeDTO) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 18 with ActivityDTO

use of org.activityinfo.shared.dto.ActivityDTO in project activityinfo by bedatadriven.

the class SiteRendererTest method multipleGroupsRender.

@Test
public void multipleGroupsRender() {
    IndicatorDTO indicator1 = new IndicatorDTO();
    indicator1.setId(1);
    indicator1.setAggregation(IndicatorDTO.AGGREGATE_SUM);
    indicator1.setName("First indicator");
    indicator1.setCategory("First group");
    IndicatorDTO indicator2 = new IndicatorDTO();
    indicator2.setAggregation(IndicatorDTO.AGGREGATE_SUM);
    indicator2.setId(2);
    indicator2.setName("Second indicator");
    indicator2.setCategory("Second group");
    ActivityDTO activity = new ActivityDTO();
    activity.setId(1);
    activity.getIndicators().add(indicator1);
    activity.getIndicators().add(indicator2);
    SiteDTO site = new SiteDTO();
    site.setIndicatorValue(1, 1000d);
    site.setIndicatorValue(2, 2000d);
    String html = siteRenderer.renderSite(site, activity, false, true);
    assertTrue(html.contains(indicator1.getName()));
    assertTrue(html.contains(indicator2.getName()));
}
Also used : IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) SiteDTO(org.activityinfo.shared.dto.SiteDTO) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) Test(org.junit.Test)

Example 19 with ActivityDTO

use of org.activityinfo.shared.dto.ActivityDTO in project activityinfo by bedatadriven.

the class AttributeGroupTest method testUpdate.

@Test
public void testUpdate() throws Exception {
    // initial data load
    SchemaDTO schema = execute(new GetSchema());
    // change the name of an entity group
    ActivityDTO activity = schema.getActivityById(1);
    AttributeGroupDTO group = activity.getAttributeGroups().get(0);
    group.setName("Foobar");
    Map<String, Object> changes = new HashMap<String, Object>();
    changes.put("name", group.getName());
    execute(new UpdateEntity(group, changes));
    // reload data
    schema = execute(new GetSchema());
    // verify the property has been duly changed
    Assert.assertEquals(group.getName(), schema.getActivityById(1).getAttributeGroups().get(0).getName());
}
Also used : AttributeGroupDTO(org.activityinfo.shared.dto.AttributeGroupDTO) UpdateEntity(org.activityinfo.shared.command.UpdateEntity) HashMap(java.util.HashMap) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 20 with ActivityDTO

use of org.activityinfo.shared.dto.ActivityDTO in project activityinfo by bedatadriven.

the class LocalSchemaChangeTest method createActivity.

@Test
public void createActivity() {
    synchronizeFirstTime();
    SchemaDTO schema = executeLocally(new GetSchema());
    ActivityDTO activity = new ActivityDTO();
    activity.setName("New Activity");
    activity.setReportingFrequency(0);
    activity.setLocationTypeId(1);
    CreateResult createResult = executeRemotely(CreateEntity.Activity(schema.getDatabaseById(1), activity));
    synchronize();
    schema = executeLocally(new GetSchema());
    ActivityDTO createdActivity = schema.getActivityById(createResult.getNewId());
    assertThat(createdActivity, is(not(nullValue())));
    assertThat(createdActivity.getName(), equalTo(activity.getName()));
}
Also used : CreateResult(org.activityinfo.shared.command.result.CreateResult) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Aggregations

ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)44 SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)20 GetSchema (org.activityinfo.shared.command.GetSchema)15 UserDatabaseDTO (org.activityinfo.shared.dto.UserDatabaseDTO)13 Test (org.junit.Test)13 AttributeGroupDTO (org.activityinfo.shared.dto.AttributeGroupDTO)9 IndicatorDTO (org.activityinfo.shared.dto.IndicatorDTO)9 SiteDTO (org.activityinfo.shared.dto.SiteDTO)8 CreateResult (org.activityinfo.shared.command.result.CreateResult)6 ModelData (com.extjs.gxt.ui.client.data.ModelData)5 AttributeDTO (org.activityinfo.shared.dto.AttributeDTO)5 ProjectDTO (org.activityinfo.shared.dto.ProjectDTO)5 TreeStore (com.extjs.gxt.ui.client.store.TreeStore)4 ColumnConfig (com.extjs.gxt.ui.client.widget.grid.ColumnConfig)3 ColumnData (com.extjs.gxt.ui.client.widget.grid.ColumnData)3 HashMap (java.util.HashMap)3 MockEventBus (org.activityinfo.client.MockEventBus)3 DispatcherStub (org.activityinfo.client.dispatch.DispatcherStub)3 UIConstants (org.activityinfo.client.i18n.UIConstants)3 StateManagerStub (org.activityinfo.client.mock.StateManagerStub)3