Class ExporterIntegrationRule

java.lang.Object
org.junit.rules.ExternalResource
io.camunda.zeebe.test.exporter.ExporterIntegrationRule
All Implemented Interfaces:
org.junit.rules.TestRule

@Deprecated(since="1.3.0", forRemoval=true) public class ExporterIntegrationRule extends org.junit.rules.ExternalResource
Deprecated, for removal: This API element is subject to removal in a future version.
since 1.3.0. See issue 8143 for more information.
JUnit test rule to facilitate running integration tests for exporters.

Sets up an embedded broker, gateway, client, and provides convenience methods to:

  1. run a sample workload (e.g. deploy & create processes, setup a job worker, etc.)
  2. visit all exported records so far
  3. perform simple operations such as deployments, starting a job worker, etc.
The embedded broker is automatically started iff at least one exporter is configured. If not explicitly configured, it must be started explicitly using start().

The broker is configured either implicitly through "zeebe.test.cfg.yaml" (found in the resource classpath) or explicitly through one of the configure methods.

An example integration test suite could look like:

 public class MyExporterIT {
   private final MyExporterConfig config = new MyExporterConfig();
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final BpmnModelInstance
    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
    protected void
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    org.junit.runners.model.Statement
    apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    void
    awaitProcessCompletion(long processInstanceKey)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Blocks and wait until the process identified by the key has been completed.
    protected void
    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.
    Configures the broker to add whatever exporters are defined in the yaml represented by the input stream.
    configure(String id, Class<E> exporterClass, Map<String,Object> arguments)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Configures the broker to use the given exporter.
    configure(String id, Class<E> exporterClass, T configuration)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Configures the broker to use the given exporter.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Creates a new job worker that will handle jobs of type .
    long
    createProcessInstance(String processId, Map<String,Object> variables)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Creates a process instance for the given process ID, with the given variables.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Deploys the given process to the broker.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns the current broker configuration.
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    <T> T
    getExporterConfiguration(String id, Class<T> configurationClass)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns an instance of the configuration class for the given exporter.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Runs a sample workload on the broker, exporting several records of different types.
    void
    publishMessage(String messageName, String correlationKey)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Publishes a new message to the broker.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Starts the broker and the client.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Stops the broker and destroys the client.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Visits all exported records in the order they were exported.

    Methods inherited from class java.lang.Object

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

    • SAMPLE_PROCESS

      public static final BpmnModelInstance SAMPLE_PROCESS
      Deprecated, for removal: This API element is subject to removal in a future version.
  • Constructor Details

    • ExporterIntegrationRule

      public ExporterIntegrationRule()
      Deprecated, for removal: This API element is subject to removal in a future version.
  • Method Details

    • apply

      public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specified by:
      apply in interface org.junit.rules.TestRule
      Overrides:
      apply in class org.junit.rules.ExternalResource
    • before

      protected void before() throws Throwable
      Deprecated, for removal: This API element is subject to removal in a future version.
      Overrides:
      before in class org.junit.rules.ExternalResource
      Throws:
      Throwable
    • after

      protected void after()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Overrides:
      after in class org.junit.rules.ExternalResource
    • getBrokerConfig

      public BrokerCfg getBrokerConfig()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns the current broker configuration.
      Returns:
      current broker configuration
    • getConfiguredExporters

      public List<ExporterCfg> getConfiguredExporters()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns:
      the currently configured exporters
    • hasConfiguredExporters

      public boolean hasConfiguredExporters()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns:
      true if any exporter has been configured for the broker, false otherwise
    • getExporterConfiguration

      public <T> T getExporterConfiguration(String id, Class<T> configurationClass)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns an instance of the configuration class for the given exporter.
      Type Parameters:
      T - type of the configuration instance
      Parameters:
      id - the exporter ID
      configurationClass - the class to instantiate based on the exporter configuration
      Returns:
      instantiated configuration class based on the exporter args map
    • configure

      public ExporterIntegrationRule configure(InputStream yaml)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Configures the broker to add whatever exporters are defined in the yaml represented by the input stream.
      Parameters:
      yaml - input stream wrapping a yaml document
    • configure

      public <T, E extends Exporter> ExporterIntegrationRule configure(String id, Class<E> exporterClass, T configuration)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Configures the broker to use the given exporter.
      Type Parameters:
      T - type of the configuration
      E - type of the exporter
      Parameters:
      id - the exporter ID
      exporterClass - the exporter class
      configuration - the configuration to use
    • configure

      public <E extends Exporter> ExporterIntegrationRule configure(String id, Class<E> exporterClass, Map<String,Object> arguments)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Configures the broker to use the given exporter.
      Type Parameters:
      E - type of the exporter
      Parameters:
      id - the exporter ID
      exporterClass - the exporter class
      arguments - the arguments to pass during configuration
    • start

      public void start()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Starts the broker and the client. This is blocking and will return once the broker is ready to accept commands.
      Throws:
      IllegalStateException - if no exporter has previously been configured
    • stop

      public void stop()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Stops the broker and destroys the client. Does nothing if not started yet.
    • performSampleWorkload

      public void performSampleWorkload()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Runs a sample workload on the broker, exporting several records of different types.
    • visitExportedRecords

      public void visitExportedRecords(Consumer<Record<?>> visitor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Visits all exported records in the order they were exported.
      Parameters:
      visitor - record consumer
    • deployProcess

      public void deployProcess(BpmnModelInstance process, String filename)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Deploys the given process to the broker. Note that the filename must have the "bpmn" file extension, e.g. "resource.bpmn".
      Parameters:
      process - process to deploy
      filename - resource name, e.g. "process.bpmn"
    • createProcessInstance

      public long createProcessInstance(String processId, Map<String,Object> variables)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a process instance for the given process ID, with the given variables.
      Parameters:
      processId - BPMN process ID
      variables - initial variables for the instance
      Returns:
      unique ID used to interact with the instance
    • createJobWorker

      public JobWorker createJobWorker(String type, JobHandler handler)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a new job worker that will handle jobs of type .

      Make sure to close the returned job worker.

      Parameters:
      type - type of the jobs to handle
      handler - handler
      Returns:
      a new JobWorker
    • publishMessage

      public void publishMessage(String messageName, String correlationKey)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Publishes a new message to the broker.
      Parameters:
      messageName - name of the message
      correlationKey - correlation key
    • awaitProcessCompletion

      public void awaitProcessCompletion(long processInstanceKey)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Blocks and wait until the process identified by the key has been completed.
      Parameters:
      processInstanceKey - ID of the process