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(#2217): Apply FakeMaven in AssembleMojoTest #2221

Merged
merged 14 commits into from
Jul 12, 2023

Conversation

volodya-lombrozo
Copy link
Member

@volodya-lombrozo volodya-lombrozo commented Jul 7, 2023

I've applied FakeMaven for AssembleMojoTest and added checking prerequisites for RegisterMojo in order to show more meaningful message instead of just NullPointerException.

Closes: #2217


PR-Codex overview

This PR focuses on improving the AssembleMojoTest by using the FakeMaven class.

Detailed summary:

  • Refactored the tests in AssembleMojoTest to use the FakeMaven class
  • Added a new test case for assembling invalid eo programs
  • Updated the assertions in the test cases to use the FakeMaven result method

The following files were skipped due to too many changes: eo-maven-plugin/src/test/java/org/eolang/maven/AssembleMojoTest.java

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

@volodya-lombrozo
Copy link
Member Author

@maxonfjvipon Could you take a look, please?

# Conflicts:
#	eo-maven-plugin/src/test/java/org/eolang/maven/FakeMaven.java
#	eo-maven-plugin/src/test/java/org/eolang/maven/RegisterMojoTest.java
@volodya-lombrozo
Copy link
Member Author

@maxonfjvipon Could you take a look one more time, please?

* @return The same maven instance.
*/
FakeMaven withoutDefaults() {
return new FakeMaven(this.workspace, this.params, this.attributes, this.current, false);
Copy link
Member

@maxonfjvipon maxonfjvipon Jul 10, 2023

Choose a reason for hiding this comment

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

@volodya-lombrozo Do you think it's a good idea to return a new instance of FakeMaven here? It looks like in order to get FakeMaven without defaults you need to create first one with defaults and then call this method (like you did in test throwsExceptionInCaseSourceDirIsNotSet).
It's up to you but I would remove the method and uses constructor with 2 arguments in tests instead

Copy link
Member Author

Choose a reason for hiding this comment

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

@maxonfjvipon To be honest, it's a good suggestion. Thank you. However, I'm trying to hide that fact that FakeMaven is a configurable object:
https://www.yegor256.com/2016/04/19/object-must-not-be-configurable.html

Moreover, since FakeMaven implements some sort of the builder pattern, I believe that it's convenient to keep the corresponding style.

Copy link
Member

Choose a reason for hiding this comment

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

@volodya-lombrozo then I have no more questions, thanks.

@maxonfjvipon
Copy link
Member

@volodya-lombrozo One comment from my side, see above

@maxonfjvipon
Copy link
Member

@yegor256 could you please merge these changes?

@volodya-lombrozo
Copy link
Member Author

@yegor256 Could you merge that changes please?

@@ -108,6 +108,7 @@ public final class RegisterMojo extends SafeMojo {

@Override
public void exec() throws IOException {
this.verifyPrerequisite();
Copy link
Member

Choose a reason for hiding this comment

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

@volodya-lombrozo
Copy link
Member Author

@yegor256 I've inlined that method and added if-else statement. Could you have a look one more time, please?

@volodya-lombrozo
Copy link
Member Author

@yegor256 Reminder

if (this.scopedTojos().contains(name)) {
Logger.debug(this, "EO source %s already registered", name);
continue;
if (this.sourcesDir == null) {
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

@yegor256 Done. Thanks

@volodya-lombrozo
Copy link
Member Author

@yegor256 Could you merge that changes, please?

@yegor256
Copy link
Member

@rultor merge

@rultor
Copy link
Contributor

rultor commented Jul 12, 2023

@rultor merge

@yegor256 OK, I'll try to merge now. You can check the progress of the merge here

@rultor rultor merged commit b2f082d into objectionary:master Jul 12, 2023
12 checks passed
@rultor
Copy link
Contributor

rultor commented Jul 12, 2023

@rultor merge

@yegor256 Done! FYI, the full log is here (took me 10min)

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.

AssembleMojoTest.java:41-44: Use FakeMaven in...
4 participants