Class InjectSiteStylesMojoTest
java.lang.Object
com.guinetik.terminaljavadocs.plugin.InjectSiteStylesMojoTest
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 Summary
FieldsModifier and TypeFieldDescriptionorg.junit.rules.TemporaryFolderTemporary directory for test file operations, cleaned up after each test. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidsetUp()Sets up the test fixture with mocked dependencies and default configuration.voidVerifies that CSS and JS resources are copied to the styles directory.voidVerifies that the styles directory is created.voidVerifies that a custom styles directory name is used.voidVerifies that unknown pages default to SITE page type.voidVerifies that files in /jacoco/ paths are detected as COVERAGE pages.voidVerifies that files in /apidocs/ paths are detected as JAVADOC pages.voidVerifies that files in /xref/ paths are detected as JXR pages.voidVerifies that coverage.html and source-xref.html are detected as LANDING pages.voidVerifies that styles are injected before the closing head tag.voidVerifies that the mojo exits gracefully when no site directory exists.voidVerifies that staging directory is preferred over site directory.voidVerifies that site directory is processed when staging doesn't exist.voidVerifies that relative paths are correctly calculated for nested files.voidVerifies that the mojo exits early when skip=true without processing any files.voidVerifies that already-injected files are skipped on re-execution.
-
Field Details
-
tempFolder
public org.junit.rules.TemporaryFolder tempFolderTemporary directory for test file operations, cleaned up after each test.
-
-
Constructor Details
-
InjectSiteStylesMojoTest
public InjectSiteStylesMojoTest()
-
-
Method Details
-
setUp
Sets up the test fixture with mocked dependencies and default configuration.- Throws:
Exception- if reflection fails during field injection
-
testSkipExecution
Verifies that the mojo exits early when skip=true without processing any files.- Throws:
Exception- if reflection or execution fails
-
testNoSiteDirectory
Verifies that the mojo exits gracefully when no site directory exists.- Throws:
Exception- if execution fails
-
testPrefersStagingOverSite
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
Verifies that site directory is processed when staging doesn't exist.- Throws:
Exception- if reflection or execution fails
-
testDetectLandingPageByFilename
Verifies that coverage.html and source-xref.html are detected as LANDING pages.- Throws:
Exception- if reflection or execution fails
-
testDetectCoverageByPath
Verifies that files in /jacoco/ paths are detected as COVERAGE pages.- Throws:
Exception- if reflection or execution fails
-
testDetectJxrByPath
Verifies that files in /xref/ paths are detected as JXR pages.- Throws:
Exception- if reflection or execution fails
-
testDetectJavadocByPath
Verifies that files in /apidocs/ paths are detected as JAVADOC pages.- Throws:
Exception- if reflection or execution fails
-
testDefaultsToSiteType
Verifies that unknown pages default to SITE page type.- Throws:
Exception- if reflection or execution fails
-
testInjectsBeforeHeadClose
Verifies that styles are injected before the closing head tag.- Throws:
Exception- if reflection or execution fails
-
testSkipsAlreadyInjected
Verifies that already-injected files are skipped on re-execution. Prevents duplicate style injections.- Throws:
Exception- if reflection or execution fails
-
testCopiesStyleResources
Verifies that CSS and JS resources are copied to the styles directory.- Throws:
Exception- if reflection or execution fails
-
testCreatesStylesDirectory
Verifies that the styles directory is created.- Throws:
Exception- if reflection or execution fails
-
testRelativePathCalculation
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
Verifies that a custom styles directory name is used.- Throws:
Exception- if reflection or execution fails
-