Class
caplin.services.testing

RecordStub

Constructor Summary

Attributes Name and Description
caplin.services.testing.RecordStub(String subject, Object initialFieldData, Array generators)

Created by caplin.services.testing.MessageServiceStub as a representation of a record that can be subscribed to.

Field Summary

Attributes Name and Description
<static> caplin.services.testing.RecordStub.EVENTS

A map of events that this class may trigger.

Method Summary

Attributes Name and Description
void addDataGenerator(caplin.workbench.model.DataGenerator generatorToAdd)

Adds a caplin.workbench.model.DataGenerator to this record, which will then be used to auto-generate data updates, using the record's initial values as seeds.

void clearUpdateInterval()

Stops this record from providing automatic updates.

Map getFieldData()

Gets a map of all the record's fields and their values.

Number getPausedSubscriptionCount()

Returns the number of paused subscriptions there are for this record.

caplin.services.messaging.SubscriptionStatus getStatus()

Gets the current status of the record.

String getSubject()

Gets the subject that maps to this record.

Number getSubscriptionCount()

Returns the number of subscriptions there are for this record.

void removeDataGenerator(caplin.workbench.model.DataGenerator generatorToRemove)

void setErrorType(@link caplin.services.messaging.SubscriptionError errorType)

Sets the error type of this record, and then informs all listeners of the change.

void setFieldData(Map dataUpdates)

Sets new values for fields on this record, and then informs all subscribers of the change.

void setStatus(caplin.services.messaging.SubscriptionStatus status)

Sets the status of the record {@see caplin.services.messaging.SubscriptionStatus}.

void setUpdateInterval(Number intervalPeriod)

Sets the update rate of generated data for this record {@see caplin.services.testing.RecordStub#addDataGenerator}.

Constructor Detail

caplin.services.testing.RecordStub(String subject, Object initialFieldData, Array generators)

Created by caplin.services.testing.MessageServiceStub as a representation of a record that can be subscribed to. Used to send updated field data to subscribers, and to monitor the number of subscriptions made for the record's subject.

This class uses emitr.

Parameters
String subject The subject for this record
Object initialFieldData Data fields that will be sent to component when it subscribes. If provided, these will also be editable by user in workbench tool.
Array generators List of data generators.

Field Detail

<static> caplin.services.testing.RecordStub.EVENTS

A map of events that this class may trigger.

Contains the following events:

DATA_CHANGED
Triggered when some of the record's field data has changed.
PARAMETERS
{Map} updatedFields A map of field names to their new values.
STATUS_CHANGED
Triggered when the record's status has changed.
SUBSCRIPTIONS_CHANGED
Triggered when a record stub's number of all subscriptions, or number of paused subscriptions changes.
PARAMETERS
caplin.services.testing.RecordStub record The record stub that fired the event.
ERROR
Triggered when the record stub is put into an error state.
PARAMETERS
caplin.services.messaging.SubscriptionError type The error type.

Method Detail

void addDataGenerator(caplin.workbench.model.DataGenerator generatorToAdd)

Adds a caplin.workbench.model.DataGenerator to this record, which will then be used to auto-generate data updates, using the record's initial values as seeds. The update rate can be set using caplin.services.testing.RecordStub#setUpdateInterval.

Parameters
caplin.workbench.model.DataGenerator generatorToAdd The data generator that should be used to generate auto updates for this record.

void clearUpdateInterval()

Stops this record from providing automatic updates.

Map getFieldData()

Gets a map of all the record's fields and their values.

Returns
{Map} A map of all field data for this record.

Number getPausedSubscriptionCount()

Returns the number of paused subscriptions there are for this record.

Returns
{Number} The number of paused subscriptions for this record.

caplin.services.messaging.SubscriptionStatus getStatus()

Gets the current status of the record.

Returns
{caplin.services.messaging.SubscriptionStatus} The current status of the record.

String getSubject()

Gets the subject that maps to this record.

Returns
{String} The subject of the record.

Number getSubscriptionCount()

Returns the number of subscriptions there are for this record. This includes both active and paused subscriptions.

Returns
{Number} the number of subscriptions for this record.

void removeDataGenerator(caplin.workbench.model.DataGenerator generatorToRemove)

Parameters
caplin.workbench.model.DataGenerator generatorToRemove The data generator that should no longer be used to generate auto updates for this record.

void setErrorType(@link caplin.services.messaging.SubscriptionError errorType)

Sets the error type of this record, and then informs all listeners of the change.

Parameters
@link caplin.services.messaging.SubscriptionError errorType The type of error that this record is in.

void setFieldData(Map dataUpdates)

Sets new values for fields on this record, and then informs all subscribers of the change.

Parameters
Map dataUpdates A map of new field values.

void setStatus(caplin.services.messaging.SubscriptionStatus status)

Sets the status of the record {@see caplin.services.messaging.SubscriptionStatus}.

Parameters
caplin.services.messaging.SubscriptionStatus status The new status of this record.

void setUpdateInterval(Number intervalPeriod)

Sets the update rate of generated data for this record {@see caplin.services.testing.RecordStub#addDataGenerator}.

Parameters
Number intervalPeriod The time in milliseconds between auto-generated data updates for this record.