Bukama commented on code in PR #619:
URL: 
https://github.com/apache/maven-project-info-reports-plugin/pull/619#discussion_r2807904023


##########
src/test/java/org/apache/maven/report/projectinfo/DependenciesReportTest.java:
##########
@@ -26,35 +28,62 @@
 import com.meterware.httpunit.WebRequest;
 import com.meterware.httpunit.WebResponse;
 import com.meterware.httpunit.WebTable;
+import org.apache.maven.api.plugin.testing.Basedir;
+import org.apache.maven.api.plugin.testing.InjectMojo;
+import org.apache.maven.api.plugin.testing.MojoTest;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import static org.apache.maven.api.plugin.testing.MojoExtension.getTestFile;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
 
 /**
  * @author Edwin Punzalan
  * @author <a href="mailto:[email protected]";>Vincent Siveton</a>
  * @version $Id$
  */
-public class DependenciesReportTest extends AbstractProjectInfoTestCase {
+@MojoTest(realRepositorySession = true)
+@Basedir("/plugin-configs")
+class DependenciesReportTest extends AbstractProjectInfoTest {
+
+    @Inject
+    private MavenSession mavenSession;
+
     /**
      * WebConversation object
      */
     private static final WebConversation WEB_CONVERSATION = new 
WebConversation();
 
+    @BeforeEach
+    void setup() throws Exception {
+        DefaultProjectBuildingRequest pbr = spy(new 
DefaultProjectBuildingRequest());
+        doAnswer(__ -> 
mavenSession.getRepositorySession()).when(pbr).getRepositorySession();
+        when(mavenSession.getProjectBuildingRequest()).thenReturn(pbr);
+        readMavenProjectModel(mavenProject, "dependencies-plugin-config.xml");
+        setArtifactForProject(mavenProject);
+    }
+
     /**
      * Test report
      *
      * @throws Exception if any
      */
     @Test
-    public void testReport() throws Exception {
-        generateReport(getGoal(), "dependencies-plugin-config.xml");
-        org.junit.jupiter.api.Assertions.assertTrue(
-                getGeneratedReport("dependencies.html").exists(), "Test html 
generated");
+    @InjectMojo(goal = "dependencies", pom = "dependencies-plugin-config.xml")
+    void testReport(DependenciesReport mojo) throws Exception {
+        mojo.execute();
+
+        URL reportURL =
+                
getTestFile("target/dependencies/dependencies.html").toURI().toURL();
 
-        URL reportURL = 
getGeneratedReport("dependencies.html").toURI().toURL();
+        //        URL reportURL = ("dependencies.html").toURI().toURL();

Review Comment:
   Delete this line



-- 
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]

Reply via email to