Class GenerateLandingPagesMojoTest

java.lang.Object
com.guinetik.terminaljavadocs.plugin.GenerateLandingPagesMojoTest

public class GenerateLandingPagesMojoTest extends Object
Unit tests for GenerateLandingPagesMojo.

Tests the landing page generation goal including skip behavior, packaging type checks, and site directory creation.

Uses Mockito to mock Maven session and project dependencies, and JUnit's TemporaryFolder for isolated file system operations.

  • Field Details

    • tempFolder

      public org.junit.rules.TemporaryFolder tempFolder
      Temporary directory for test file operations, cleaned up after each test.
  • Constructor Details

    • GenerateLandingPagesMojoTest

      public GenerateLandingPagesMojoTest()
  • Method Details

    • setUp

      public void setUp() throws Exception
      Sets up the test fixture with mocked Maven dependencies. Initializes the mojo with default configuration using reflection.
      Throws:
      Exception - if reflection fails during field injection
    • testMojoSkipsWhenSkipFlagIsTrue

      public void testMojoSkipsWhenSkipFlagIsTrue() throws Exception
      Verifies that the mojo exits early without processing when skip=true.
      Throws:
      Exception - if reflection or execution fails
    • testMojoSkipsWhenNotPomPackaging

      public void testMojoSkipsWhenNotPomPackaging() throws Exception
      Verifies that the mojo exits early for non-POM packaging types. Landing pages should only be generated for aggregator (pom) projects.
      Throws:
      Exception - if reflection or execution fails
    • testMojoExecutesForPomProject

      public void testMojoExecutesForPomProject() throws Exception
      Verifies that the mojo executes successfully for POM packaging. Sets up a mock reactor with one module (without reports) to test the scanning logic.
      Throws:
      Exception - if reflection or execution fails
    • testSiteDirectoryIsCreated

      public void testSiteDirectoryIsCreated() throws Exception
      Verifies that the site output directory is created when it doesn't exist. When no staging directory exists, the mojo should create target/site.
      Throws:
      Exception - if reflection or execution fails
    • testProjectNameIsUsedInPages

      public void testProjectNameIsUsedInPages() throws Exception
      Verifies that the custom project name parameter is accepted. The project name is used in the generated landing page headers.
      Throws:
      Exception - if reflection or execution fails
    • testHandlesEmptyReactorProjects

      public void testHandlesEmptyReactorProjects() throws Exception
      Verifies graceful handling when the reactor contains no modules. This can occur in single-module projects or during partial builds.
      Throws:
      Exception - if reflection or execution fails