use of org.activityinfo.shared.command.UpdateEntity in project activityinfo by bedatadriven.
the class DesignTest method testSaveOnNavigateAway.
@Test
public void testSaveOnNavigateAway() {
// Dummy Data
SchemaDTO schema = DTOs.pear();
// Collaborator
MockEventBus eventBus = new MockEventBus();
// Collaborator
DispatcherStub service = new DispatcherStub();
service.setResult(GetSchema.class, schema);
service.setResult(UpdateEntity.class, new VoidResult());
// Collaborator
DesignPresenter.View view = createNiceMock(DesignPresenter.View.class);
replay(view);
// Collaborator
UIConstants constants = createNiceMock(UIConstants.class);
replay(constants);
DesignPresenter designer = new DesignPresenter(eventBus, service, new StateManagerStub(), view, constants);
designer.go(schema.getDatabaseById(1));
// Verify that following a change to the record, a save call
// triggers an update command
ActivityDTO activity = (ActivityDTO) ((TreeStore) designer.getStore()).getRootItems().get(0);
Record record = designer.getStore().getRecord(activity);
record.set("name", "New Name");
designer.requestToNavigateAway(new DataEntryPlace(), new NavigationCallback() {
@Override
public void onDecided(boolean allowed) {
}
});
UpdateEntity cmd = service.getLastExecuted(UpdateEntity.class);
Assert.assertTrue(cmd.getChanges().containsKey("name"));
Assert.assertEquals("New Name", cmd.getChanges().get("name"));
}
use of org.activityinfo.shared.command.UpdateEntity in project activityinfo by bedatadriven.
the class ActivityTest method updatePublished.
@Test
public void updatePublished() throws Throwable {
/* Update Sort Order */
Map<String, Object> changes = new HashMap<String, Object>();
changes.put("published", Published.ALL_ARE_PUBLISHED.getIndex());
execute(new UpdateEntity("Activity", 1, changes));
/* Confirm the order is changed */
SchemaDTO schema = execute(new GetSchema());
Assert.assertEquals(Published.ALL_ARE_PUBLISHED.getIndex(), schema.getActivityById(1).getPublished());
}
use of org.activityinfo.shared.command.UpdateEntity in project activityinfo by bedatadriven.
the class ActivityTest method updateSortOrderTest.
@Test
public void updateSortOrderTest() throws Throwable {
/* Update Sort Order */
Map<String, Object> changes1 = new HashMap<String, Object>();
changes1.put("sortOrder", 2);
Map<String, Object> changes2 = new HashMap<String, Object>();
changes2.put("sortOrder", 1);
execute(new BatchCommand(new UpdateEntity("Activity", 1, changes1), new UpdateEntity("Activity", 2, changes2)));
/* Confirm the order is changed */
SchemaDTO schema = execute(new GetSchema());
Assert.assertEquals(2, schema.getDatabaseById(1).getActivities().get(0).getId());
Assert.assertEquals(1, schema.getDatabaseById(1).getActivities().get(1).getId());
}
use of org.activityinfo.shared.command.UpdateEntity in project activityinfo by bedatadriven.
the class AttributeGroupTest method testUpdate.
@Test
public void testUpdate() throws Exception {
// initial data load
SchemaDTO schema = execute(new GetSchema());
// change the name of an entity group
ActivityDTO activity = schema.getActivityById(1);
AttributeGroupDTO group = activity.getAttributeGroups().get(0);
group.setName("Foobar");
Map<String, Object> changes = new HashMap<String, Object>();
changes.put("name", group.getName());
execute(new UpdateEntity(group, changes));
// reload data
schema = execute(new GetSchema());
// verify the property has been duly changed
Assert.assertEquals(group.getName(), schema.getActivityById(1).getAttributeGroups().get(0).getName());
}
use of org.activityinfo.shared.command.UpdateEntity in project activityinfo by bedatadriven.
the class LocalSchemaChangeTest method updateIndicator.
@Test
public void updateIndicator() {
synchronizeFirstTime();
Map<String, Object> changes = Maps.newHashMap();
changes.put("name", "New Name");
UpdateEntity update = new UpdateEntity("Indicator", 5, changes);
executeRemotely(update);
synchronize();
SchemaDTO schema = executeLocally(new GetSchema());
assertThat(schema.getIndicatorById(5).getName(), equalTo("New Name"));
}
Aggregations