Caplin Trader 5.1.0

Class: module:ct-watchlist/testing/WatchlistServiceStub

module:ct-watchlist/testing/WatchlistServiceStub()

Stub implementation of module:ct-watchlist/Watchlist 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-watchlist/testing/WatchlistServiceStub()

Implements:
  • ct-watchlist/WatchlistService

Methods

addWatchlist(properties) → {module:ct-watchlist/Watchlist}

A stub method used for adding watchlists without having to respond to a request for creation. This can be used to simulate watchlists being created on a different device.

Parameters:
Name Type Description
properties map

The properties of the watchlist being added.

Returns:

The added watchlist.

Type
module:ct-watchlist/Watchlist

create(name, error, success)

Fires a CREATE_REQUESTED event (see module:ct-watchlist/testing/WatchlistServiceStubEvents) if the service status is AVAILABLE, or fires the error callback otherwise.

Parameters:
Name Type Description
name String

The name of the watchlist to be created.

error function

A callback that will be invoked if the request fails.

success function

A callback that will be invoked when the request succeeds.

Implements:
See:

dispose(watchlists, error, success)

Fires a DISPOSE_REQUESTED event (see module:ct-watchlist/testing/WatchlistServiceStubEvents) if the service status is AVAILABLE, or fires the error callback otherwise.

Parameters:
Name Type Description
watchlists Array.<module:ct-watchlist/Watchlist>

The watchlists to dispose of.

error function

A callback that will be invoked if the request fails.

success function

A callback that will be invoked when the request succeeds.

Implements:
See:

getById()

Implements:

getContentsManager()

See:

getId()

See:

getName()

See:

getSubject()

See:

getWatchlistCount()

Implements:

getWatchlists()

Implements:

propertyChanged(name, value)

Stub method to change the value of one of this watchlist's properties.

Parameters:
Name Type Description
name

The name of the property to change.

value

The new value for the changed property.

removeWatchlist(watchlist)

A stub method used for removing watchlists without having to respond to a request for disposal. This can be used to simulate watchlists being removed on a different device.

Parameters:
Name Type Description
watchlist module:ct-watchlist/Watchlist

The removed watchlist.

setName()

See:

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:

subjectsAdded(subjects)

Stub method to add subjects to this watchlist.

Parameters:
Name Type Description
subjects array

The subjects to add to this watchlist.

subjectsRemoved(subjects)

Stub method to remove subjects from this watchlist.

Parameters:
Name Type Description
subjects array

The subjects to remove from this watchlist.

module:ct-watchlist/testing/WatchlistServiceStub()

Stub implementation of module:ct-watchlist/WatchlistService 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-watchlist/testing/WatchlistServiceStub()

Implements:

Methods

addWatchlist(properties) → {module:ct-watchlist/Watchlist}

A stub method used for adding watchlists without having to respond to a request for creation. This can be used to simulate watchlists being created on a different device.

Parameters:
Name Type Description
properties map

The properties of the watchlist being added.

Returns:

The added watchlist.

Type
module:ct-watchlist/Watchlist

create(name, error, success)

Fires a CREATE_REQUESTED event (see module:ct-watchlist/testing/WatchlistServiceStubEvents) if the service status is AVAILABLE, or fires the error callback otherwise.

Parameters:
Name Type Description
name String

The name of the watchlist to be created.

error function

A callback that will be invoked if the request fails.

success function

A callback that will be invoked when the request succeeds.

Implements:
See:

dispose(watchlists, error, success)

Fires a DISPOSE_REQUESTED event (see module:ct-watchlist/testing/WatchlistServiceStubEvents) if the service status is AVAILABLE, or fires the error callback otherwise.

Parameters:
Name Type Description
watchlists Array.<module:ct-watchlist/Watchlist>

The watchlists to dispose of.

error function

A callback that will be invoked if the request fails.

success function

A callback that will be invoked when the request succeeds.

Implements:
See:

getById()

Implements:

getContentsManager()

See:

getId()

See:

getName()

See:

getSubject()

See:

getWatchlistCount()

Implements:

getWatchlists()

Implements:

propertyChanged(name, value)

Stub method to change the value of one of this watchlist's properties.

Parameters:
Name Type Description
name

The name of the property to change.

value

The new value for the changed property.

removeWatchlist(watchlist)

A stub method used for removing watchlists without having to respond to a request for disposal. This can be used to simulate watchlists being removed on a different device.

Parameters:
Name Type Description
watchlist module:ct-watchlist/Watchlist

The removed watchlist.

setName()

See:

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:

subjectsAdded(subjects)

Stub method to add subjects to this watchlist.

Parameters:
Name Type Description
subjects array

The subjects to add to this watchlist.

subjectsRemoved(subjects)

Stub method to remove subjects from this watchlist.

Parameters:
Name Type Description
subjects array

The subjects to remove from this watchlist.