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

Implement two separate builders for PullRequest and Repository #188

Merged
merged 1 commit into from
Mar 25, 2024

Conversation

The-Huginn
Copy link
Collaborator

resolves #148

@The-Huginn The-Huginn requested a review from xstefank March 5, 2024 10:15
protected Mockable previousMock;

private static final Set<Mockable> requiredMockables;
static {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This section doesn't seem just right. Perhaps I can convert this into an injectable bean, which could based on a new annotation pick up all Mockable-s and fill the set this way. It would also not rely on static variables and context.
However, that might be a bit too overkill for testing purposes and this might be more readable and understandable for future reference.

Let me know, what you think @xstefank

Copy link
Member

Choose a reason for hiding this comment

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

TBH, not sure if there should be a default at all. If this is used everywhere, it can be in the constructor.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

usually a new check or functionality always calls some new API. Thus a default mock needs to be there, otherwise it would throw many exceptions.

Example, adding check for config file always retrieves a file, thus every test will try to retrieve some file. We mock that no file is there to retrieve instead of NPE from mockito.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's static, as this method is called in tests annotated with BeforeAll, which has to be on static method. Thus static context is required.

* Note: Only one {@code Mockable} per domain is allowed to be mocked.
*
* Parallel execution is not supported as we are relaying static variables.
*/
Copy link
Member

Choose a reason for hiding this comment

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

Comments go on the class declaration, not before package or imports

protected Mockable previousMock;

private static final Set<Mockable> requiredMockables;
static {
Copy link
Member

Choose a reason for hiding this comment

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

TBH, not sure if there should be a default at all. If this is used everywhere, it can be in the constructor.

@xstefank xstefank merged commit 4e71e9a into wildfly:main Mar 25, 2024
1 check passed
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.

Mocked context in testing should have separate builders for repository and pull request
2 participants