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())));
}
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);
}
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);
}
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);
}
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);
}
Aggregations