Caplin Trader 4.8.0

Class: module:caplin/services/testing/MessageServiceStub

module:caplin/services/testing/MessageServiceStub

Constructor

new module:caplin/services/testing/MessageServiceStub()

Constructs a caplin.services.testing.MessageServiceStub.

A stub implementation of module:caplin/services/messaging/MessageService for use in tests and workbenches.

This class uses emitr.

Implements:

Members

(static) EVENTS

A map of events that this class may trigger.

Contains the following events:

RECORD_CREATED
Triggered when some of the record's field data has changed.
PARAMETERS
module:caplin/services/testing/RecordStub record The newly created record.

Methods

addDataGenerator(generator)

Adds a data generator that will be used to generate field data for all records. Each record's initial values will be used as seeds for the generated values.
Parameters:
Name Type Description
generator module:caplin/workbench/model/DataGenerator The data generator.

addSubjectPrefixData(prefix, data)

Sets initial data for all records that have a subject starting with the given prefix. This does not affect already existing records.
Parameters:
Name Type Description
prefix String The subject prefix of records that should be initialised with the data.
data Object The initial data for matching records.

clearDataSubscribers()

Deprecated:

getRecordStub(subject) → {module:caplin/services/testing/RecordStub}

Gets the module:caplin/services/testing/RecordStub for the given subject.
Parameters:
Name Type Description
subject String The subject of the RecordStub to get.
Returns:
Type
module:caplin/services/testing/RecordStub

getRecordStubs() → {Map}

Returns:
Type
Map

invokeSendDataToListenerOnDataSubscribers()

Deprecated:

publish()

This stub does not handle contribs
Implements:

publishSessionMessage()

This stub does not handle session messages
Implements:

reset()

Resets the stub, clearing all records, data generators and subject prefix mappings.

subscribe() → {module:caplin/services/testing/SubscriptionStub}

Implements:
See:
  • caplin/services/messaging/MessageService#subscribe
Returns:
Type
module:caplin/services/testing/SubscriptionStub

updateSubjectData(subject, data)

Updates field data for a record, which then notifies all of its subscriptions of the change.
Parameters:
Name Type Description
subject String The subject of the record to be updated.
data Object The new field data for the record.