Skip to content

Add unit tests for de.rub.nds.crawler.data package to achieve 100% coverage #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

ic0ns
Copy link
Contributor

@ic0ns ic0ns commented Jun 19, 2025

Summary

  • Added comprehensive unit tests for all classes in the de.rub.nds.crawler.data package
  • Achieved 100% code coverage for all data classes
  • Tests use only JUnit Jupiter (no external mocking frameworks)

Changes

  • Added unit tests for ScanTarget class
  • Added unit tests for ScanConfig abstract class
  • Added unit tests for BulkScanJobCounters class
  • Added unit tests for BulkScanInfo class
  • Added unit tests for ScanJobDescription class
  • Added unit tests for ScanResult class
  • Added unit tests for BulkScan class

All tests pass successfully with 129 total tests.

ic0ns added 11 commits June 19, 2025 11:50
- Test all constructors, getters, and setters
- Test fromTargetString with various input formats
- Test IP address validation and hostname resolution
- Test port parsing and validation
- Test Tranco rank parsing
- Test MX format and quoted strings handling
- Test denylist functionality
- Test error cases (unresolvable hosts, invalid formats)
- Test IPv6 address handling
- Test boundary conditions for port numbers
- Achieve 100% code coverage for ScanTarget class
- Test protected constructor with all parameter combinations
- Test all getters and setters with various values
- Test abstract createWorker method via concrete implementation
- Test serialization interface implementation
- Test boundary values for timeout and reexecutions
- Test null handling for ScannerDetail
- Test all ScannerDetail enum values
- Achieve 100% code coverage for ScanConfig class
- Test constructor initialization with all JobStatus values
- Test exclusion of TO_BE_EXECUTED status from counters
- Test thread-safe counter operations
- Test concurrent increment and read operations
- Test getJobStatusCountersCopy returns independent copies
- Test individual status counting
- Test total job count tracking across all statuses
- Test null pointer exceptions for excluded status
- Achieve 100% code coverage for BulkScanJobCounters class
- Test constructor initialization from BulkScan
- Test all getter methods
- Test type-safe getScanConfig with generics
- Test ClassCastException for wrong type casting
- Test field immutability (final fields)
- Test null handling for all fields
- Test serialization interface implementation
- Test edge cases (empty strings, null configs)
- Achieve 100% code coverage for BulkScanInfo class
- Test both constructors (with BulkScanInfo and BulkScan)
- Test all getter and setter methods
- Test delivery tag management and single-assignment enforcement
- Test serialization/deserialization with transient field handling
- Test IllegalStateException for duplicate delivery tag assignment
- Test NoSuchElementException for empty delivery tag
- Test null and empty string handling
- Test field modifiers (final, transient)
- Test all JobStatus values
- Achieve 100% code coverage for ScanJobDescription class
- Test constructor with ScanJobDescription
- Test IllegalArgumentException for TO_BE_EXECUTED status
- Test fromException static factory method
- Test UUID generation and uniqueness
- Test all getter and setter methods
- Test JSON property annotations
- Test error handling for non-error statuses in fromException
- Test various Document scenarios (null, empty, large)
- Test field modifiers (final fields)
- Test private constructor existence
- Achieve 100% code coverage for ScanResult class
- Test main constructor with all parameters
- Test collection name generation with date formatting
- Test all getter and setter methods
- Test version extraction from package classes
- Test JobStatus counters map handling
- Test persistence annotation (@id)
- Test boundary values for numeric fields
- Test null and empty string handling
- Test static dateFormat field
- Test private no-args constructor existence
- Test field initialization defaults
- Achieve 100% code coverage for BulkScan class
- Replace all mocked objects with concrete test implementations
- Remove MockitoExtension and Mock annotations
- Update tests to use real objects instead of mocks
- Maintain test coverage and functionality
- Tests now work with only JUnit Jupiter dependency
- Port validation only applies to setPort(), not parsing
- IPv6 addresses fail due to : handling (known FIXME in code)
- Empty hostnames resolve to localhost in test environment
- Handle environment-specific hostname resolution differences
- Port validation happens during parsing, not just in setPort()
- Invalid ports (<=1 or >=65535) use default port
- Quote removal happens correctly after // removal
- When port validation fails, setPort is never called and port stays at default 0
- Quotes are only removed if string both starts AND ends with quotes
- With format '//"hostname":port', quotes remain as string ends with :port
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant