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

Inject ZPT related fields into superclasses #605

Merged
2 commits merged into from
Dec 15, 2022
Merged

Conversation

remcowesterhoud
Copy link
Contributor

@remcowesterhoud remcowesterhoud commented Dec 14, 2022

Description

The extensions should inject the engine, client and recordstream into the fields that are available. Before this only tried to inject them into the annotated class. This does not work when inheritance is used and the fields are defined on the superclass of the annotated class.

This PR changes the extensions so that it will first look on the annotated class. If it cannot find any of the annotations here, it will work it's way up to the superclass and so on until it either found a field it is able to inject, or no fields at all.

Related issues

closes #604

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

The extensions should inject the ZeebeClient and the ZeebeTestEngine into the fields available with this type. This test will verify that this happens for both the embedded engine and the testcontainers engine.
The extensions should inject the engine, client and recordstream into the fields that are available. Before this only tried to inject them into the annotated class. This does not work when inheritance is used and the fields are defined on the superclass of the annotated class.

This commit changes the extension so that it will first look on the annotated class. If it cannot find any of the annotations here, it will work it's way up to the superclass and so on until it either found a field it is able to inject, or no fields at all.
@github-actions
Copy link

Test Results

  47 files  ±0    47 suites  ±0   1m 56s ⏱️ ±0s
113 tests ±0  113 ✔️ ±0  0 💤 ±0  0 ±0 
362 runs  ±0  362 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit b912ba9. ± Comparison against base commit 9badb55.

Copy link
Member

@koevskinikola koevskinikola left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

@remcowesterhoud thanks for passing the review to me. It was a nice chance to learn how the extension works.

I raised one point for discussion below, so this is why I didn't ask bors to merge the PR. It's optional, so fell free to merge it if you want to.

Comment on lines +147 to +151
} else if (fields.size() == 0) {
final Class<?> superclass = requiredTestClass.getSuperclass();
return superclass == null ? Optional.empty() : getField(superclass, object);
} else {
return Optional.of(fields.get(0));
Copy link
Member

Choose a reason for hiding this comment

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

👍 Nice, it will go up in the hierarchy until if finds something.

@remcowesterhoud
Copy link
Contributor Author

bors merge

@ghost
Copy link

ghost commented Dec 15, 2022

Build succeeded:

@ghost ghost merged commit c427e1a into main Dec 15, 2022
@ghost ghost deleted the 604_superclass_injection branch December 15, 2022 10:48
@github-actions
Copy link

Successfully created backport PR #608 for stable/8.0.

@github-actions
Copy link

Successfully created backport PR #609 for stable/8.1.

ghost pushed a commit that referenced this pull request Dec 15, 2022
608: [Backport stable/8.0] Inject ZPT related fields into superclasses r=remcowesterhoud a=github-actions[bot]

# Description
Backport of #605 to `stable/8.0`.

relates to #604

Co-authored-by: Remco Westerhoud <remco@westerhoud.nl>
ghost pushed a commit that referenced this pull request Dec 15, 2022
609: [Backport stable/8.1] Inject ZPT related fields into superclasses r=remcowesterhoud a=github-actions[bot]

# Description
Backport of #605 to `stable/8.1`.

relates to #604

Co-authored-by: Remco Westerhoud <remco@westerhoud.nl>
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@ZeebeProcessTest and injection is ignored when placed on a super class
2 participants