use of org.activityinfo.shared.dto.LocationDTO in project activityinfo by bedatadriven.
the class LocalSiteCreateTest method createNew.
@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void createNew() throws CommandException {
synchronizeFirstTime();
// 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);
loadResult = executeLocally(pagingRequest);
}
use of org.activityinfo.shared.dto.LocationDTO in project activityinfo by bedatadriven.
the class CreateLocationTest method test.
@Test
public void test() throws CommandException {
LocationDTO location = LocationDTOs.newLocation();
execute(new CreateLocation(location));
SearchLocations getLocations = new SearchLocations().setName(location.getName());
LocationResult locations = execute(getLocations);
LocationDTO newLocation = locations.getData().get(0);
assertEquals(location.getName(), newLocation.getName());
assertEquals(location.getAxe(), newLocation.getAxe());
assertEquals(location.getLongitude(), newLocation.getLongitude());
assertEquals(location.getLatitude(), newLocation.getLatitude());
}
Aggregations