use of org.activityinfo.client.MockEventBus in project activityinfo by bedatadriven.
the class AdminEntityCacheTest method testRootLevelCache.
@Test
public void testRootLevelCache() {
CacheManager proxyMgr = new CacheManager(new MockEventBus());
new AdminEntityCache(proxyMgr);
proxyMgr.notifyListenersOfSuccess(new GetAdminEntities(1), DTOs.getProvinces());
CacheResult<ListResult<AdminEntityDTO>> proxyResult = proxyMgr.execute(new GetAdminEntities(1));
Assert.assertTrue(proxyResult.isCouldExecute());
Assert.assertEquals(2, proxyResult.getResult().getData().size());
}
use of org.activityinfo.client.MockEventBus in project activityinfo by bedatadriven.
the class OutOfSyncMonitorTest method setUp.
@Before
public void setUp() {
eventBus = new MockEventBus();
notifier = createNiceMock(OutOfSyncMonitor.View.class);
replay(notifier);
}
use of org.activityinfo.client.MockEventBus in project activityinfo by bedatadriven.
the class DesignTest method testSave.
@Test
public void testSave() {
// 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);
// Localisation resources
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.onUIAction(UIActions.SAVE);
UpdateEntity cmd = service.getLastExecuted(UpdateEntity.class);
Assert.assertTrue(cmd.getChanges().containsKey("name"));
Assert.assertEquals("New Name", cmd.getChanges().get("name"));
}
use of org.activityinfo.client.MockEventBus in project activityinfo by bedatadriven.
the class DesignTest method testDeleteEnabled.
@Test
public void testDeleteEnabled() {
// Dummy Data
SchemaDTO schema = DTOs.pear();
// Collaborator
DispatcherStub service = new DispatcherStub();
service.setResult(GetSchema.class, schema);
service.setResult(Delete.class, new VoidResult());
// Collaborator
DesignPresenter.View view = createNiceMock(DesignPresenter.View.class);
view.setActionEnabled(UIActions.DELETE, false);
replay(view);
// Collaborator
UIConstants constants = createNiceMock(UIConstants.class);
replay(constants);
DesignPresenter designer = new DesignPresenter(new MockEventBus(), service, new StateManagerStub(), view, constants);
designer.go(schema.getDatabaseById(1));
// Verify that the delete command is initially disabled
verify(view);
// Verify that the delete command is enabled when an activity is
// selected
resetToDefault(view);
view.setActionEnabled(UIActions.DELETE, true);
replay(view);
designer.onSelectionChanged(schema.getActivityById(91));
verify(view);
// Verify that the delete command is disabled when a folder is selected
reset(view);
view.setActionEnabled(UIActions.DELETE, false);
replay(view);
designer.onSelectionChanged(new IndicatorFolder(null));
verify(view);
}
Aggregations