Search in sources :

Example 11 with GetSchema

use of org.activityinfo.legacy.shared.command.GetSchema in project activityinfo by bedatadriven.

the class CommandRequestTest method equalCommandsShouldBeMerged.

@Test
public void equalCommandsShouldBeMerged() {
    assumeThat(new GetSchema(), is(equalTo(new GetSchema())));
    CommandRequest firstCommand = new CommandRequest(new GetSchema(), new NullCallback());
    List<CommandRequest> pending = Collections.singletonList(firstCommand);
    CommandRequest secondRequest = new CommandRequest(new GetSchema(), new NullCallback());
    boolean merged = secondRequest.mergeSuccessfulInto(pending);
    assertThat("merged", merged, is(true));
    assertThat(firstCommand.getCallbacks(), hasItem(first(secondRequest.getCallbacks())));
}
Also used : NullCallback(com.bedatadriven.rebar.async.NullCallback) GetSchema(org.activityinfo.legacy.shared.command.GetSchema) Test(org.junit.Test)

Example 12 with GetSchema

use of org.activityinfo.legacy.shared.command.GetSchema in project activityinfo by bedatadriven.

the class RemoteDispatcherTest method duplicateCommandsShouldBeMergedWithExecutingRequests.

@Test
public void duplicateCommandsShouldBeMergedWithExecutingRequests() {
    expectRemoteCall(new GetSchema());
    replay(service);
    // simulate successive dispatches of the same command from different
    // components of the application
    dispatcher.execute(new GetSchema(), makeNullCallback());
    processPendingCommands();
    dispatcher.execute(new GetSchema(), makeNullCallback());
    // verify that only one command was sent
    verify(service);
}
Also used : GetSchema(org.activityinfo.legacy.shared.command.GetSchema) Test(org.junit.Test)

Example 13 with GetSchema

use of org.activityinfo.legacy.shared.command.GetSchema in project activityinfo by bedatadriven.

the class RemoteDispatcherTest method mergedCommandsShouldEachReceiveACallback.

@Test
public void mergedCommandsShouldEachReceiveACallback() {
    expectRemoteCall(new GetSchema());
    andCallbackWihSuccess(new SchemaDTO());
    replay(service);
    AsyncCallback callback1 = makeCallbackThatExpectsNonNullSuccess();
    AsyncCallback callback2 = makeCallbackThatExpectsNonNullSuccess();
    // simulate successive dispatches of the same command from different
    // components of the application
    dispatcher.execute(new GetSchema(), callback1);
    dispatcher.execute(new GetSchema(), callback2);
    processPendingCommands();
    // verify that only one command was sent
    verify(callback1);
    verify(callback2);
}
Also used : AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetSchema(org.activityinfo.legacy.shared.command.GetSchema) SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO) Test(org.junit.Test)

Example 14 with GetSchema

use of org.activityinfo.legacy.shared.command.GetSchema in project activityinfo by bedatadriven.

the class RemoteDispatcherTest method commandsUnsuccessfullyExecutedThroughProxiesShouldBeSentToServer.

@Test
public void commandsUnsuccessfullyExecutedThroughProxiesShouldBeSentToServer() {
    GetSchema command = new GetSchema();
    expect(proxy.maybeExecute(eq(command))).andReturn(CacheResult.couldNotExecute());
    replay(proxy);
    expectRemoteCall(command);
    andCallbackWihSuccess(new SchemaDTO());
    replay(service);
    AsyncCallback callback = makeCallbackThatExpectsNonNullSuccess();
    proxyManager.registerProxy(GetSchema.class, proxy);
    dispatcher.execute(new GetSchema(), callback);
    processPendingCommands();
    verify(proxy, service, callback);
}
Also used : AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetSchema(org.activityinfo.legacy.shared.command.GetSchema) SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO) Test(org.junit.Test)

Example 15 with GetSchema

use of org.activityinfo.legacy.shared.command.GetSchema in project activityinfo by bedatadriven.

the class RemoteDispatcherTest method commandsSuccessfullyExecutedThroughProxiesShouldNotBeSentToServer.

@Test
public void commandsSuccessfullyExecutedThroughProxiesShouldNotBeSentToServer() {
    GetSchema command = new GetSchema();
    expect(proxy.maybeExecute(eq(command))).andReturn(new CacheResult(new SchemaDTO()));
    replay(proxy);
    // no calls should be made to the remote service
    replay(service);
    AsyncCallback callback = makeCallbackThatExpectsNonNullSuccess();
    proxyManager.registerProxy(GetSchema.class, proxy);
    dispatcher.execute(new GetSchema(), callback);
    processPendingCommands();
    verify(proxy, service, callback);
}
Also used : AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) CacheResult(org.activityinfo.ui.client.dispatch.remote.cache.CacheResult) GetSchema(org.activityinfo.legacy.shared.command.GetSchema) SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO) Test(org.junit.Test)

Aggregations

GetSchema (org.activityinfo.legacy.shared.command.GetSchema)42 Test (org.junit.Test)27 SchemaDTO (org.activityinfo.legacy.shared.model.SchemaDTO)22 UserDatabaseDTO (org.activityinfo.legacy.shared.model.UserDatabaseDTO)11 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)9 CreateResult (org.activityinfo.legacy.shared.command.result.CreateResult)7 GetActivityForm (org.activityinfo.legacy.shared.command.GetActivityForm)6 CreateEntity (org.activityinfo.legacy.shared.command.CreateEntity)4 UpdatePartner (org.activityinfo.legacy.shared.command.UpdatePartner)4 ActivityDTO (org.activityinfo.legacy.shared.model.ActivityDTO)4 CloneDatabase (org.activityinfo.legacy.shared.command.CloneDatabase)3 OnDataSet (org.activityinfo.server.database.OnDataSet)3 Delete (org.activityinfo.legacy.shared.command.Delete)2 DuplicateCreateResult (org.activityinfo.legacy.shared.command.result.DuplicateCreateResult)2 ActivityFormDTO (org.activityinfo.legacy.shared.model.ActivityFormDTO)2 CacheResult (org.activityinfo.ui.client.dispatch.remote.cache.CacheResult)2 NullCallback (com.bedatadriven.rebar.async.NullCallback)1 LocalDate (com.bedatadriven.rebar.time.calendar.LocalDate)1 BaseListLoadResult (com.extjs.gxt.ui.client.data.BaseListLoadResult)1 TreeStore (com.extjs.gxt.ui.client.store.TreeStore)1