Caplin Trader 5.1.0

Class: module:ct-alerts/testing/TriggerServiceStub

module:ct-alerts/testing/TriggerServiceStub()

A stub implementation of module:ct-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:ct-services/testing/RequestStubs to simulate server requests.

Constructor

new module:ct-alerts/testing/TriggerServiceStub()

Implements:
  • ct-alerts/TriggerService

Methods

addTrigger(properties, {@link) → {module:ct-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:ct-alerts/TriggerStates} state The current state of the trigger.

Returns:

The added trigger.

Type
module:ct-alerts/Trigger

create(properties, error, success)

Fires a CREATE_REQUESTED event (see module:ct-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:ct-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:ct-alerts/testing/TriggerServiceStubEvents) if the service status is AVAILABLE, or fires the error callback otherwise.

Parameters:
Name Type Description
trigger module:ct-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:ct-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:ct-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:ct-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:ct-alerts/TriggerStates).

Parameters:
Name Type Description
trigger module:ct-alerts/Trigger

The triggered trigger.