adityamparikh opened a new pull request, #321:
URL: https://github.com/apache/solr-mcp/pull/321
## Summary
Tests that check JSON matched substrings of the serialized text, or walked
it through `Map` cast chains. A substring check passes on any payload that
happens to contain the token: `text.contains("5")` matches a timestamp, and
`contains("success") || contains("true")` matches a failure that has some other
`true` field. These tests now read values at a JsonPath through Spring
Framework's `JsonContent`, which comes with `spring-boot-starter-test`
(json-path 3.0.0), so no dependency is added.
```diff
check-health
- text.contains("true") || text.contains("healthy")
- text.contains("5")
+ $.isHealthy == true
+ $.totalDocuments == 5
get-collection-stats
- text.contains("5") || text.contains("numDocs")
+ $.indexStats.numDocs == 5
get-schema (shows)
- text.contains("\"title\"") ...for 7 names
+ $.fields[*].name contains title, platform, genres, ...
/actuator/health (Docker image)
- body.contains("UP") || body.contains("\"status\"")
+ $.status == "UP"
list-fields (SchemaServiceTest)
- assertEquals("{\"fields\":{\"genre_s\":...}}", json)
+ isStrictlyEqualTo(<text block>) # key order no longer matters
```
| File | Change |
|---|---|
| `McpClientIntegrationTestBase` | every tool-result JSON check (HTTP and
STDIO); `json(result)`, `read(result, path)` and `getNumFound(result)` helpers
replace `OBJECT_MAPPER` + `Map` casts |
| `SchemaServiceTest` | catch-all and flags checks by path; the list-fields
payload compared structurally |
| `DockerImageHttpIntegrationTest` | health status by path |
| `AGENTS.md` | the convention, and the deep-scan gotcha below |
One JsonPath trap is called out in comments and AGENTS.md:
`doesNotHavePath("$..other")` always fails, because a deep scan returns `[]`
instead of throwing `PathNotFoundException`. The "no `other` key anywhere"
checks use `extractingPath("$..other").asArray().isEmpty()`.
Out of scope: `contains` on prose (prompt bodies, error messages) is not
JSON and stays. `LgtmAssertions` is an HTTP client for Grafana's APIs that
returns parsed `JsonNode` trees and does no string matching.
`SchemaServiceIntegrationTest` already compares parsed maps.
## Evidence
- `./gradlew build`: 518 tests, 0 failures, 0 skipped.
- `./gradlew dockerIntegrationTest` (Jib JVM image, where
`DockerImageHttpIntegrationTest` runs): 58 tests across the three Docker test
classes, 0 failures, 0 skipped.
- The new assertions can fail: changing `"docs": 5` to `6` in the expected
list-fields JSON fails
`listFields_decodesFlagsAndLeavesOutTheInfoAndIndexSections`.
## Merge Danger
**Door:** two-way
Test-only, plus one AGENTS.md paragraph. Reverting restores the old
assertions.
**Blast Radius:** tests
The assertions are stricter: `check-health` must now report exactly 5
documents and `get-collection-stats` an exact `numDocs`, where any `5` in the
payload used to pass. #270 adds tests to `McpClientIntegrationTestBase` and the
same two imports, so whichever of the two merges second needs a one-line import
rebase.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]