com.espertech.esper.client.scopetest
Class SupportUpdateListener

java.lang.Object
  extended by com.espertech.esper.client.scopetest.SupportUpdateListener
All Implemented Interfaces:
UpdateListener

public class SupportUpdateListener
extends java.lang.Object
implements UpdateListener

Update listener that retains the events it receives for use in assertions.


Constructor Summary
SupportUpdateListener()
          Ctor.
 
Method Summary
 UniformPair<EventBean[]> assertInvokedAndReset()
          Returns a pair of insert and remove stream event arrays considering the last invocation only, asserting that only a single invocation occured, and resetting the listener.
 EventBean assertOneGetNew()
          Asserts that exactly one insert stream event was received not checking remove stream data, and returns the received event.
 EventBean assertOneGetNewAndReset()
          Asserts that exactly one insert stream event was received and no remove stream events, resets the listener clearing all state and returns the received event.
 EventBean assertOneGetOld()
          Asserts that exactly one remove stream event was received not checking insert stream data, and returns the received event.
 EventBean assertOneGetOldAndReset()
          Asserts that exactly one remove stream event was received and no insert stream events, resets the listener clearing all state and returns the received event.
 UniformPair<EventBean> assertPairGetIRAndReset()
          Asserts that exactly one insert stream event and exactly one remove stream event was received, resets the listener clearing all state and returns the received events as a pair.
 boolean getAndClearIsInvoked()
          Returns true if the listener was invoked at least once and clears the invocation flag.
 UniformPair<EventBean[]> getAndResetDataListsFlattened()
          Returns a pair of insert and remove stream event arrays considering the all invocations, and resets the listener.
 EventBean[] getAndResetLastNewData()
          Returns the last array of events (insert stream) that were received and resets the listener.
 EventBean[] getAndResetLastOldData()
          Returns the last array of events (insert stream) that were received and resets the listener.
 UniformPair<EventBean[]> getDataListsFlattened()
          Returns a pair of insert and remove stream event arrays considering the all invocations.
 EventBean[] getLastNewData()
          Returns the last array of events (insert stream) that were received.
 EventBean[] getLastOldData()
          Returns the last array of remove-stream events that were received.
 java.util.List<EventBean[]> getNewDataList()
          Get a list of all insert-stream event arrays received.
 EventBean[] getNewDataListFlattened()
          Returns an event array that represents all insert-stream events received so far.
 java.util.List<EventBean[]> getOldDataList()
          Get a list of all remove-stream event arrays received.
 EventBean[] getOldDataListFlattened()
          Returns an event array that represents all remove-stream events received so far.
 boolean isInvoked()
          Returns true if the listener was invoked at least once.
 void reset()
          Reset listener, clearing all associated state.
 void setLastNewData(EventBean[] lastNewData)
          Set an array of events as the last insert-stream events received.
 void setLastOldData(EventBean[] lastOldData)
          Set an array of events as the last remove-stream events received.
 void update(EventBean[] newData, EventBean[] oldData)
          Notify that new events are available or old events are removed.
 void waitForInvocation(long msecWait)
          Wait for the listener invocation for up to the given number of milliseconds.
 void waitForInvocation(long msecWait, int numberOfNewEvents)
          Wait for the listener invocation for up to the given number of milliseconds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SupportUpdateListener

public SupportUpdateListener()
Ctor.

Method Detail

waitForInvocation

public void waitForInvocation(long msecWait)
Wait for the listener invocation for up to the given number of milliseconds.

Parameters:
msecWait - to wait
Throws:
java.lang.RuntimeException - when no results were received

waitForInvocation

public void waitForInvocation(long msecWait,
                              int numberOfNewEvents)
Wait for the listener invocation for up to the given number of milliseconds.

Parameters:
msecWait - to wait
numberOfNewEvents - in any number of separate invocations required before returning
Throws:
java.lang.RuntimeException - when no results or insufficient number of events were received

update

public void update(EventBean[] newData,
                   EventBean[] oldData)
Description copied from interface: UpdateListener
Notify that new events are available or old events are removed. If the call to update contains new (inserted) events, then the first argument will be a non-empty list and the second will be empty. Similarly, if the call is a notification of deleted events, then the first argument will be empty and the second will be non-empty. Either the newEvents or oldEvents will be non-null. This method won't be called with both arguments being null (unless using output rate limiting or force-output options), but either one could be null. The same is true for zero-length arrays. Either newEvents or oldEvents will be non-empty. If both are non-empty, then the update is a modification notification.

Specified by:
update in interface UpdateListener
Parameters:
newData - is any new events. This will be null or empty if the update is for old events only.
oldData - is any old events. This will be null or empty if the update is for new events only.

reset

public void reset()
Reset listener, clearing all associated state.


getLastNewData

public EventBean[] getLastNewData()
Returns the last array of events (insert stream) that were received.

Returns:
insert stream events or null if either a null value was received or when no events have been received since the last reset

getLastOldData

public EventBean[] getLastOldData()
Returns the last array of remove-stream events that were received.

Returns:
remove stream events or null if either a null value was received or when no events have been received since the last reset

getAndResetLastNewData

public EventBean[] getAndResetLastNewData()
Returns the last array of events (insert stream) that were received and resets the listener.

Returns:
insert stream events or null if either a null value was received or when no events have been received since the last reset

getAndResetLastOldData

public EventBean[] getAndResetLastOldData()
Returns the last array of events (insert stream) that were received and resets the listener.

Returns:
insert stream events or null if either a null value was received or when no events have been received since the last reset

assertOneGetNewAndReset

public EventBean assertOneGetNewAndReset()
Asserts that exactly one insert stream event was received and no remove stream events, resets the listener clearing all state and returns the received event.

Returns:
single insert-stream event

assertOneGetOldAndReset

public EventBean assertOneGetOldAndReset()
Asserts that exactly one remove stream event was received and no insert stream events, resets the listener clearing all state and returns the received event.

Returns:
single remove-stream event

assertPairGetIRAndReset

public UniformPair<EventBean> assertPairGetIRAndReset()
Asserts that exactly one insert stream event and exactly one remove stream event was received, resets the listener clearing all state and returns the received events as a pair.

Returns:
pair of insert-stream and remove-stream events

assertOneGetNew

public EventBean assertOneGetNew()
Asserts that exactly one insert stream event was received not checking remove stream data, and returns the received event.

Returns:
single insert-stream event

assertOneGetOld

public EventBean assertOneGetOld()
Asserts that exactly one remove stream event was received not checking insert stream data, and returns the received event.

Returns:
single remove-stream event

getNewDataList

public java.util.List<EventBean[]> getNewDataList()
Get a list of all insert-stream event arrays received.

Returns:
list of event arrays

getOldDataList

public java.util.List<EventBean[]> getOldDataList()
Get a list of all remove-stream event arrays received.

Returns:
list of event arrays

isInvoked

public boolean isInvoked()
Returns true if the listener was invoked at least once.

Returns:
invoked flag

getAndClearIsInvoked

public boolean getAndClearIsInvoked()
Returns true if the listener was invoked at least once and clears the invocation flag.

Returns:
invoked flag

setLastNewData

public void setLastNewData(EventBean[] lastNewData)
Set an array of events as the last insert-stream events received.

Parameters:
lastNewData - to store

setLastOldData

public void setLastOldData(EventBean[] lastOldData)
Set an array of events as the last remove-stream events received.

Parameters:
lastOldData - to store

getNewDataListFlattened

public EventBean[] getNewDataListFlattened()
Returns an event array that represents all insert-stream events received so far.

Returns:
event array

getOldDataListFlattened

public EventBean[] getOldDataListFlattened()
Returns an event array that represents all remove-stream events received so far.

Returns:
event array

assertInvokedAndReset

public UniformPair<EventBean[]> assertInvokedAndReset()
Returns a pair of insert and remove stream event arrays considering the last invocation only, asserting that only a single invocation occured, and resetting the listener.

Returns:
pair of event arrays, the first in the pair is the insert stream data, the second in the pair is the remove stream data

getDataListsFlattened

public UniformPair<EventBean[]> getDataListsFlattened()
Returns a pair of insert and remove stream event arrays considering the all invocations.

Returns:
pair of event arrays, the first in the pair is the insert stream data, the second in the pair is the remove stream data

getAndResetDataListsFlattened

public UniformPair<EventBean[]> getAndResetDataListsFlattened()
Returns a pair of insert and remove stream event arrays considering the all invocations, and resets the listener.

Returns:
pair of event arrays, the first in the pair is the insert stream data, the second in the pair is the remove stream data

© 2006-2014 EsperTech Inc.
All rights reserved.
Visit us at espertech.com