new module:ct-services /testing /Message Service Stub()
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
add Data Generator(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 |
The data generator. |
add Subject Prefix Data(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. |
clear Data Subscribers()
- Deprecated:
- Use
module:ct-services/testing/MessageServiceStub#reset
instead.
- Use
dispose()
Disposes of any listeners and resources that were used by the service.
get Record Stub(subject) → {module:ct-services /testing /Record Stub}
Gets the module:ct-services/testing/RecordStub
for the given subject.
Parameters:
Name | Type | Description |
---|---|---|
subject |
String | The subject of the |
Returns:
get Record Stubs() → {Map}
Gets a map of all module:ct-services/testing/RecordStub
s.
Returns:
- Type
- Map
invoke Send Data ToListener OnData Subscribers()
- Deprecated:
on Subscription Disposed() → {module:ct-services /messaging /Subscription}
Notifies this MessageService that a subscription has been disposed of.
Returns:
The subscription that's been disposed of
publish()
This stub does not handle contribs
publish Session Message()
This stub does not handle session messages
reset()
Resets the stub, clearing all records, data generators and subject prefix mappings.
subscribe() → {module:ct-services /testing /Subscription Stub}
- Implements:
- See:
-
- ct-services/messaging/MessageService#subscribe
Returns:
update Subject Data(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. |