Class ExporterTestHarness

java.lang.Object
io.camunda.zeebe.test.exporter.ExporterTestHarness

@Deprecated(since="1.3.0", forRemoval=true) public class ExporterTestHarness extends Object
Deprecated, for removal: This API element is subject to removal in a future version.
since 1.3.0. See issue 8143 for more information.
ExporterTestHarness provides utilities to write unit tests for concrete implementations of the Exporter interface, by simulating the lifecycle that it would have on a live broker while allowing callers to control the execution flow.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    class 
    Deprecated, for removal: This API element is subject to removal in a future version.
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated, for removal: This API element is subject to removal in a future version.
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Closes the exporter
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Will configure the exporter with a default empty configuration, an empty arguments map, but the correct given ID.
    void
    configure(String id, File configFile)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Convenience method for configure(String, InputStream) which will transform the file into an InputStream.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Will configure the exporter with the given ID, and parse the input as if it were a partial YAML document; this would allow one to test sample configuration and make sure they're parsed as expected.
    <T> void
    configure(String id, T config)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Convenience method which will substitute a prepared configuration instance such that it is always returned by a call to Configuration.instantiate(Class)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Exports a single default record.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Exports the given record, updating the latest position to the position of the record.
    export(Consumer<MockRecord> configurator)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Will export a mock record to the exporter; the is called right before, providing a means of modifying the record before.
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    long
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns the last position as reported by the exporter through Controller.updateLastExportedRecordPosition(long)
    long
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns the last exported record's position; note that this is not the last updated record position, as updated by the exporter, but simply the position of that last record handed off to the exporter via Exporter.export(Record).
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Resets scheduled tasks and opens the exporter.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Runs all scheduled tasks which should be expired if time has passed since the last time this was called.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Streams a series of record.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Streams a series of record based on the given seed.
    stream(Consumer<MockRecord> configurator)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Streams a series of record based on a default record, which the caller can modify before it used as a seed for the stream.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ExporterTestHarness

      public ExporterTestHarness(Exporter exporter)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Parameters:
      exporter - the exporter to be tested
  • Method Details

    • configure

      public void configure(String id) throws Exception
      Deprecated, for removal: This API element is subject to removal in a future version.
      Will configure the exporter with a default empty configuration, an empty arguments map, but the correct given ID.
      Parameters:
      id - the ID of the exporter
      Throws:
      Exception
    • configure

      public void configure(String id, InputStream yaml) throws Exception
      Deprecated, for removal: This API element is subject to removal in a future version.
      Will configure the exporter with the given ID, and parse the input as if it were a partial YAML document; this would allow one to test sample configuration and make sure they're parsed as expected.

      The given YAML document can be a partial document which contains strictly the exporter definition. For example: zeebe: broker: exporters: elasticsearsch: className: io.camunda.zeebe.exporter.ElasticsearchExporter args: ...

      NOTE: the ID of the exporter in the YAML document MUST match the given ID here to avoid any issues where you would pass a sample YAML document with multiple exporter definitions.

      Parameters:
      id - id of the exporter
      yaml - the reference YAML document
      Throws:
      Exception
    • configure

      public void configure(String id, File configFile) throws Exception
      Deprecated, for removal: This API element is subject to removal in a future version.
      Convenience method for configure(String, InputStream) which will transform the file into an InputStream. See its documentation for more.
      Parameters:
      id - the exporter ID
      configFile - pointer to a yaml configuration file
      Throws:
      Exception
    • configure

      public <T> void configure(String id, T config) throws Exception
      Deprecated, for removal: This API element is subject to removal in a future version.
      Convenience method which will substitute a prepared configuration instance such that it is always returned by a call to Configuration.instantiate(Class)

      NOTE: in this case, Configuration.getArguments() always returns an empty map.

      Type Parameters:
      T - type of the configuration class
      Parameters:
      id - the exporter ID
      config - new return value of Configuration.instantiate(Class)
      Throws:
      Exception
    • open

      public void open()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Resets scheduled tasks and opens the exporter.

      NOTE: if closing/opening the exporter here several times, the start position will be the same as the end position when the exporter was last closed.

    • close

      public void close()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Closes the exporter
    • export

      public MockRecord export()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Exports a single default record.
      Returns:
      generated record
    • export

      public MockRecord export(MockRecord record)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Exports the given record, updating the latest position to the position of the record.
      Parameters:
      record - record to export
      Returns:
      exported record
    • export

      public MockRecord export(Consumer<MockRecord> configurator)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Will export a mock record to the exporter; the is called right before, providing a means of modifying the record before.
      Parameters:
      configurator - a consumer to modify the record, can be null
      Returns:
      the exported record
    • stream

      public ExporterTestHarness.Stream stream()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Streams a series of record.
      Returns:
      a stream of MockRecord
    • stream

      public ExporterTestHarness.Stream stream(MockRecord seed)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Streams a series of record based on the given seed.

      Subsequent records after the seed will be exactly the same, with the exception that the position and timestamps of later records are always greater than that of previous ones.

      Parameters:
      seed - the initial sample record
      Returns:
      a stream of MockRecord
    • stream

      public ExporterTestHarness.Stream stream(Consumer<MockRecord> configurator)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Streams a series of record based on a default record, which the caller can modify before it used as a seed for the stream. For more, see stream(MockRecord).
      Parameters:
      configurator - a consumer to modify the record, can be null
      Returns:
      a stream of MockRecord
    • runScheduledTasks

      public void runScheduledTasks(Duration elapsed)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Runs all scheduled tasks which should be expired if time has passed since the last time this was called.
      Parameters:
      elapsed - time to elapse
    • getController

      public MockController getController()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns:
      underlying mock controller
    • getContext

      public MockContext getContext()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getPosition

      public long getPosition()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns the last exported record's position; note that this is not the last updated record position, as updated by the exporter, but simply the position of that last record handed off to the exporter via Exporter.export(Record).
      Returns:
      the last exported record's position
    • getLastUpdatedPosition

      public long getLastUpdatedPosition()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns the last position as reported by the exporter through Controller.updateLastExportedRecordPosition(long)
      Returns:
      the last exported record position