Caplin Trader 4.7.1

Class: module:caplin/trading/testing/TradeMessageServiceStub

module:caplin/trading/testing/TradeMessageServiceStub

Constructor

new module:caplin/trading/testing/TradeMessageServiceStub()

Constructs an instance of caplin.trading.testing.TradeMessageServiceStub. A TradeSubscribeStub stubs out a module: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.
Implements:

Methods

addEventLogger(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:
    Name Type Description
    fLogger function the callback function to log mock trade events

    addTrade(oTrade)

    Assigns the trade as the subscriber to mocked trade messages.
    Parameters:
    Name Type Description
    oTrade module:caplin/trading/trademodel/Trade the trade object.
    Implements:

    receiveServerTradeEvent(sEventName, mData)

    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:
    Name Type Description
    sEventName String the event name that is being received from the server
    mData Map the data being received for this event

    receiveTradeChannelStatusChange(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:
    Name Type Description
    bEnabled boolean the new trading status received

    removeTrade(oTrade)

    Unregisters the trade subscribed to mocked trade messages.
    Parameters:
    Name Type Description
    oTrade module:caplin/trading/trademodel/Trade the trade object.
    Implements:

    sendTradeEvent(sEventName, oTrade, oData)

    This method is called by a module: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:
    Name Type Description
    sEventName String the event name that is being sent to the server.
    oTrade module:caplin/trading/trademodel/Trade the trade object.
    oData module:caplin/trading/trademodel/DataHolder the data being sent with this event.
    Implements: