Package com.streambase.sb.unittest
Class Expecter
- java.lang.Object
-
- com.streambase.sb.unittest.Expecter
-
public class Expecter extends Object
- Since:
- 6.6
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classExpecter.AbstractPredicateSubclass this and override isExpected(Tuple t) to simplify creating predicates.static classExpecter.DequeueSettingDequeue settingsstatic interfaceExpecter.PredicateTo expect tuples by predicate, implement this interface.
-
Constructor Summary
Constructors Constructor Description Expecter(Dequeuer stream)ConstructorExpecter(Dequeuer stream, TupleComparator comparator)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexpect(Tuple tuple)Expect a tuple from the dequeuer.voidexpect(Tuple... tuples)Expect multiple tuples in a particular order from the dequeuer.voidexpect(Expecter.DequeueSetting mode, Tuple expected)Expect a given tuple from the dequeuervoidexpect(Expecter.DequeueSetting mode, Tuple... tuples)Expect multiple tuples in a particular order from the dequeuer<T> voidexpect(Expecter.DequeueSetting mode, TupleMaker<T> tupleMaker, List<T> t)Expect a tuple from the dequeuer<T> voidexpect(Expecter.DequeueSetting mode, TupleMaker<T> tupleMaker, T t)Expect a tuple from the dequeuer<T> voidexpect(Expecter.DequeueSetting mode, TupleMaker<T> tupleMaker, T... t)Expect a tuple from the dequeuervoidexpect(Expecter.DequeueSetting mode, List<Tuple> expected)Expect multiple tuples in a particular order from the dequeuer<T> voidexpect(TupleMaker<T> tupleMaker, List<T> t)Expect multiple tuples in a particular order from the dequeuer.<T> voidexpect(TupleMaker<T> tupleMaker, T t)Expect a tuple from the dequeuer.<T> voidexpect(TupleMaker<T> tupleMaker, T... t)Expect multiple tuples in a particular order from the dequeuer.voidexpect(List<Tuple> expected)Expect multiple tuples in a particular order from the dequeuer.voidexpectNothing()Expect no tuples to be available on the stream, while ensuring that the server has time to process any tuples that are currently in flight.voidexpectNothing(long time, TimeUnit unit)Expect no tuples to be available on the stream, while ensuring that the server has time to process any tuples that are currently in flight.voidexpectPredicate(Expecter.DequeueSetting mode, Expecter.Predicate p)Expect a tuple that fulfills the given predicate from the dequeuervoidexpectPredicate(Expecter.DequeueSetting mode, List<Expecter.Predicate> expected)Expect a number of tuples, each fulfilling one predicate in a list, from the DequeuervoidexpectUnordered(Tuple... expected)Expect multiple tuples in any order from the dequeuer.voidexpectUnordered(Expecter.DequeueSetting mode, Tuple... expected)Expect multiple tuples in any order from the dequeuer<T> voidexpectUnordered(Expecter.DequeueSetting mode, TupleMaker<T> tupleMaker, List<T> t)Expect multiple tuples in any order from the dequeuer<T> voidexpectUnordered(Expecter.DequeueSetting mode, TupleMaker<T> tupleMaker, T... t)Expect multiple tuples in any order from the dequeuervoidexpectUnordered(Expecter.DequeueSetting mode, List<Tuple> expected)Expect multiple tuples in any order from the dequeuer<T> voidexpectUnordered(TupleMaker<T> tupleMaker, List<T> t)Expect multiple tuples in any order from the dequeuer.<T> voidexpectUnordered(TupleMaker<T> tupleMaker, T... t)Expect multiple tuples in any order from the dequeuer.voidexpectUnordered(List<Tuple> expected)Expect multiple tuples in any order from the dequeuer.voidexpectUnorderedPredicate(Expecter.DequeueSetting mode, List<Expecter.Predicate> expected)Expect tuples that fulfill multiple predicates in any order from the dequeuerlonggetTimeout(TimeUnit unit)get the timeout that the expector will use for each call to expect*()voidsetTimeout(long time, TimeUnit unit)Set the timeout that the expector should assume for each call to expect*()
-
-
-
Constructor Detail
-
Expecter
public Expecter(Dequeuer stream)
Constructor- Parameters:
stream- Associate expecter with this stream
-
Expecter
public Expecter(Dequeuer stream, TupleComparator comparator)
Constructor- Parameters:
stream- Associate expecter with this streamcomparator- Comparator to use
-
-
Method Detail
-
setTimeout
public void setTimeout(long time, TimeUnit unit)Set the timeout that the expector should assume for each call to expect*()- Parameters:
time- Time valueunit- Time units
-
getTimeout
public long getTimeout(TimeUnit unit)
get the timeout that the expector will use for each call to expect*()- Parameters:
unit- the unit in which to return the result.- Returns:
- Timeout value in specified units
-
expect
public void expect(Expecter.DequeueSetting mode, Tuple expected) throws StreamBaseException
Expect a given tuple from the dequeuer- Parameters:
mode- whether to allow extra tuples or require the next tuple to match exactlyexpected- the tuple to expect- Throws:
StreamBaseException- if expected match does not arrive
-
expectPredicate
public void expectPredicate(Expecter.DequeueSetting mode, Expecter.Predicate p) throws StreamBaseException
Expect a tuple that fulfills the given predicate from the dequeuer- Parameters:
mode- whether to allow extra tuples or require the next tuple to match the predicatep- the predicate- Throws:
StreamBaseException- if expected match does not arrive
-
expect
public void expect(Tuple tuple) throws StreamBaseException
Expect a tuple from the dequeuer. Equivalent toexpect(DequeueSetting.DISALLOW_EXTRA_TUPLES, tuple);- Parameters:
tuple- Expected tuple- Throws:
StreamBaseException- if the next dequeued tuple does not match the expected tuple.
-
expect
public void expect(Expecter.DequeueSetting mode, List<Tuple> expected) throws StreamBaseException
Expect multiple tuples in a particular order from the dequeuer- Parameters:
mode- whether to allow extra tuples or require the tuples to match without intermediate tuplesexpected- the tuples to expect- Throws:
StreamBaseException- if the next dequeued tuple does not match the expected tuple.
-
expectPredicate
public void expectPredicate(Expecter.DequeueSetting mode, List<Expecter.Predicate> expected) throws StreamBaseException
Expect a number of tuples, each fulfilling one predicate in a list, from the Dequeuer- Parameters:
mode- whether to allow extra tuples or require the tuples to match without intermediate tuplesexpected- the predicates we expect the dequeued tuples to fulfill- Throws:
StreamBaseException- if the expected tuples do not arrive
-
expect
public void expect(List<Tuple> expected) throws StreamBaseException
Expect multiple tuples in a particular order from the dequeuer. Equivalent toexpect(DequeueSetting.DISALLOW_EXTRA_TUPLES, expected);- Parameters:
expected- List of expected tuples- Throws:
StreamBaseException- if the dequeued tuples do not match the expected tuples.
-
expect
public void expect(Expecter.DequeueSetting mode, Tuple... tuples) throws StreamBaseException
Expect multiple tuples in a particular order from the dequeuer- Parameters:
mode- whether to allow extra tuples or require the tuples to match without intermediate tuplestuples- Ordered expected tuples- Throws:
StreamBaseException- if the dequeued tuples do not match the expected tuples.
-
expect
public void expect(Tuple... tuples) throws StreamBaseException
Expect multiple tuples in a particular order from the dequeuer. Equivalent toexpect(DequeueSetting.DISALLOW_EXTRA_TUPLES, tuples);- Parameters:
tuples- Ordered expected tuples- Throws:
StreamBaseException- if the dequeued tuples do not match the expected tuples.
-
expect
public <T> void expect(Expecter.DequeueSetting mode, TupleMaker<T> tupleMaker, T t) throws StreamBaseException
Expect a tuple from the dequeuer- Parameters:
mode- whether to allow extra tuples or require the tuples to match without intermediate tuplestupleMaker- Tuple factoryt- Tuple to expect- Throws:
StreamBaseException- if the next dequeued tuple does not match the expected tuple.
-
expect
public <T> void expect(TupleMaker<T> tupleMaker, T t) throws StreamBaseException
Expect a tuple from the dequeuer. Equivalent toexpect(DequeueSetting.DISALLOW_EXTRA_TUPLES, tupleMaker, t);- Parameters:
tupleMaker- Tuple factoryt- Tuple to expect- Throws:
StreamBaseException- if the next dequeued tuple does not match the expected tuple.
-
expect
public <T> void expect(Expecter.DequeueSetting mode, TupleMaker<T> tupleMaker, T... t) throws StreamBaseException
Expect a tuple from the dequeuer- Parameters:
mode- whether to allow extra tuples or require the tuples to match without intermediate tuplestupleMaker- Tuple factoryt- Ordered list of expected tuples- Throws:
StreamBaseException- if the next dequeued tuple does not match the expected tuple.
-
expect
public <T> void expect(TupleMaker<T> tupleMaker, T... t) throws StreamBaseException
Expect multiple tuples in a particular order from the dequeuer. Equivalent toexpect(DequeueSetting.DISALLOW_EXTRA_TUPLES, tupleMaker, t);- Parameters:
tupleMaker- Tuple factoryt- Ordered list of expected tuples- Throws:
StreamBaseException- if the dequeued tuples do not match the expected tuples.
-
expect
public <T> void expect(Expecter.DequeueSetting mode, TupleMaker<T> tupleMaker, List<T> t) throws StreamBaseException
Expect a tuple from the dequeuer- Parameters:
mode- whether to allow extra tuples or require the tuples to match without intermediate tuplestupleMaker- Tuple factoryt- List of expected tuples- Throws:
StreamBaseException- if the next dequeued tuple does not match the expected tuple.
-
expect
public <T> void expect(TupleMaker<T> tupleMaker, List<T> t) throws StreamBaseException
Expect multiple tuples in a particular order from the dequeuer. Equivalent toexpect(DequeueSetting.DISALLOW_EXTRA_TUPLES, tupleMaker, t);- Parameters:
tupleMaker- Tuple factoryt- List of expected tuples- Throws:
StreamBaseException- if the dequeued tuples do not match the expected tuples.
-
expectUnordered
public void expectUnordered(Expecter.DequeueSetting mode, List<Tuple> expected) throws StreamBaseException
Expect multiple tuples in any order from the dequeuer- Parameters:
mode- whether to allow extra tuples or require the tuples to match without intermediate tuplesexpected- the expected tuples- Throws:
StreamBaseException- if the dequeued tuples do not match the expected tuples.
-
expectUnorderedPredicate
public void expectUnorderedPredicate(Expecter.DequeueSetting mode, List<Expecter.Predicate> expected) throws StreamBaseException
Expect tuples that fulfill multiple predicates in any order from the dequeuer- Parameters:
mode- whether to allow extra tuples or require the tuples to match without intermediate tuplesexpected- the predicates incoming tuples are expected to match- Throws:
StreamBaseException- if the dequeued tuples do not match the expected predicates.
-
expectUnordered
public void expectUnordered(List<Tuple> expected) throws StreamBaseException
Expect multiple tuples in any order from the dequeuer. Equivalent toexpectUnordered(DequeueSetting.DISALLOW_EXTRA_TUPLES, expected);- Parameters:
expected- List of expected tuples- Throws:
StreamBaseException- if the dequeued tuples do not match the expected tuples.
-
expectUnordered
public void expectUnordered(Expecter.DequeueSetting mode, Tuple... expected) throws StreamBaseException
Expect multiple tuples in any order from the dequeuer- Parameters:
mode- whether to allow extra tuples or require the tuples to match without intermediate tuplesexpected- the expected tuples- Throws:
StreamBaseException- if the dequeued tuples do not match the expected tuples.
-
expectUnordered
public void expectUnordered(Tuple... expected) throws StreamBaseException
Expect multiple tuples in any order from the dequeuer. Equivalent toexpectUnordered(DequeueSetting.DISALLOW_EXTRA_TUPLES, expected);- Parameters:
expected- Ordered list of expected tuples- Throws:
StreamBaseException- if the dequeued tuples do not match the expected tuples.
-
expectUnordered
public <T> void expectUnordered(Expecter.DequeueSetting mode, TupleMaker<T> tupleMaker, T... t) throws StreamBaseException
Expect multiple tuples in any order from the dequeuer- Parameters:
mode- Dequeue modetupleMaker- Tuple factoryt- Expected tuples- Throws:
StreamBaseException- if the dequeued tuples do not match the expected tuples.
-
expectUnordered
public <T> void expectUnordered(TupleMaker<T> tupleMaker, T... t) throws StreamBaseException
Expect multiple tuples in any order from the dequeuer. Equivalent toexpectUnordered(DequeueSetting.DISALLOW_EXTRA_TUPLES, tupleMaker, t);- Parameters:
tupleMaker- Tuple factoryt- Expected tuples- Throws:
StreamBaseException- if the dequeued tuples do not match the expected tuples.
-
expectUnordered
public <T> void expectUnordered(Expecter.DequeueSetting mode, TupleMaker<T> tupleMaker, List<T> t) throws StreamBaseException
Expect multiple tuples in any order from the dequeuer- Parameters:
mode- Dequeue modetupleMaker- Tuple factoryt- List of expected tuples- Throws:
StreamBaseException- if the dequeued tuples do not match the expected tuples.
-
expectUnordered
public <T> void expectUnordered(TupleMaker<T> tupleMaker, List<T> t) throws StreamBaseException
Expect multiple tuples in any order from the dequeuer. Equivalent toexpectUnordered(DequeueSetting.DISALLOW_EXTRA_TUPLES, tupleMaker, t);- Parameters:
tupleMaker- Tuple factoryt- Expected tuples- Throws:
StreamBaseException- if the dequeued tuples do not match the expected tuples.
-
expectNothing
public void expectNothing(long time, TimeUnit unit) throws StreamBaseExceptionExpect no tuples to be available on the stream, while ensuring that the server has time to process any tuples that are currently in flight.- Parameters:
time- the period of time to dequeue for (must be ≥ 0)unit- the unit for time- Throws:
StreamBaseException- Error detected
-
expectNothing
public void expectNothing() throws StreamBaseExceptionExpect no tuples to be available on the stream, while ensuring that the server has time to process any tuples that are currently in flight.- Throws:
StreamBaseException- Error detected
-
-