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"));
}
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));
}
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());
}
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());
}
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));
}
Aggregations