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

Move annotation discovery into AbstractEntryBasedExtension #485

Merged
merged 14 commits into from May 29, 2021
Merged

Move annotation discovery into AbstractEntryBasedExtension #485

merged 14 commits into from May 29, 2021

Conversation

beatngu13
Copy link
Member

Closes #460. This issue was basically a description of the current usage of both BeforeAllCallback and BeforeEachCallback, which was indirectly followed by a discussion on "Enclosing classes vs Before/AfterAll" in #479. As a goal in the first issue, I said I would like to add an implementation note to prevent further confusion. In addition, it would be helpful if a core part of the implementation – annotation discovery – was a single point of failure, and not duplicated in EnvironmentVariableExtension and SystemPropertyExtension.

Note that this PR is based on the currently unmerged changes in #481. I also marked this as a draft since I haven't updated the README.md yet to not cause merge conflicts.

Proposed commit message:

Move annotation discovery into AbstractEntryBasedExtension (#460 / #485)

This PR removes the duplicated annotation discovery in
`EnvironmentVariableExtension` and `SystemPropertyExtension` and moves
it into `AbstractEntryBasedExtension`.

Closes: #460
PR: #485

PR checklist

The following checklist shall help the PR's author, the reviewers and maintainers to ensure the quality of this project.
It is based on our contributors guidelines, especially the "writing code" section.
It shall help to check for completion of the listed points.
If a point does not apply to the given PR's changes, the corresponding entry can be simply marked as done.

Documentation (general)

  • There is documentation (Javadoc and site documentation; added or updated)
  • There is implementation information to describe why a non-obvious source code / solution got implemented
  • Site documentation has its own .adoc file in the docs folder, e.g. docs/report-entries.adoc
  • Only one sentence per line (especially in .adoc files)
  • Javadoc uses formal style, while sites documentation may use informal style

Documentation (new extension)

  • The docs/docs-nav.yml navigation has an entry for the new extension
  • The package-info.java contains information about the new extension

Code

  • Code adheres to code style, naming conventions etc.
  • Successful tests cover all changes
  • There are checks which validate correct / false usage / configuration of a functionality and there are tests to verify those checks
  • Tests use AssertJ or our own PioneerAssert (which are based on AssertJ)

Contributing

  • A prepared commit message exists
  • The list of contributions inside README.md mentions the new contribution (real name optional)

I hereby agree to the terms of the JUnit Pioneer Contributor License Agreement.

Unfortunately, static declarations in inner classes (e.g. a static
factory method `empty()`) are not supported in Java 8.
Eat your own dog food!
Since the extension context store no longer queries ancestors, original
entries can always be restored as the backup is simply empty if there
is no value for the supplied key.
@beatngu13 beatngu13 changed the title Refactor AbstractEntryBasedExtension Move annotation discovery into AbstractEntryBasedExtension May 14, 2021
@Bukama Bukama requested a review from nipafx May 15, 2021 05:52
Copy link
Member

@nipafx nipafx left a comment

Choose a reason for hiding this comment

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

Looks good to me. The annotations as generic types and the ...Mapper methods are a bit weird at first sight, but all together they make for a pretty type-safe way to handle the problem, particularly given annotations can't implement interfaces.

@nipafx nipafx marked this pull request as ready for review May 29, 2021 12:35
@nipafx nipafx merged commit 0ef4ca6 into junit-pioneer:main May 29, 2021
@beatngu13 beatngu13 deleted the issue/460-refactor-envvar-sysprop branch May 30, 2021 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants