Class StreamFactoryMock<T>


  • public class StreamFactoryMock<T>
    extends java.lang.Object
    Very simple StreamFactory mock builder to simplify the test code.
    • Method Detail

      • newFactory

        public static <T> StreamFactoryMock<T> newFactory​(java.lang.Class<T> factoryOfType)
        Start the creation of a new StreamFactoryMock.
        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 the StreamFactoryMock
      • withIdDiscoverAnother

        public StreamFactoryMock<T> withIdDiscoverAnother​(StreamId<T> id,
                                                          StreamId<T> idToDiscover)
        When the factory is asked to create id, it will use the DiscoveryService to discover idToDiscover.
        Parameters:
        id - the id that triggers the discovery
        idToDiscover - the id that will be discovered
      • withIdProvideStreamWithValue

        public StreamFactoryMock<T> withIdProvideStreamWithValue​(StreamId<T> id,
                                                                 T value)
        When the factory is asked to create id, a Publisher that contains the value will be provided.
        Parameters:
        id - the id that triggers the stream creation
        value - 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 create id, it will invoke the specified BiFunction. This gives the power to provide custom behavior in tests, the BiFunction will receive the StreamId and a DiscoveryService and must produce a Publisher.
        Parameters:
        id - the id that triggers the bifunction invocation
        bifunction - the function that will be invoked