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

feat: add assertions for message variables #1195

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sephiroth-j
Copy link

@sephiroth-j sephiroth-j commented Jun 14, 2024

Description

Adds hasVariable and hasVariableWithValue to MessageAssert, similar to ProcessInstanceAssert.

Related issues

Definition of Done

Not all items need to be done depending on the issue and the pull request.

Code changes:

  • The changes are backwards compatibility with previous versions
  • If it fixes a bug then PRs are created to backport the fix

Testing:

  • There are unit/integration tests that verify all acceptance criterias of the issue
  • New tests are written to ensure backwards compatibility with further versions
  • The behavior is tested manually

Documentation:

  • Javadoc has been written
  • The documentation is updated

@CLAassistant
Copy link

CLAassistant commented Jun 14, 2024

CLA assistant check
All committers have signed the CLA.

@saig0 saig0 self-assigned this Jun 17, 2024
@saig0 saig0 self-requested a review June 17, 2024 11:13
Copy link

github-actions bot commented Jun 17, 2024

Test Results

 24 files   24 suites   12s ⏱️
 25 tests  25 ✅ 0 💤 0 ❌
100 runs  100 ✅ 0 💤 0 ❌

Results for commit c357eb6.

♻️ This comment has been updated with latest results.

adds `hasVariable` and `hasVariableWithValue` to `MessageAssert`, similar to `ProcessInstanceAssert`
@sephiroth-j sephiroth-j force-pushed the feature/variable-assert-for-messages branch from 8a716ce to 8de00a7 Compare June 17, 2024 11:59
@sephiroth-j sephiroth-j changed the title feat: add hasVariable and hasVariableWithValue to MessageAssert feat: add assertions for message variables Jun 17, 2024
@sephiroth-j
Copy link
Author

I fixed the formatting problems and swapped the title and description.

@saig0
Copy link
Member

saig0 commented Jun 20, 2024

@sephiroth-j thank you for your contribution. 👍 I checked the changes but I'm unsure about the use case.

Do you want to check the variables of a published message?
Please describe for what use case.


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. 🚀

@sephiroth-j
Copy link
Author

@sephiroth-j thank you for your contribution. 👍 I checked the changes but I'm unsure about the use case.

Do you want to check the variables of a published message? Please describe for what use case.

Yes, exactly. Right now, you need to retrieve a process instance that may have been created after the message was received to be able to check the variables. But it makes no sense if the client's task is only to publish a specific message with specific variables. It could also be that no process instance was created at all.

Copy link
Member

@saig0 saig0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sephiroth-j the changes look good. 👍

I have two minor comments before we can merge the PR. Please have a look. 🍪

@@ -234,4 +237,51 @@ private List<Long> getProcessInstanceKeysForCorrelatedMessageStartEvent() {
.map(record -> record.getValue().getProcessInstanceKey())
.collect(Collectors.toList());
}

private Map<String, Object> getVariables() {
return StreamFilter.processMessageSubscription(recordStream)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ We should get the variables of the message from the message records.

A process message subscription is only written when a message is correlated to a process instance.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use StreamFilter.message(recordStream) for this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ We need to add the API module as a test dependency. The dependency plugin fails with the message:

[INFO] --- maven-dependency-plugin:3.6.1:analyze-only (analyze) @ zeebe-process-test-assertions ---
Error:  Used undeclared dependencies found:
Error:     io.camunda:zeebe-process-test-api:jar:8.6.0-alpha2-rc2-SNAPSHOT:compile
Error:  Non-test scoped test only dependencies found:
Error:     io.camunda:zeebe-process-test-api:jar:8.6.0-alpha2-rc2-SNAPSHOT:compile

Add the following test dependency to the module pom.xml:

<dependency>
      <groupId>io.camunda</groupId>
      <artifactId>zeebe-process-test-api</artifactId>
      <scope>test</scope>
    </dependency>

@sephiroth-j
Copy link
Author

sephiroth-j commented Jun 25, 2024

I'm getting the following build error on the main branch. Any ideas?

mvn -U clean test verify

[INFO] --- dependency:3.6.1:analyze-only (analyze) @ zeebe-process-test-api ---
[ERROR] Unused declared dependencies found:
[ERROR]    io.camunda:zeebe-client-java:jar:8.6.0-SNAPSHOT:compile
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Zeebe Process Test Root 8.6.0-alpha2-rc2-SNAPSHOT:
[INFO]
[INFO] Zeebe Process Test Root ............................ SUCCESS [  2.828 s]
[INFO] Zeebe Process Test API ............................. FAILURE [  0.954 s]
[INFO] Zeebe Process Test Filters ......................... SKIPPED
[INFO] Zeebe Process Test Assertions ...................... SKIPPED
[INFO] Zeebe Process Test Engine .......................... SKIPPED
[INFO] Zeebe Process Test Engine Protocol ................. SKIPPED
[INFO] Zeebe Process Test Engine Agent .................... SKIPPED
[INFO] Zeebe Process Test Extension ....................... SKIPPED
[INFO] Zeebe Process Test Extension Testcontainer ......... SKIPPED
[INFO] Zeebe Process Test QA .............................. SKIPPED
[INFO] Zeebe Process Test QA Abstracts .................... SKIPPED
[INFO] Zeebe Process Test QA Embedded ..................... SKIPPED
[INFO] Zeebe Process Test Examples ........................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.666 s
[INFO] Finished at: 2024-06-25T14:00:59+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project zeebe-process-test-api: Compilation failure: Compilation failure:
[ERROR] /C:/DEVEL/zeebe-process-test/api/src/main/java/io/camunda/zeebe/process/test/api/ZeebeTestEngine.java:[19,31] Package io.camunda.zeebe.client ist nicht vorhanden
[ERROR] /C:/DEVEL/zeebe-process-test/api/src/main/java/io/camunda/zeebe/process/test/api/ZeebeTestEngine.java:[43,3] Symbol nicht gefunden
[ERROR]   Symbol: Klasse ZeebeClient
[ERROR]   Ort: Schnittstelle io.camunda.zeebe.process.test.api.ZeebeTestEngine
[ERROR] /C:/DEVEL/zeebe-process-test/api/src/main/java/io/camunda/zeebe/process/test/api/ZeebeTestEngine.java:[48,3] Symbol nicht gefunden
[ERROR]   Symbol: Klasse ZeebeClient
[ERROR]   Ort: Schnittstelle io.camunda.zeebe.process.test.api.ZeebeTestEngine
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :zeebe-process-test-api

@sephiroth-j
Copy link
Author

sephiroth-j commented Jun 25, 2024

For some reason, the jar file zeebe-client-java-8.6.0-20240625.094240-1041 does not contain any class files. All jar files currently available at https://artifacts.camunda.com/ui/native/zeebe-io-snapshots/io/camunda/zeebe-client-java/8.6.0-SNAPSHOT/ are affected!

grafik

@saig0
Copy link
Member

saig0 commented Jun 25, 2024

@sephiroth-j yes, in 8.6.0-SNAPSHOT the artifact name of the Zeebe client changed to:

<dependency>
      <groupId>io.camunda</groupId>
      <artifactId>camunda-client-java</artifactId>
    </dependency>

@sephiroth-j
Copy link
Author

@sephiroth-j yes, in 8.6.0-SNAPSHOT the artifact name of the Zeebe client changed to:

<dependency>
      <groupId>io.camunda</groupId>
      <artifactId>camunda-client-java</artifactId>
    </dependency>

Okay, then please update your main branch first and let me know when that's done so I can rebase my feature branch again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants