use of org.activityinfo.client.page.common.grid.ConfirmCallback in project activityinfo by bedatadriven.
the class DesignTest method testDelete.
@Test
public void testDelete() {
// 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);
expect(view.getSelection()).andReturn(schema.getActivityById(91));
view.confirmDeleteSelected(isA(ConfirmCallback.class));
expectLastCall().andAnswer(new IAnswer<Object>() {
@Override
public Object answer() throws Throwable {
((ConfirmCallback) getCurrentArguments()[0]).confirmed();
return null;
}
});
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 proper delete command executes
designer.onUIAction(UIActions.DELETE);
Delete cmd = service.getLastExecuted(Delete.class);
Assert.assertEquals("Activity", cmd.getEntityName());
Assert.assertEquals(91, cmd.getId());
}
Aggregations