Class
caplin.trading.testing

TradeMessageFixture

The TradeMessageFixture serves to create a context for testing trade interactions, through the use of a trade subscriber mock object.

Tests may use the TradeMessageFixture to:

  • trigger mock server events:
    given(PM is in state A)
    when("trade.eventReceived => 'ExecuteAck|TRADE_CONF_EXECUTE_DATA'")
    then(PM is in state B)
  • trigger mock server's trading status changes:
    given(PM is in state A)
    when("trade.statusEnabled => false")
    then(PM is in state B)
  • verify that a trade object has sent the expected event:
    given(PM is in state A)
    when (execute button is pressed)
    then ("trade.eventSent = 'Execute|TRADE_EXECUTE_DATA'")

Constructor Summary

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

Constructs a caplin.trading.testing.TradeMessageFixture.

Method Summary

Attributes Name and Description
void addNamedValueMap(String sName, Map mValues)

This method enables a FixtureFactory to register a set of record identifiers and corresponding map of mock record field data with this TradeMessageFixture.

void canHandleProperty( sProperty)

TradeMessageFixture handles properties 'eventReceived', 'eventSent' and 'statusEnabled'.

void doGiven(String sPropertyName, Variant vValue)

This method can be used with the 'eventReceived' or 'statusEnabled' properties to trigger the stub to simulate these events being received from the server.

void doThen(String sPropertyName, Variant vValue)

This method can be used to check whether the last trade event 'sent' by the trading stub was the one expected.

void doWhen(String sPropertyName, Variant vValue)

This method can be used with the 'eventReceived' or 'statusEnabled' properties to trigger the stub to simulate these events being received from the server.

void setTradeMessageServiceStub(caplin.trading.testing.TradeMessageServiceStub oTradeMessageServiceStub)

Sets a TradeMessageServiceStub to be used by this fixture to simulate trade events.

Methods implemented from class caplin.testing.Fixture:
addSubFixtures, setUp, tearDown

Constructor Detail

caplin.trading.testing.TradeMessageFixture()

Constructs a caplin.trading.testing.TradeMessageFixture.

Method Detail

void addNamedValueMap(String sName, Map mValues)

This method enables a FixtureFactory to register a set of record identifiers and corresponding map of mock record field data with this TradeMessageFixture. Tests using the fixture to receive mock messages or verify events sent by the trade are able to refer to record data using property value '|'.

Parameters
String sName the record identifier.
Map mValues the record data map from field data to field value.

void canHandleProperty( sProperty)

TradeMessageFixture handles properties 'eventReceived', 'eventSent' and 'statusEnabled'.

Parameters
sProperty
See
caplin.testing.Fixture#canHandleProperty

void doGiven(String sPropertyName, Variant vValue)

This method can be used with the 'eventReceived' or 'statusEnabled' properties to trigger the stub to simulate these events being received from the server. The 'eventReceived' property must be supplied with a trade event name and optional data map id, in the format NAME|DATA, where DATA is the key for one of the name-value pairs already supplied (caplin.trading.testing.TradeMessageFixture.addNamedValueMap).

Parameters
String sPropertyName The property name
Variant vValue The value to check
See
caplin.testing.Fixture#doGiven

void doThen(String sPropertyName, Variant vValue)

This method can be used to check whether the last trade event 'sent' by the trading stub was the one expected. This method must be used with the property name 'eventSent', while the value is the event name and data expected in the format NAME|DATA.

Parameters
String sPropertyName The property name
Variant vValue The value to set
See
caplin.testing.Fixture#doThen

void doWhen(String sPropertyName, Variant vValue)

This method can be used with the 'eventReceived' or 'statusEnabled' properties to trigger the stub to simulate these events being received from the server.

Parameters
String sPropertyName The property name
Variant vValue The value to set
See
caplin.testing.Fixture#doWhen

void setTradeMessageServiceStub(caplin.trading.testing.TradeMessageServiceStub oTradeMessageServiceStub)

Sets a TradeMessageServiceStub to be used by this fixture to simulate trade events.

Parameters
caplin.trading.testing.TradeMessageServiceStub oTradeMessageServiceStub the trade subscriber stub.