Skip to content

Conversation

@Pankraz76
Copy link
Contributor

provide only fixup for UnusedLocalVariable, no refactoring like in

@Pankraz76 Pankraz76 changed the title chore: ArtifactHandlerTest add test assertion to resolve @SuppressWarnings("checkstyle:UnusedLocalVariable") chore: ArtifactHandlerTest add test assertion to resolve @SuppressWarnings("checkstyle:UnusedLocalVariable") May 22, 2025
@Pankraz76 Pankraz76 changed the title chore: ArtifactHandlerTest add test assertion to resolve @SuppressWarnings("checkstyle:UnusedLocalVariable") chore: ArtifactHandlerTest add assertion to resolve @SuppressWarnings("checkstyle:UnusedLocalVariable") May 22, 2025
@Pankraz76 Pankraz76 marked this pull request as ready for review May 22, 2025 08:18
@Pankraz76 Pankraz76 force-pushed the fix-ArtifactHandlerTest branch 2 times, most recently from b60fd48 to bc0ea91 Compare May 23, 2025 08:22
@Pankraz76 Pankraz76 requested a review from elharo May 23, 2025 08:22
@Pankraz76 Pankraz76 force-pushed the fix-ArtifactHandlerTest branch from bc0ea91 to 44a5d95 Compare May 23, 2025 08:23
@Pankraz76 Pankraz76 force-pushed the fix-ArtifactHandlerTest branch from 44a5d95 to 582c71a Compare May 24, 2025 09:20
@Pankraz76 Pankraz76 requested a review from elharo May 24, 2025 09:20
assertEquals(handler.getExtension(), extension, type + " extension");
// Packaging/Directory is Maven1 remnant!!!
// assertEquals(handler.getPackaging(), packaging, type + " packaging");
assertThat(handler.getPackaging()).contains(packaging);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

test-jar != jar

this could be investigated, if only this is a combination not matching and why so.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

could merge will check up.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand why we're not just using assertEquals here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because test-jar != jar might be the only exception, but equals is the right but not working.
This could be an bug because the packaging is different. Will investigate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

all hyphen needs contains. we can continue but i wont want to ask any more questions and would take increment.
Whats your call?

@Pankraz76 Pankraz76 force-pushed the fix-ArtifactHandlerTest branch from 582c71a to 7872cca Compare May 28, 2025 08:06
@Pankraz76 Pankraz76 requested a review from elharo May 28, 2025 08:06
@Pankraz76 Pankraz76 force-pushed the fix-ArtifactHandlerTest branch from 7872cca to f6c6200 Compare May 28, 2025 08:16
Copy link
Contributor Author

@Pankraz76 Pankraz76 left a comment

Choose a reason for hiding this comment

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

smell.

assertEquals("jar", packaging);

} else if (handler.getPackaging().equals("ejb-client")) {
assertEquals("ejb", packaging);
Copy link
Contributor Author

@Pankraz76 Pankraz76 May 28, 2025

Choose a reason for hiding this comment

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

both look like bug to me. maven-archetype",
"maven-plugin", "java-source" are all equal so why not these two ? So its not a hyphen thing in general, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

I might be starting to see what's going on here. I think you're hitting a weird issue (though WAI) about file extension vs dependency type. See https://maven.apache.org/ref/3.9.9/maven-core/artifact-handlers.html and pages I can't put my finger on right now, but updated a few months ago.

That being said, I am more convinced now that this approach is incorrect. We want one single assertEquals that tests a specific value, not contains something from a collection and not "if this assert that". This might mean splitting into multiple test methods. DRY does not apply to tests and asserts. Unit tests should be very straight-forward with no branching and no conditionals.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Pankraz76 Pankraz76 force-pushed the fix-ArtifactHandlerTest branch from f6c6200 to 6a90f9b Compare May 28, 2025 08:18
assertEquals("jar", packaging);

} else if (handler.getPackaging().equals("ejb-client")) {
assertEquals("ejb", packaging);
Copy link
Contributor

Choose a reason for hiding this comment

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

I might be starting to see what's going on here. I think you're hitting a weird issue (though WAI) about file extension vs dependency type. See https://maven.apache.org/ref/3.9.9/maven-core/artifact-handlers.html and pages I can't put my finger on right now, but updated a few months ago.

That being said, I am more convinced now that this approach is incorrect. We want one single assertEquals that tests a specific value, not contains something from a collection and not "if this assert that". This might mean splitting into multiple test methods. DRY does not apply to tests and asserts. Unit tests should be very straight-forward with no branching and no conditionals.

@Pankraz76 Pankraz76 changed the title chore: ArtifactHandlerTest add assertion to resolve @SuppressWarnings("checkstyle:UnusedLocalVariable") chore: ArtifactHandlerTest improve tests on packaging Jun 7, 2025
@Pankraz76 Pankraz76 force-pushed the fix-ArtifactHandlerTest branch from 6a90f9b to d67f637 Compare June 7, 2025 09:49
container.lookup(ArtifactHandlerManager.class).getArtifactHandler(type);
assertEquals(handler.getExtension(), extension, type + " extension");
// Packaging/Directory is Maven1 remnant!!!
// assertEquals(handler.getPackaging(), packaging, type + " packaging");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

better some special workaround assert than no at all!

Agree upon test code allowed some flexibility like having commented out code. So lets use this liberty to improve the test by testing the production code.

This topic remains, but we have cleared up the doing and increased coverage.

If/as no ability to fix it yet, might consider take the increment and go for next increment.

Copy link
Contributor Author

@Pankraz76 Pankraz76 left a comment

Choose a reason for hiding this comment

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

can we resolve conversation and go for next increment? Its already an win, as removing dead code and improve context.

@Pankraz76 Pankraz76 requested a review from elharo June 7, 2025 09:55
@slachiewicz slachiewicz closed this Jun 9, 2025
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