Caplin Trader 4.8.0

Class: module:caplin/alerts/testing/NotificationServiceStub

module:caplin/alerts/testing/NotificationServiceStub

A stub implementation of module:caplin/alerts/NotificationService 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/NotificationServiceStub()

Implements:
  • caplin/alerts/NotificationService

Methods

createNotification(source, timeCreated, additionalFields) → {module:caplin/alerts/Notification}

A stub method used for creating notifications.
Parameters:
Name Type Description
source String The source of the notification. This can be anything, but would generally be the name of the server side component that created the notification.
timeCreated Number Seconds since epoch that the notification was generated.
additionalFields Map A map of additional fields (names to values) for the notification.
Returns:
The created notification.
Type
module:caplin/alerts/Notification

dismiss(notification, erroropt, successopt)

Fires a DISMISS_REQUESTED event (see module:caplin/alerts/testing/NotificationServiceStubEvents) if the service status is AVAILABLE, or fires the error callback otherwise.
Parameters:
Name Type Attributes Description
notification module:caplin/alerts/Notification The notification to dismiss.
error function <optional>
A callback that will be invoked when the request fails.
success function <optional>
A callback that will be invoked when the request succeeds.
See:

dispose()

Disposes of any listeners and resources that were used by the service.

removeNotification(removedNotification)

A stub method used for removing notifications without having to respond to a request for a dismiss.
Parameters:
Name Type Description
removedNotification module:caplin/alerts/Notification The notification that has been removed.

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: