use of org.activityinfo.shared.command.GetSites in project activityinfo by bedatadriven.
the class GetSitesTest method testActivityQueryBasic.
@Test
public void testActivityQueryBasic() throws CommandException {
setUser(DATABASE_OWNER);
GetSites cmd = new GetSites();
cmd.filter().onActivity(1);
cmd.setSortInfo(new SortInfo("date2", SortDir.DESC));
PagingLoadResult<SiteDTO> result = execute(cmd);
Assert.assertEquals("totalLength", 3, result.getData().size());
Assert.assertEquals("totalLength", 3, result.getTotalLength());
Assert.assertEquals("offset", 0, result.getOffset());
// Assert.assertNull("row(0).activity",
// result.getData().get(0).getActivity());
// assure sorted
Assert.assertEquals("sorted", 2, result.getData().get(0).getId());
Assert.assertEquals("sorted", 1, result.getData().get(1).getId());
Assert.assertEquals("sorted", 3, result.getData().get(2).getId());
// assure indicators are present (site id=3)
SiteDTO s = result.getData().get(2);
Assert.assertEquals("entityName", "Ituri", s.getAdminEntity(1).getName());
Assert.assertNotNull("admin bounds", s.getAdminEntity(1).getBounds());
Assert.assertEquals("indicator", 10000.0, s.getIndicatorValue(1));
Assert.assertNull("site x", s.getX());
// assure project is present
SiteDTO s1 = result.getData().get(1);
assertThat(s1.getId(), equalTo(1));
assertThat(s1.getProject().getId(), equalTo(1));
}
use of org.activityinfo.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));
}
use of org.activityinfo.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.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
Assert.assertEquals("sorted", 10000.0, result.getData().get(0).getIndicatorValue(1));
Assert.assertEquals("sorted", 3600.0, result.getData().get(1).getIndicatorValue(1));
Assert.assertEquals("sorted", 1500.0, result.getData().get(2).getIndicatorValue(1));
Assert.assertNotNull("activityId", result.getData().get(0).getActivityId());
}
use of org.activityinfo.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());
}
Aggregations