General Concerns

(General Variables)

To avoid a lot of boilerplate in your Input Objects, we define a list of input variables we handle by default.

We generate a description with the API Documentation under General Variables.

You can override the list of variables, you support in your ApiProjectCreator, like

import camundala.bpmn.InputParams.*

override def supportedVariables: Seq[InputParams] = Seq(
    servicesMocked,
    outputMock,
    outputServiceMock,
    handledErrors,
    regexHandledErrors,
    impersonateUserId
  )

If you use our Workers - you must use the predefined Variables.

Mocking

This looks a bit strange, that mocking is at the domain level. However, it turns out that this is quite helpful:

The mocking is done with General Variables - see also the chapter above.

The Usage is described here under General Variables

We have four ways to mock. Each possibility is done with a dedicated Process Variable.

1. Services mocked

In a process, this mocks every ServiceTask (ServiceWorker), with the serviceMock (MockedServiceResponse[ServiceOut]).

2. Mocked Worker

In a process, this mocks the SubProcesses and ServiceTasks, if their topicName or processName is in this list.

Processes must have an InitWorker and you need to add an In Mapping in the BPMN!

3. Mocked Output

A Process or a Worker, can be mocked with its Out object.

Processes must have an InitWorker!

4. Mocked Service Output

A ServiceWorker, can be mocked with its ServiceOut object.

This allows you also to mock failures in the Service, e.g. MockedServiceResponse.error(404).

Mocking Input (outputMock & outputServiceMock)

We define specific Mocks of a Process in its Input Class (In).

  case class In(
                 //..
                 mocks: Option[Mocks] = None
               )

For better readability we put all Mocks in a separate case class:

  case class Mocks(
                    @description(serviceOrProcessMockDescr(GetAccount.Out()))
                    getAccountMock: Option[GetAccount.Out] = None,
                    @description(serviceOrProcessMockDescr(GetAccount.serviceMock))
                    getServiceAccountMock: Option[MockedServiceResponse[GetAccount.ServiceOut]] = None,
                  )

This class contains all mocks as optional variables.

Process Configuration

The configuration of a process is also part of the Input object (In), and so part of the domain specification.

A like the Mocks this has these advantages:

We define specific Mocks of a Process in its Input Class (In).

  case class In(
                 //..
                 config: Option[InConfig] = None,
               )

For better readability we put all Configurations in a separate case class:

  case class InConfig(
                       @description("Timer to wait....")
                       waitForInput: String = "PT2H"
                     )

The class contains all variables with its default values.

Mapping

By default, all output variables (Out) of a Worker are on the process (External Task completion).

To reduce the variables you have two possibilities, that also can be combined:

1. Filter Output Variables

You can filter the Output with a list of variable names you are interested in. This list may include all variables from the output (Out).

2. Manual Output Mapping

This will complete the External Task only with local output variables. And you must do the output mapping manually in the BPMN.

This is needed, if you have the output variable already in the process with another value.

Exception Handling

To handle an Exception in a Worker, we can do the following:

1. List of Error Codes

To handle Errors in a ServiceTask, you need to define a list of error codes. If an error has this error code, it will complete with a BpmnError, instead a Failure.

2. List of Error Messages

If the error code is not enough, you can also add a list of regex expressions, to filter the Errors you handle.

For example, you want to handle a 400 error, but only if the message contains bad response.

Authorization

Impersonate User

User-ID or Correlation-ID of a User that should be taken to authenticate to the services. This must be supported by your implementation.

It is helpful if you have Tokens that expire, but long-running Processes.

Validation

The Validation is handled by all Workers and no additional variables are needed.

The following objects are handled: