Search in sources :

Example 6 with GetSites

use of org.activityinfo.legacy.shared.command.GetSites in project activityinfo by bedatadriven.

the class GetSitesTest method testAdminEntitySort.

@Test
@OnDataSet("/dbunit/sites-public.db.xml")
public void testAdminEntitySort() throws CommandException {
    setUser(DATABASE_OWNER);
    // level 1 - DESC
    GetSites cmd = new GetSites();
    cmd.filter().onActivity(1);
    cmd.setSortInfo(new SortInfo("E1", SortDir.DESC));
    PagingLoadResult<SiteDTO> result = execute(cmd);
    assertThat("sorted", adminName(result, 0, "E1"), equalTo("Sud Kivu"));
    assertThat("sorted", adminName(result, 1, "E1"), equalTo("Sud Kivu"));
    assertThat("sorted", adminName(result, 2, "E1"), equalTo("Ituri"));
    // level 1 - ASC
    cmd = new GetSites();
    cmd.filter().onActivity(1);
    cmd.setSortInfo(new SortInfo("E1", SortDir.ASC));
    result = execute(cmd);
    assertThat("sorted", adminName(result, 0, "E1"), equalTo("Ituri"));
    assertThat("sorted", adminName(result, 1, "E1"), equalTo("Sud Kivu"));
    assertThat("sorted", adminName(result, 2, "E1"), equalTo("Sud Kivu"));
    // level 2 - DESC
    cmd = new GetSites();
    cmd.filter().onActivity(1);
    cmd.setSortInfo(new SortInfo("E2", SortDir.DESC));
    result = execute(cmd);
    assertThat("sorted", adminName(result, 0, "E2"), equalTo("Walungu"));
    assertThat("sorted", adminName(result, 1, "E2"), equalTo("Shabunda"));
    assertThat("sorted", adminName(result, 2, "E2"), equalTo("Irumu"));
    // level 2 - ASC
    cmd = new GetSites();
    cmd.filter().onActivity(1);
    cmd.setSortInfo(new SortInfo("E2", SortDir.ASC));
    result = execute(cmd);
    assertThat("sorted", adminName(result, 0, "E2"), equalTo("Irumu"));
    assertThat("sorted", adminName(result, 1, "E2"), equalTo("Shabunda"));
    assertThat("sorted", adminName(result, 2, "E2"), equalTo("Walungu"));
}
Also used : GetSites(org.activityinfo.legacy.shared.command.GetSites) SiteDTO(org.activityinfo.legacy.shared.model.SiteDTO) SortInfo(com.extjs.gxt.ui.client.data.SortInfo) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 7 with GetSites

use of org.activityinfo.legacy.shared.command.GetSites in project activityinfo by bedatadriven.

the class GetSitesTest method filterByIndicator.

@Test
public void filterByIndicator() throws CommandException {
    setUser(1);
    Filter filter = new Filter();
    filter.addRestriction(DimensionType.Indicator, 5);
    SiteResult result = execute(new GetSites(filter));
    assertThat(result.getData().size(), equalTo(1));
    assertThat(result.getData().get(0).getId(), equalTo(9));
}
Also used : Filter(org.activityinfo.legacy.shared.command.Filter) SiteResult(org.activityinfo.legacy.shared.command.result.SiteResult) GetSites(org.activityinfo.legacy.shared.command.GetSites) Test(org.junit.Test)

Example 8 with GetSites

use of org.activityinfo.legacy.shared.command.GetSites in project activityinfo by bedatadriven.

the class GetSitesTest method testDatabasePartner2PartnerVisibility.

@Test
public void testDatabasePartner2PartnerVisibility() throws CommandException {
    // BAVON (can't see other partner's stuff)
    setUser(2);
    GetSites cmd = new GetSites();
    cmd.getFilter().addRestriction(DimensionType.Database, 1);
    PagingLoadResult<SiteDTO> result = execute(cmd);
    Assert.assertEquals("rows", 3, result.getData().size());
}
Also used : GetSites(org.activityinfo.legacy.shared.command.GetSites) SiteDTO(org.activityinfo.legacy.shared.model.SiteDTO) Test(org.junit.Test)

Example 9 with GetSites

use of org.activityinfo.legacy.shared.command.GetSites in project activityinfo by bedatadriven.

the class GetSitesTest method testIndicatorSort.

@Test
public void testIndicatorSort() throws CommandException {
    setUser(DATABASE_OWNER);
    GetSites cmd = new GetSites();
    cmd.filter().onActivity(1);
    cmd.setSortInfo(new SortInfo(IndicatorDTO.getPropertyName(1), SortDir.DESC));
    PagingLoadResult<SiteDTO> result = execute(cmd);
    // assure sorted
    assertThat("sorted", (Double) result.getData().get(0).getIndicatorValue(1), equalTo(10000.0));
    assertThat("sorted", (Double) result.getData().get(1).getIndicatorValue(1), closeTo(3600.0, 1d));
    assertThat("sorted", (Double) result.getData().get(2).getIndicatorValue(1), closeTo(1500.0, 1d));
    Assert.assertNotNull("activityId", result.getData().get(0).getActivityId());
}
Also used : GetSites(org.activityinfo.legacy.shared.command.GetSites) SiteDTO(org.activityinfo.legacy.shared.model.SiteDTO) SortInfo(com.extjs.gxt.ui.client.data.SortInfo) Test(org.junit.Test)

Example 10 with GetSites

use of org.activityinfo.legacy.shared.command.GetSites in project activityinfo by bedatadriven.

the class GetSitesTest method filterOnPartner.

@Test
public void filterOnPartner() {
    setUser(1);
    GetSites cmd = new GetSites();
    cmd.filter().addRestriction(DimensionType.Project, 2);
    SiteResult result = execute(cmd);
    assertThat(result.getData().size(), equalTo(1));
}
Also used : SiteResult(org.activityinfo.legacy.shared.command.result.SiteResult) GetSites(org.activityinfo.legacy.shared.command.GetSites) Test(org.junit.Test)

Aggregations

GetSites (org.activityinfo.legacy.shared.command.GetSites)24 Test (org.junit.Test)19 SiteDTO (org.activityinfo.legacy.shared.model.SiteDTO)16 SortInfo (com.extjs.gxt.ui.client.data.SortInfo)10 SiteResult (org.activityinfo.legacy.shared.command.result.SiteResult)9 OnDataSet (org.activityinfo.server.database.OnDataSet)5 Filter (org.activityinfo.legacy.shared.command.Filter)4 LocalDate (com.bedatadriven.rebar.time.calendar.LocalDate)2 FormTree (org.activityinfo.model.formTree.FormTree)2 ImportModel (org.activityinfo.ui.client.component.importDialog.model.ImportModel)2 PastedTable (org.activityinfo.ui.client.component.importDialog.model.source.PastedTable)2 ValidatedRowTable (org.activityinfo.ui.client.component.importDialog.model.validation.ValidatedRowTable)2 Ignore (org.junit.Ignore)2 Delete (org.activityinfo.legacy.shared.command.Delete)1 TableData (org.activityinfo.legacy.shared.reports.content.TableData)1 AdminDimension (org.activityinfo.legacy.shared.reports.model.AdminDimension)1 AttributeGroupDimension (org.activityinfo.legacy.shared.reports.model.AttributeGroupDimension)1 DateDimension (org.activityinfo.legacy.shared.reports.model.DateDimension)1 Dimension (org.activityinfo.legacy.shared.reports.model.Dimension)1 TableColumn (org.activityinfo.legacy.shared.reports.model.TableColumn)1