Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to mock a subprocess (called activity) #694

Open
sburkard opened this issue Mar 17, 2023 · 3 comments
Open

Ability to mock a subprocess (called activity) #694

sburkard opened this issue Mar 17, 2023 · 3 comments
Labels
good first issue Good for newcomers kind/feature Categorizes an issue or PR as a feature, i.e. new behavior

Comments

@sburkard
Copy link

Description

It would be great if one could mock a called activity in a zeebe process test.

Use case: Model technical processes and call them from a main "business view" process

  • I have a main process model that represents the "business view" of the whole process
  • Let's say a workflow task need to insert data into a backend system
  • Because this is done in multiple steps through an API, it is modeled in a dedicated technical process (multiple tasks with compensation tasks etc, kind of Saga-Process)
  • To hide these technical details in the business model, I use a call activity step to call the technical process

So it is kind of the same situation as when I want to test a service or similar. I want to mock away the dependencies of the system under test for all the well known reasons.

I want to test the business process by mocking away technical (sub-)processes and just say what the outcome of the technical process should be for my test case.

@sburkard sburkard added the kind/feature Categorizes an issue or PR as a feature, i.e. new behavior label Mar 17, 2023
@remcowesterhoud remcowesterhoud added the good first issue Good for newcomers label Mar 20, 2023
@remcowesterhoud
Copy link
Contributor

remcowesterhoud commented Mar 20, 2023

Hi @sburkard, thank you for raising this. I do see value in adding a simple way for users to mock away call activities.

For now I can provide you with a workaround. Instead of mocking the called process you could deploy it with just a start event.

If you give the process the same id as the called process you can save yourself the hassle of having to execute all the tasks in the called process.

This is also how we use it ourselves:

  private void deployFakeChildProcess(final String processId, final Map<String, String> outputVariables) {
      final var builder = Bpmn.createExecutableProcess(processId).startEvent();
      outputVariables.forEach(builder::zeebeOutputExpression);
      var model = builder.done();
      client.newDeployResourceCommand().addProcessModel(model, processId + ".bpmn").send().join();
  }

Do note that here we use the BPMN Model api instead of deploying it from a file.

@sburkard
Copy link
Author

Hi @remcowesterhoud

Excellent workaround, thank you very much.

@saig0
Copy link
Member

saig0 commented May 31, 2024

Note

Heads up! We are building a new Java testing library for Camunda 8.6. The new library will replace Zeebe Process Test.
Read more about upcoming changes here and stay tuned for updates. 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers kind/feature Categorizes an issue or PR as a feature, i.e. new behavior
Projects
None yet
Development

No branches or pull requests

3 participants