use of org.activityinfo.legacy.shared.command.result.MonthlyReportResult in project activityinfo by bedatadriven.
the class SyncIntegrationTest method updateMonthlyReports.
@Test
@OnDataSet("/dbunit/monthly-calc-indicators.db.xml")
public void updateMonthlyReports() throws SQLException, InterruptedException {
synchronize();
int siteId = 1;
MonthlyReportResult result = executeLocally(new GetMonthlyReports(siteId, new Month(2009, 1), 5));
IndicatorRowDTO women = result.getData().get(0);
IndicatorRowDTO men = result.getData().get(1);
assertThat(women.getIndicatorName(), equalTo("women"));
assertThat(women.getIndicatorId(), equalTo(7002));
assertThat(men.getIndicatorName(), equalTo("men"));
assertThat(men.getActivityName(), equalTo("NFI"));
assertThat(men.getActivityId(), equalTo(901));
assertThat(men.getIndicatorId(), equalTo(7001));
assertThat(men.getValue(2009, 1), CoreMatchers.equalTo(200d));
assertThat(women.getValue(2009, 1), equalTo(300d));
assertThat(men.getValue(2009, 2), equalTo(150d));
assertThat(women.getValue(2009, 2), equalTo(330d));
// Update locally
executeLocally(new UpdateMonthlyReports(siteId, Lists.newArrayList(new Change(men.getIndicatorId(), new Month(2009, 1), 221d), new Change(men.getIndicatorId(), new Month(2009, 3), 444d), new Change(women.getIndicatorId(), new Month(2009, 5), 200d), new Change(men.getIndicatorId(), new Month(2009, 5), 522d))));
result = executeLocally(new GetMonthlyReports(siteId, new Month(2009, 1), 12));
women = result.getData().get(0);
men = result.getData().get(1);
assertThat(men.getValue(2009, 1), equalTo(221d));
assertThat(women.getValue(2009, 1), equalTo(300d));
// same - no change
assertThat(men.getValue(2009, 2), equalTo(150d));
assertThat(women.getValue(2009, 2), equalTo(330d));
// new periods
assertThat(men.getValue(2009, 3), equalTo(444d));
assertThat(women.getValue(2009, 5), equalTo(200d));
assertThat(men.getValue(2009, 5), equalTo(522d));
// Synchronize
synchronize();
newRequest();
MonthlyReportResult remoteResult = executeRemotely(new GetMonthlyReports(siteId, new Month(2009, 1), 12));
women = remoteResult.getData().get(0);
men = remoteResult.getData().get(1);
assertThat(men.getValue(2009, 1), equalTo(221d));
assertThat(women.getValue(2009, 1), equalTo(300d));
// same - no change
assertThat(men.getValue(2009, 2), equalTo(150d));
assertThat(women.getValue(2009, 2), equalTo(330d));
// new periods
assertThat(men.getValue(2009, 3), equalTo(444d));
assertThat(women.getValue(2009, 5), equalTo(200d));
assertThat(men.getValue(2009, 5), equalTo(522d));
newRequest();
// REmote update
executeRemotely(new UpdateMonthlyReports(siteId, Lists.newArrayList(new Change(men.getIndicatorId(), new Month(2009, 1), 40d), new Change(women.getIndicatorId(), new Month(2009, 3), 6000d))));
newRequest();
synchronize();
result = executeLocally(new GetMonthlyReports(siteId, new Month(2009, 1), 5));
women = result.getData().get(0);
men = result.getData().get(1);
assertThat(men.getValue(2009, 1), CoreMatchers.equalTo(40d));
// unchanged
assertThat(women.getValue(2009, 1), CoreMatchers.equalTo(300d));
assertThat(women.getValue(2009, 3), equalTo(6000d));
}
use of org.activityinfo.legacy.shared.command.result.MonthlyReportResult in project activityinfo by bedatadriven.
the class MonthlyReportsTest method testGetReports.
@Test
public void testGetReports() throws Exception {
GetMonthlyReports cmd = new GetMonthlyReports(6);
cmd.setStartMonth(new Month(2009, 1));
cmd.setEndMonth(new Month(2009, 2));
MonthlyReportResult result = execute(cmd);
Assert.assertEquals(1, result.getData().size());
Assert.assertEquals(35, result.getData().get(0).getValue(2009, 1).intValue());
Assert.assertEquals(70, result.getData().get(0).getValue(2009, 2).intValue());
}
Aggregations