use of org.activityinfo.client.page.NavigationCallback 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"));
}
Aggregations