use of org.activityinfo.server.command.handler.GetSyncRegionsHandler in project activityinfo by bedatadriven.
the class LocationBuilderTest method locationTypeChange.
@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void locationTypeChange() throws Exception {
EntityManager em = emf.createEntityManager();
User user = em.find(User.class, 1);
// Update the location type 1
Map<String, Object> changes = new HashMap<>();
changes.put("name", "Ishamael");
em.getTransaction().begin();
LocationTypePolicy locationTypePolicy = new LocationTypePolicy(em);
locationTypePolicy.update(user, 1, new PropertyMap(changes));
em.getTransaction().commit();
// First update should include this change
String regionId = "location/" + 1;
LocationUpdateBuilder builder = new LocationUpdateBuilder(em);
GetSyncRegionUpdates request = new GetSyncRegionUpdates(regionId, null);
SyncRegionUpdate update = builder.build(user, request);
assertThat(update.isComplete(), equalTo(true));
assertThat(update.getSql(), containsString("Ishamael"));
// We should be up to date now...
GetSyncRegionsHandler getSyncRegionsHandler = new GetSyncRegionsHandler(em);
SyncRegions syncRegions = getSyncRegionsHandler.execute(new GetSyncRegions(), user);
System.out.println(syncRegions.getList());
assertThat(syncRegions, hasItem(new SyncRegion(regionId, update.getVersion())));
}
Aggregations