Class
caplin.trading.testing

TradeMessageServiceStub

A TradeSubscribeStub stubs out a caplin.trading.trademodel.TradeMessageService instance for the purpose of testing trades and trading components in acceptance tests and workbenches. The TradeMessageServiceStub mocks out a subscription for only one trade, as only one is typically required in a test or in a component's workbench.

Constructor Summary

Attributes Name and Description
caplin.trading.testing.TradeMessageServiceStub()

Constructs an instance of caplin.trading.testing.TradeMessageServiceStub.

Method Summary

Attributes Name and Description
void addEventLogger(Function fLogger)

This method registers an event logging function with this mock TradeMessageService.

void addTrade(caplin.trading.trademodel.Trade oTrade)

Assigns the trade as the subscriber to mocked trade messages.

void receiveServerTradeEvent(String sEventName, Map mData, sTradeID)

This method is called by a mock trade server to simulate the receipt of a trade event from Liberator via SL4B.

void receiveTradeChannelStatusChange(boolean bEnabled)

This method is called by a mock trade server to simulate a channel status change of the trade subscriber.

void removeTrade(caplin.trading.trademodel.Trade oTrade)

Unregisters the trade subscribed to mocked trade messages.

void sendTradeEvent(String sEventName, caplin.trading.trademodel.Trade oTrade, caplin.trading.trademodel.DataHolder oData)

This method is called by a caplin.trading.trademodel.Trade to simulate the sending of a trade event to Liberator via SL4B.

Constructor Detail

caplin.trading.testing.TradeMessageServiceStub()

Constructs an instance of caplin.trading.testing.TradeMessageServiceStub.

Method Detail

void addEventLogger(Function fLogger)

This method registers an event logging function with this mock TradeMessageService. This function is called for all events Events being "sent" by a trade and "received" from a server mock. A component workbench or a mock server will typically register a logger in order to display or be informed of the mocked trade events. Callback functions must handle the following 3 parameters:

  • the event name (String)
  • the direction of the event (eg. send/ receive) (String)
  • the event data (Map)
    • Parameters
      Function fLogger the callback function to log mock trade events

void addTrade(caplin.trading.trademodel.Trade oTrade)

Assigns the trade as the subscriber to mocked trade messages.

Parameters
caplin.trading.trademodel.Trade oTrade the trade object.

void receiveServerTradeEvent(String sEventName, Map mData, sTradeID)

This method is called by a mock trade server to simulate the receipt of a trade event from Liberator via SL4B. The event is propagated to the Trade subscribed via this mock trade subscriber. This stub will print out the message to a logger if one has been defined.

Parameters
String sEventName the event name that is being received from the server
Map mData the data being received for this event
sTradeID

void receiveTradeChannelStatusChange(boolean bEnabled)

This method is called by a mock trade server to simulate a channel status change of the trade subscriber. The change event is propagated to the Trade subscribed via this mock trade subscriber. The new subscriber status will be printed to a logger if one has been defined.

Parameters
boolean bEnabled the new trading status received

void removeTrade(caplin.trading.trademodel.Trade oTrade)

Unregisters the trade subscribed to mocked trade messages.

Parameters
caplin.trading.trademodel.Trade oTrade the trade object.

void sendTradeEvent(String sEventName, caplin.trading.trademodel.Trade oTrade, caplin.trading.trademodel.DataHolder oData)

This method is called by a caplin.trading.trademodel.Trade to simulate the sending of a trade event to Liberator via SL4B. This stub will print out the message to a logger if one has been defined.

Parameters
String sEventName the event name that is being sent to the server.
caplin.trading.trademodel.Trade oTrade the trade object.
caplin.trading.trademodel.DataHolder oData the data being sent with this event.