Search in sources :

Example 1 with ConfirmCallback

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());
}
Also used : Delete(org.activityinfo.shared.command.Delete) ConfirmCallback(org.activityinfo.client.page.common.grid.ConfirmCallback) VoidResult(org.activityinfo.shared.command.result.VoidResult) DispatcherStub(org.activityinfo.client.dispatch.DispatcherStub) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) MockEventBus(org.activityinfo.client.MockEventBus) UIConstants(org.activityinfo.client.i18n.UIConstants) StateManagerStub(org.activityinfo.client.mock.StateManagerStub) Test(org.junit.Test)

Aggregations

MockEventBus (org.activityinfo.client.MockEventBus)1 DispatcherStub (org.activityinfo.client.dispatch.DispatcherStub)1 UIConstants (org.activityinfo.client.i18n.UIConstants)1 StateManagerStub (org.activityinfo.client.mock.StateManagerStub)1 ConfirmCallback (org.activityinfo.client.page.common.grid.ConfirmCallback)1 Delete (org.activityinfo.shared.command.Delete)1 VoidResult (org.activityinfo.shared.command.result.VoidResult)1 SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)1 Test (org.junit.Test)1