Search in sources :

Example 16 with LocationDTO

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);
}
Also used : CreateLocation(org.activityinfo.shared.command.CreateLocation) CreateResult(org.activityinfo.shared.command.result.CreateResult) SiteResult(org.activityinfo.shared.command.result.SiteResult) GetSites(org.activityinfo.shared.command.GetSites) SiteDTO(org.activityinfo.shared.dto.SiteDTO) LocationDTO(org.activityinfo.shared.dto.LocationDTO) CreateSite(org.activityinfo.shared.command.CreateSite) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 17 with LocationDTO

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());
}
Also used : LocationDTO(org.activityinfo.shared.dto.LocationDTO) LocationResult(org.activityinfo.shared.command.result.LocationResult) Test(org.junit.Test)

Aggregations

LocationDTO (org.activityinfo.shared.dto.LocationDTO)17 KeyGenerator (org.activityinfo.client.local.command.handler.KeyGenerator)6 SiteDTO (org.activityinfo.shared.dto.SiteDTO)5 CreateLocation (org.activityinfo.shared.command.CreateLocation)4 Test (org.junit.Test)4 CreateSite (org.activityinfo.shared.command.CreateSite)3 SqlResultCallback (com.bedatadriven.rebar.sql.client.SqlResultCallback)2 SqlResultSet (com.bedatadriven.rebar.sql.client.SqlResultSet)2 SqlResultSetRow (com.bedatadriven.rebar.sql.client.SqlResultSetRow)2 SqlTransaction (com.bedatadriven.rebar.sql.client.SqlTransaction)2 ArrayList (java.util.ArrayList)2 LocationDialog (org.activityinfo.client.page.entry.location.LocationDialog)2 AdminEntity (org.activityinfo.server.database.hibernate.entity.AdminEntity)2 CreateResult (org.activityinfo.shared.command.result.CreateResult)2 LocationResult (org.activityinfo.shared.command.result.LocationResult)2 AdminEntityDTO (org.activityinfo.shared.dto.AdminEntityDTO)2 AdminLevelDTO (org.activityinfo.shared.dto.AdminLevelDTO)2 SqlQuery (com.bedatadriven.rebar.sql.client.query.SqlQuery)1 RpcMap (com.extjs.gxt.ui.client.data.RpcMap)1 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1