use of org.activityinfo.legacy.shared.command.result.SiteResult 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.result.SiteResult 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));
}
use of org.activityinfo.legacy.shared.command.result.SiteResult in project activityinfo by bedatadriven.
the class LocalSiteCreateTest method createNew.
@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void createNew() {
synchronize();
// create a new detached, client model
SiteDTO newSite = SiteDTOs.newSite();
LocationDTO location = LocationDTOs.newLocation();
executeLocally(new CreateLocation(location));
newSite.setLocation(location);
// create command
CreateSite cmd = new CreateSite(newSite);
// execute the command
CreateResult result = executeLocally(cmd);
// let the client know the command has succeeded
newSite.setId(result.getNewId());
// try to retrieve what we've created FROM OUR CLIENT SIDE DATABASE
SiteResult loadResult = executeLocally(GetSites.byId(newSite.getId()));
Assert.assertEquals(1, loadResult.getData().size());
SiteDTO secondRead = loadResult.getData().get(0);
// confirm that the changes are there
SiteDTOs.validateNewSite(secondRead);
newRequest();
// now Sync with the server
synchronize();
// Confirm that paging works client side
GetSites pagingRequest = new GetSites();
pagingRequest.setLimit(1);
executeLocally(pagingRequest);
}
use of org.activityinfo.legacy.shared.command.result.SiteResult in project activityinfo by bedatadriven.
the class ProjectTest method deleteProject.
@Test
public void deleteProject() {
setUser(1);
long originalDatabaseVersion = lookupDbVersion(1);
int projectId = 2;
execute(RequestChange.delete("Project", projectId));
SchemaDTO schema = execute(new GetSchema());
assertThat(schema.getProjectById(projectId), nullValue());
// make sure it's gone from sites
Filter filter = new Filter();
filter.addRestriction(DimensionType.Activity, 1);
filter.addRestriction(DimensionType.Site, 3);
SiteResult sites = execute(new GetSites(filter));
assertThat(sites.getData().get(0).getProject(), is(nullValue()));
// and doesn't show up in pivoting...
PivotSites pivot = new PivotSites();
Dimension projectDimension = new Dimension(DimensionType.Project);
pivot.setDimensions(projectDimension);
pivot.setFilter(filter);
PivotResult buckets = execute(pivot);
assertThat(buckets.getBuckets().size(), equalTo(1));
assertThat(buckets.getBuckets().get(0).getCategory(projectDimension), is(nullValue()));
// make sure the version number of the database is updated
assertThat(lookupDbVersion(1), not(equalTo(originalDatabaseVersion)));
}
Aggregations