Class InjectSiteStylesMojoTest

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

public class InjectSiteStylesMojoTest extends Object
Unit tests for InjectSiteStylesMojo.

Tests the style injection goal including:

  • Skip behavior and directory preference
  • Page type detection (landing, coverage, jxr, javadoc, site)
  • HTML injection mechanics
  • Resource copying and path calculations

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

    • InjectSiteStylesMojoTest

      public InjectSiteStylesMojoTest()
  • Method Details

    • setUp

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

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

      public void testNoSiteDirectory() throws Exception
      Verifies that the mojo exits gracefully when no site directory exists.
      Throws:
      Exception - if execution fails
    • testPrefersStagingOverSite

      public void testPrefersStagingOverSite() throws Exception
      Verifies that staging directory is preferred over site directory. When both exist, only staging should be processed.
      Throws:
      Exception - if reflection or execution fails
    • testProcessesSiteHtmlFiles

      public void testProcessesSiteHtmlFiles() throws Exception
      Verifies that site directory is processed when staging doesn't exist.
      Throws:
      Exception - if reflection or execution fails
    • testDetectLandingPageByFilename

      public void testDetectLandingPageByFilename() throws Exception
      Verifies that coverage.html and source-xref.html are detected as LANDING pages.
      Throws:
      Exception - if reflection or execution fails
    • testDetectCoverageByPath

      public void testDetectCoverageByPath() throws Exception
      Verifies that files in /jacoco/ paths are detected as COVERAGE pages.
      Throws:
      Exception - if reflection or execution fails
    • testDetectJxrByPath

      public void testDetectJxrByPath() throws Exception
      Verifies that files in /xref/ paths are detected as JXR pages.
      Throws:
      Exception - if reflection or execution fails
    • testDetectJavadocByPath

      public void testDetectJavadocByPath() throws Exception
      Verifies that files in /apidocs/ paths are detected as JAVADOC pages.
      Throws:
      Exception - if reflection or execution fails
    • testDefaultsToSiteType

      public void testDefaultsToSiteType() throws Exception
      Verifies that unknown pages default to SITE page type.
      Throws:
      Exception - if reflection or execution fails
    • testInjectsBeforeHeadClose

      public void testInjectsBeforeHeadClose() throws Exception
      Verifies that styles are injected before the closing head tag.
      Throws:
      Exception - if reflection or execution fails
    • testSkipsAlreadyInjected

      public void testSkipsAlreadyInjected() throws Exception
      Verifies that already-injected files are skipped on re-execution. Prevents duplicate style injections.
      Throws:
      Exception - if reflection or execution fails
    • testCopiesStyleResources

      public void testCopiesStyleResources() throws Exception
      Verifies that CSS and JS resources are copied to the styles directory.
      Throws:
      Exception - if reflection or execution fails
    • testCreatesStylesDirectory

      public void testCreatesStylesDirectory() throws Exception
      Verifies that the styles directory is created.
      Throws:
      Exception - if reflection or execution fails
    • testRelativePathCalculation

      public void testRelativePathCalculation() throws Exception
      Verifies that relative paths are correctly calculated for nested files. Files in subdirectories need "../" prefixes to reach the styles directory.
      Throws:
      Exception - if reflection or execution fails
    • testCustomStylesDir

      public void testCustomStylesDir() throws Exception
      Verifies that a custom styles directory name is used.
      Throws:
      Exception - if reflection or execution fails