Skip to content

Add comprehensive unit tests for HTTP client actions and utilities#17

Merged
marevol merged 3 commits intomainfrom
claude/review-and-test-coverage-hLXNi
Mar 21, 2026
Merged

Add comprehensive unit tests for HTTP client actions and utilities#17
marevol merged 3 commits intomainfrom
claude/review-and-test-coverage-hLXNi

Conversation

@marevol
Copy link
Contributor

@marevol marevol commented Mar 21, 2026

Summary

This PR adds extensive unit test coverage for the HTTP client implementation, including tests for action handlers, node management, and URL utilities. The test suite covers core functionality such as media type handling, bulk operations, search queries, index creation, and node availability management.

Key Changes

  • HttpAction tests: Added 14 test cases covering media type/format conversion, ActiveShardCount value extraction, OpenSearchException unwrapping, and field constant validation
  • HttpBulkAction tests: Added 8 test cases for document write request serialization and bulk response parsing with various scenarios (index, delete, failures)
  • HttpSearchAction tests: Added 7 test cases for query source extraction with different query types (match_all, term, bool, aggregations, source filtering)
  • HttpIndexAction tests: Added 2 test cases for index response parsing (created and updated results)
  • HttpDeleteAction tests: Added 2 test cases for delete response parsing (deleted and not_found results)
  • HttpGetAction tests: Added 1 basic construction test
  • HttpCreateIndexRequest tests: Added 6 test cases for mapping preparation and request delegation
  • Node tests: Added 8 test cases for node URL construction, availability management, and thread safety
  • NodeIterator tests: Added 7 test cases for round-robin iteration and boundary conditions
  • UrlUtils tests: Added 10 test cases for URL encoding and joining with special characters and Unicode support

Notable Implementation Details

  • Tests use JUnit 5 (Jupiter) with standard assertions
  • Comprehensive coverage of edge cases (null values, empty collections, special characters)
  • Thread safety validation for concurrent node availability updates
  • XContent parsing tests using OpenSearch's JsonXContent parser
  • Round-robin distribution verification for NodeIterator
  • Media type handling with charset parameters

claude and others added 3 commits March 21, 2026 09:46
…TTP actions

Add comprehensive unit test coverage for previously untested classes:
- UrlUtils: URL encoding and joining with special characters, null handling
- Node: availability state, URL construction, thread safety
- NodeIterator: round-robin iteration, boundary handling, NoSuchElementException
- HttpAction: media type detection, active shard count serialization, exception unwrapping
- HttpBulkAction: NDJSON request serialization, bulk response parsing with failures
- HttpSearchAction: query source serialization for various query types
- HttpIndexAction/HttpDeleteAction: response parsing for CRUD operations
- HttpGetAction: basic construction verification
- HttpCreateIndexRequest: mapping preparation and delegation pattern

https://claude.ai/code/session_014opUrsabrAZEr3Ck3m8kAe
SearchRequest initializes with a default SearchSourceBuilder, so
getQuerySource returns "{}" instead of null. Updated test to match
actual behavior.
@marevol marevol merged commit 005ad1c into main Mar 21, 2026
1 check passed
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.

2 participants