Caplin Trader 5.1.0

Class: module:ct-services/testing/MessageServiceStub

module:ct-services/testing/MessageServiceStub()

new module:ct-services/testing/MessageServiceStub()

Constructs a MessageServiceStub.

A stub implementation of module:ct-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:ct-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:ct-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:

dispose()

Disposes of any listeners and resources that were used by the service.

Implements:

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

Gets the module:ct-services/testing/RecordStub for the given subject.

Parameters:
Name Type Description
subject String

The subject of the RecordStub to get.

Returns:
Type
module:ct-services/testing/RecordStub

getRecordStubs() → {Map}

Returns:
Type
Map

invokeSendDataToListenerOnDataSubscribers()

Deprecated:

onSubscriptionDisposed() → {module:ct-services/messaging/Subscription}

Notifies this MessageService that a subscription has been disposed of.

Implements:
Returns:

The subscription that's been disposed of

Type
module:ct-services/messaging/Subscription

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:ct-services/testing/SubscriptionStub}

Implements:
See:
  • ct-services/messaging/MessageService#subscribe
Returns:
Type
module:ct-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.