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

ZeebeTestThreadSupport.hasProcessInstanceThrownError assert #771

Open
muraliweb9 opened this issue May 18, 2023 · 3 comments
Open

ZeebeTestThreadSupport.hasProcessInstanceThrownError assert #771

muraliweb9 opened this issue May 18, 2023 · 3 comments
Labels
kind/feature Categorizes an issue or PR as a feature, i.e. new behavior

Comments

@muraliweb9
Copy link

muraliweb9 commented May 18, 2023

com.interview.carworkflowcloud.ZeebeTestThreadSupport has many useful asserts.

Something similar to this would be useful:

ZeebeTestThreadSupport.hasProcessInstanceThrownError(processInstance, "element-id");

Something like this in io.camunda.zeebe.process.test.assertions.ProcessInstanceAssert

    /**
     * Asserts whether this process has thrown an error for this element
     *
     * @param elementId The id of the element that should have thrown error
     * @return this {@link ProcessInstanceAssert}
     */
  public ProcessInstanceAssert hasProcessInstanceThrownError(final String elementId) {

    final long count =
        StreamFilter.jobRecords(recordStream)
            .withIntent(JobIntent.ERROR_THROWN)
            .withElementId(elementId)
            .stream()
            .filter(r -> r.getValue().getProcessInstanceKey() == actual)
            .count();

    assertThat(count)
        .withFailMessage(
            "Expected element with id %s to have thrown %s error(s), but was %s",
            elementId, 1, count)
        .isEqualTo(1);

    return this;
  }

then assert count

@muraliweb9 muraliweb9 added the kind/feature Categorizes an issue or PR as a feature, i.e. new behavior label May 18, 2023
@muraliweb9 muraliweb9 closed this as not planned Won't fix, can't repro, duplicate, stale May 18, 2023
@muraliweb9 muraliweb9 reopened this May 18, 2023
@remcowesterhoud
Copy link
Contributor

Thanks for raising this @muraliweb9! I think it's a good suggestion. Unfortunately, I don't see us having the time to implement this short-term. Would you be willing to provide a pull request for this?

muraliweb9 added a commit to muraliweb9/zeebe-process-test that referenced this issue Jun 5, 2023
@muraliweb9
Copy link
Author

@remcowesterhoud I have created the below PR: #790

@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
kind/feature Categorizes an issue or PR as a feature, i.e. new behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants