elharo commented on code in PR #563:
URL: https://github.com/apache/maven-ear-plugin/pull/563#discussion_r4360015544
##########
src/test/java/org/apache/maven/plugins/ear/EarModuleTest.java:
##########
@@ -40,4 +45,22 @@ void testCleanArchivePath() {
assertEquals("", AbstractEarModule.cleanArchivePath(""));
assertNull(AbstractEarModule.cleanArchivePath(null));
}
+
+ @Test
+ void testResolveArtifactRequiresExecutionContext() throws Exception {
+ JarModule module = new JarModule();
+ setField(module, "groupId", "groupId");
+ setField(module, "artifactId", "artifactId");
+
+ MojoFailureException exception = assertThrows(
+ MojoFailureException.class, () ->
module.resolveArtifact(Collections.emptySet()));
+
+ assertEquals("Ear execution context not initialized for module
jar:groupId:artifactId", exception.getMessage());
+ }
+
+ private static void setField(Object target, String name, Object value)
throws Exception {
Review Comment:
If you're using reflection to test something, you're doing it wrong. Always
test through public APIs and observable behavior.
##########
src/main/java/org/apache/maven/plugins/ear/AbstractEarModule.java:
##########
@@ -155,6 +155,9 @@ public void resolveArtifact(Set<Artifact> artifacts) throws
EarPluginException,
throw new MojoFailureException(
"Could not resolve artifact[" + groupId + ":" +
artifactId + ":" + getType() + "]");
}
+ if (earExecutionContext == null) {
+ throw new MojoFailureException("Ear execution context not
initialized for module " + this);
Review Comment:
EAR
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]