Package org.streamingpool.core.testing
Class StreamFactoryMock<T>
- java.lang.Object
-
- org.streamingpool.core.testing.StreamFactoryMock<T>
-
public class StreamFactoryMock<T> extends java.lang.ObjectVery simple StreamFactory mock builder to simplify the test code.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StreamFactorybuild()End method that will actually create the mockedTypedStreamFactorystatic <T> StreamFactoryMock<T>newFactory(java.lang.Class<T> factoryOfType)Start the creation of a newStreamFactoryMock.StreamFactoryMock<T>withIdDiscoverAnother(StreamId<T> id, StreamId<T> idToDiscover)StreamFactoryMock<T>withIdInvoke(StreamId<T> id, java.util.function.BiFunction<StreamId<T>,DiscoveryService,org.reactivestreams.Publisher<T>> bifunction)When the factory is asked to createid, it will invoke the specifiedBiFunction.StreamFactoryMock<T>withIdProvideStreamWithValue(StreamId<T> id, T value)When the factory is asked to createid, aPublisherthat contains thevaluewill be provided.
-
-
-
Method Detail
-
newFactory
public static <T> StreamFactoryMock<T> newFactory(java.lang.Class<T> factoryOfType)
Start the creation of a newStreamFactoryMock.- Parameters:
factoryOfType- the type of the values that this factory will deal with. This is only useful for the compiler to be able to infer the correct type of theStreamFactoryMock
-
withIdDiscoverAnother
public StreamFactoryMock<T> withIdDiscoverAnother(StreamId<T> id, StreamId<T> idToDiscover)
- Parameters:
id- the id that triggers the discoveryidToDiscover- the id that will be discovered
-
withIdProvideStreamWithValue
public StreamFactoryMock<T> withIdProvideStreamWithValue(StreamId<T> id, T value)
When the factory is asked to createid, aPublisherthat contains thevaluewill be provided.- Parameters:
id- the id that triggers the stream creationvalue- the value that the created stream will contain
-
withIdInvoke
public StreamFactoryMock<T> withIdInvoke(StreamId<T> id, java.util.function.BiFunction<StreamId<T>,DiscoveryService,org.reactivestreams.Publisher<T>> bifunction)
When the factory is asked to createid, it will invoke the specifiedBiFunction. This gives the power to provide custom behavior in tests, theBiFunctionwill receive theStreamIdand aDiscoveryServiceand must produce aPublisher.- Parameters:
id- the id that triggers the bifunction invocationbifunction- the function that will be invoked
-
build
public StreamFactory build()
End method that will actually create the mockedTypedStreamFactory
-
-