Class
caplin.services.testing

ConnectionServiceStub

The ConnectionServiceStub serves to create a stub for a ConnectionService to enable tests to simulate connection status changes.

Constructor Summary

Attributes Name and Description
caplin.services.testing.ConnectionServiceStub(Object oStreamLink, String sInitialState)

Constructs a caplin.services.testing.ConnectionServiceStub.

Method Summary

Attributes Name and Description
void addStatusChangedListener(Function fCallback)

Add a function as listener to connection status changes.

void getAvailableStates()

Returns the states the ConnectionServiceStub can be in.

void getCurrentState()

Returns the current ConnectionServiceStub connection state

void getStreamlink()

Return Streamlink instance.

void getValidTransitions(String The)

Returns the available states that can be transitioned from the state given.

void removeStatusChangedListener(Function fCallback)

Remove a function as listener to connection status changes.

void setState(String sNewState)

Sets a connection state from the available ones ('OK', 'ERROR', 'PARTIAL', 'DOWN') and notifies the listeners of a connection status change.

void updateStatus(String sCallback, Array pReasons)

Notify connection service listeners that the connection status has changed.

Methods implemented from class caplin.services.ConnectionService:
connect, disconnect

Constructor Detail

caplin.services.testing.ConnectionServiceStub(Object oStreamLink, String sInitialState)

Constructs a caplin.services.testing.ConnectionServiceStub.

Parameters
Object oStreamLink Streamlink instance to be used, this parameter is optional.
String sInitialState Initial state for the ConnectionServiceStub, this parameter is optional.

Method Detail

void addStatusChangedListener(Function fCallback)

Add a function as listener to connection status changes.

Parameters
Function fCallback The callback that is used to notify of connection status changes.

void getAvailableStates()

Returns the states the ConnectionServiceStub can be in.

void getCurrentState()

Returns the current ConnectionServiceStub connection state

void getValidTransitions(String The)

Returns the available states that can be transitioned from the state given. If no state is given it will return the available transitions from the current state.

Parameters
String The state from which we want to know the transitions

void removeStatusChangedListener(Function fCallback)

Remove a function as listener to connection status changes.

Parameters
Function fCallback The callback that is used to notify of connection status changes.

void setState(String sNewState)

Sets a connection state from the available ones ('OK', 'ERROR', 'PARTIAL', 'DOWN') and notifies the listeners of a connection status change.

Parameters
String sNewState The new state to be set

void updateStatus(String sCallback, Array pReasons)

Notify connection service listeners that the connection status has changed.

Parameters
String sCallback The name of the callback function to be triggered in the ConnectionServiceListeners (e.g. 'onConnectionAvailable' or 'onConnectionUnavailable').
Array pReasons The reason for the change in connection status.