Class MockIngestApi

  • All Implemented Interfaces:
    IngestApi

    public class MockIngestApi
    extends java.lang.Object
    implements IngestApi
    A mock implementation of IngestApi that keeps a list of all messages sent to it. Messages may be retrieved with getMessage(Class) and the list may be reset with reset(). If a MockIngestApi is in use via a standard ContentFeeder, you can get the mock api in use via ServiceFactory.getService(MockIngestApi.class).

    The public member msgs can also be accessed directly. Any test which is using msgs to check test conditions should call reset() at the beginning of the test as the instance retrieved by the test may have side-effects from previous tests.

    This class simulates the processing of messages by posting CREATED and COMPLETED audit records for each documents. This allows it to be used by a ContentFeeder. The getCompletionDelay() field controls the number of milliseconds to delay the posting of the COMPLETED audit record after the CREATED is posted. The completion delay is set to 0 whenever the reset() method is called.

    • Method Detail

      • getMessage

        public <T> T getMessage​(java.lang.Class<T> clazz)
        Get the first message of the type clazz
        Parameters:
        clazz -
        Returns:
      • reset

        public void reset()
      • getCompletionDelay

        public long getCompletionDelay()
        Returns:
        the number of milliseconds before messages are COMPLETED.
      • setCompletionDelay

        public void setCompletionDelay​(long completionDelay)
        Sets the new delay. Note, the delay is reset to 0 whenever reset() is called.
        Parameters:
        completionDelay -