CAMEL-23688: camel-jbang - add unit tests for catalog listing commands#24204
Conversation
Adds unit tests for the offline catalog listing commands: component, dataformat, language, other, transformer and dev-console. They load the bundled DefaultCamelCatalog and assert the rendered listing, the --filter narrowing, plus the JSON output and no-match suggestion branches (on the component test). Also fixes a NullPointerException in CatalogBaseCommand's --filter predicate, which dereferenced row description and label without a null check. Transformer catalog models legitimately have a null description and label, so "camel catalog transformer --filter=..." crashed. The filter now null-guards both fields, covering all catalog list commands. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
davsclaus
left a comment
There was a problem hiding this comment.
Nicely done — clean test coverage for the six offline catalog listing commands, and the null-guard fix in CatalogBaseCommand is a good catch.
The tests follow the existing CatalogDocTest pattern consistently, the bug fix is minimal and correct (transformer entries legitimately have null description/label), and the PR description is thorough with a clear out-of-scope rationale for CatalogKamelet.
No blocking issues. LGTM.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
💡 Manual integration tests recommended:
All tested modules (6 modules)
|
Description
Continues the CAMEL-23688 effort to build a regression safety net around the
camel-jbangCLI commands before a planned refactor. After theaction/package was covered (PRs #24188, #24189, #24199), this PR moves to the next-largest untested cluster,commands/catalog/, which previously had a single test (CatalogDocTest).Adds unit tests for the six offline catalog listing commands, each extending
CatalogBaseCommandand loading the bundledDefaultCamelCatalog:CatalogComponentTest(component) - listskafka;--filternarrowing;--jsonoutput; no-match--filtersuggestion branch.CatalogDataFormatTest(dataformat) - listsjaxb;--filternarrowing.CatalogLanguageTest(language) - listssimple;--filternarrowing.CatalogOtherTest(other) - listscli-connector;--filternarrowing.CatalogTransformerTest(transformer) - listsapplication-octet-stream;--filternarrowing.CatalogDevConsoleTest(dev-console) - listscontext;--filternarrowing.The tests need no
ProcessHandle/status-file harness: they construct the command directly (mirroringCatalogDocTest), set the--sortoption that picocli would otherwise default, rundoCall(), and assert specific catalog entries in the rendered output.Bug fixed
The transformer
--filtertest surfaced a real, pre-existingNullPointerException:camel catalog transformer --filter=<anything>crashed becauseCatalogBaseCommand's filter predicate dereferenced the row'sdescriptionandlabelwithout a null check. Transformer catalog models legitimately have anulldescription and label (unlike component/dataformat/language/other/dev-console), so the command was unusable with a filter. The filter now null-guards both fields, which covers all six listing commands and any futurecollectRowsimplementation.Out of scope (deferred)
CatalogKameletdownloadscamel-kamelets-catalogfrom Maven and reflectively loadsKameletsCatalog; offline, a unit test reaches only itscatch -> return 1branch, so it needs an integration-style test and is not included here.Target
mainbranch)Tracking
Apache Camel coding standards and style
mvn clean install -DskipTestslocally from root folder and I have committed all auto-generated changes.Claude Code on behalf of Adriano Machado