use of org.activityinfo.legacy.shared.command.GetSites in project activityinfo by bedatadriven.
the class GetSitesTest method testDatabase.
@Test
public void testDatabase() throws CommandException {
setUser(DATABASE_OWNER);
GetSites legacyCmd = new GetSites();
GetSites newCmd = new GetSites();
legacyCmd.filter().addRestriction(DimensionType.Database, 2);
legacyCmd.setLegacyFetch(true);
newCmd.filter().addRestriction(DimensionType.Database, 2);
newCmd.setLegacyFetch(false);
PagingLoadResult<SiteDTO> legacyResult = execute(legacyCmd);
PagingLoadResult<SiteDTO> newResult = execute(newCmd);
Assert.assertEquals("rows", 3, legacyResult.getData().size());
Assert.assertNotNull("activityId", legacyResult.getData().get(0).getActivityId());
Assert.assertEquals("rows", 3, newResult.getData().size());
Assert.assertNotNull("activityId", newResult.getData().get(0).getActivityId());
GetSites newMonthlyCmd = new GetSites();
newMonthlyCmd.filter().addRestriction(DimensionType.Database, 2);
newMonthlyCmd.setLegacyFetch(false);
newMonthlyCmd.setFetchAllReportingPeriods(true);
PagingLoadResult<SiteDTO> newMonthlyResult = execute(newMonthlyCmd);
Assert.assertEquals("rows", 5, newMonthlyResult.getData().size());
}
use of org.activityinfo.legacy.shared.command.GetSites in project activityinfo by bedatadriven.
the class GetSitesTest method testAll.
@Test
public void testAll() throws CommandException {
setUser(DATABASE_OWNER);
GetSites cmd = new GetSites();
PagingLoadResult<SiteDTO> result = execute(cmd);
Assert.assertEquals("rows", 8, result.getData().size());
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 linkedSites.
@Test
@OnDataSet("/dbunit/sites-linked.db.xml")
public void linkedSites() {
setUser(1);
GetSites cmd = new GetSites();
cmd.filter().addRestriction(DimensionType.Activity, 1);
cmd.setSortInfo(new SortInfo("locationName", SortDir.ASC));
SiteResult result = execute(cmd);
assertThat(result.getData().size(), equalTo(2));
SiteDTO site1 = result.getData().get(0);
SiteDTO site2 = result.getData().get(1);
System.out.println(site1.getProperties());
System.out.println(site2.getProperties());
assertThat(site1.getId(), equalTo(1));
assertThat(site1.getLocationName(), equalTo("Penekusu Kivu"));
assertThat(site1.getActivityId(), equalTo(1));
assertThat((Double) site1.getIndicatorValue(1), equalTo(1500d));
assertThat(site2.getId(), equalTo(2));
assertThat(site2.getLocationName(), equalTo("Penekusu Kivu 2"));
assertThat(site2.getActivityId(), equalTo(1));
assertThat((Double) site2.getIndicatorValue(1), equalTo(400d));
}
use of org.activityinfo.legacy.shared.command.GetSites in project activityinfo by bedatadriven.
the class GetSitesTest method linkedSitesFilteredByIndicator.
@Test
@OnDataSet("/dbunit/sites-linked.db.xml")
public void linkedSitesFilteredByIndicator() {
setUser(1);
GetSites cmd = new GetSites();
cmd.filter().addRestriction(DimensionType.Indicator, 1);
cmd.setSortInfo(new SortInfo("locationName", SortDir.ASC));
SiteResult result = execute(cmd);
assertThat(result.getData().size(), equalTo(2));
SiteDTO site1 = result.getData().get(0);
SiteDTO site2 = result.getData().get(1);
System.out.println(site1.getProperties());
System.out.println(site2.getProperties());
assertThat(site1.getId(), equalTo(1));
assertThat(site1.getLocationName(), equalTo("Penekusu Kivu"));
assertThat(site1.getActivityId(), equalTo(1));
assertThat((Double) site1.getIndicatorValue(1), equalTo(1500d));
assertThat(site2.getId(), equalTo(2));
assertThat(site2.getLocationName(), equalTo("Penekusu Kivu 2"));
assertThat(site2.getActivityId(), equalTo(1));
assertThat((Double) site2.getIndicatorValue(1), equalTo(400d));
}
Aggregations