use of org.activityinfo.legacy.shared.model.SiteDTO 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.model.SiteDTO 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.model.SiteDTO in project activityinfo by bedatadriven.
the class GetSitesTest method testSeekSite.
@Test
@Ignore
public void testSeekSite() throws Exception {
setUser(DATABASE_OWNER);
GetSites cmd = new GetSites();
cmd.filter().onActivity(1);
cmd.setSortInfo(new SortInfo(IndicatorDTO.getPropertyName(1), SortDir.DESC));
cmd.setLimit(2);
cmd.setSeekToSiteId(1);
PagingLoadResult<SiteDTO> result = execute(cmd);
Assert.assertEquals("second page returned", 2, result.getOffset());
Assert.assertEquals("rows on this page", 1, result.getData().size());
Assert.assertEquals("correct site returned", 1, result.getData().get(0).getId());
}
use of org.activityinfo.legacy.shared.model.SiteDTO in project activityinfo by bedatadriven.
the class LocalSiteCreateTest method siteRemovePartnerConflict.
@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void siteRemovePartnerConflict() {
// FIRST U1 adds a new partner
int databaseId = 1;
PartnerDTO iom = new PartnerDTO();
iom.setName("IOM");
CreateResult result = executeRemotely(new UpdatePartner(databaseId, iom));
iom.setId(result.getNewId());
// Now U2 synchronizes, and adds a new site with this partner
synchronize();
SiteDTO site = new SiteDTO();
site.setId(3343234);
site.setActivityId(1);
site.setPartner(iom);
site.setDate1(new Date());
site.setDate2(new Date());
site.setLocationId(1);
executeLocally(new CreateSite(site));
// At T+3, U2 thinks better, removes IOM
executeRemotely(new RemovePartner(databaseId, iom.getId()));
// At T+4, U1 synchronizes, and IOM is removed, but site remains
synchronize();
// Verify that there is still a label for this partner
SiteResult sites = executeLocally(GetSites.byId(site.getId()));
assertThat(sites.getTotalLength(), equalTo(1));
assertThat(sites.getData().get(0).getName(), equalTo(site.getName()));
}
use of org.activityinfo.legacy.shared.model.SiteDTO in project activityinfo by bedatadriven.
the class TableGeneratorTest method dummySite.
public SiteDTO dummySite() {
SiteDTO site = new SiteDTO();
site.setId(1);
site.setLocationName("tampa bay");
site.setIndicatorValue(INDICATOR_ID, 1500d);
site.setX(28.4);
site.setY(1.2);
return site;
}
Aggregations