Caplin Trader 4.7.1

Class: module:caplin/alerts/testing/TriggerServiceStub

module:caplin/alerts/testing/TriggerServiceStub

A stub implementation of module:caplin/alerts/TriggerService used for testing. This class not only provides implementations for the service's interface methods, but also provides several methods for setting its internal state. This class uses module:caplin/services/testing/RequestStubs to simulate server requests.

Constructor

new module:caplin/alerts/testing/TriggerServiceStub()

Implements:
  • caplin/alerts/TriggerService

Methods

addTrigger(properties, {@link) → {module:caplin/alerts/Trigger}

A stub method used for adding triggers without having to respond to a request for creation.
Parameters:
Name Type Description
properties map The properties of the trigger being added.
Properties
Name Type Description
subject String The subject of the instrument to be monitored by the trigger.
condition String The condition that when met will trigger the trigger.
{@link module:caplin/alerts/TriggerStates} state The current state of the trigger.
Returns:
The added trigger.
Type
module:caplin/alerts/Trigger

create(properties, error, success)

Fires a CREATE_REQUESTED event (see module:caplin/alerts/testing/TriggerServiceStubEvents) if the service status is AVAILABLE, or fires the error callback otherwise.
Parameters:
Name Type Description
properties Map The properties of the trigger to be created.
Properties
Name Type Description
subject String The subject of the instrument to be monitored by the trigger.
condition String The condition that when met will trigger the trigger.
error function A callback that will be invoked if the request fails.
success function A callback that will be invoked when the request succeeds.
See:

disableTrigger(trigger, error, success)

Parameters:
Name Type Description
trigger module:caplin/alerts/Trigger The trigger to dispose.
error function A callback that will be invoked if the request fails.
success function A callback that will be invoked when the request succeeds.
See:

dispose(trigger, error, success)

Fires a DISPOSE_REQUESTED event (see module:caplin/alerts/testing/TriggerServiceStubEvents) if the service status is AVAILABLE, or fires the error callback otherwise.
Parameters:
Name Type Description
trigger module:caplin/alerts/Trigger The trigger to dispose.
error function A callback that will be invoked if the request fails.
success function A callback that will be invoked when the request succeeds.
See:

enableTrigger(trigger, error, success)

Parameters:
Name Type Description
trigger module:caplin/alerts/Trigger The trigger to dispose.
error function A callback that will be invoked if the request fails.
success function A callback that will be invoked when the request succeeds.
See:

removeTrigger(trigger)

A stub method used for removing triggers without having to respond to a request for disposal.
Parameters:
Name Type Description
trigger module:caplin/alerts/Trigger The removed trigger.

setStatus(status)

A stub method used to set the status of the service, representing the availability of its data
Parameters:
Name Type Description
status module:caplin/services/ServiceStatus The new status of the service.
See:

triggerTrigger(trigger)

A stub method used for triggering triggers. This is used to represent a trigger's condition having been met, and will set the trigger's state to TRIGGERED (see module:caplin/alerts/TriggerStates).
Parameters:
Name Type Description
trigger module:caplin/alerts/Trigger The triggered trigger.