Skip to content

CAMEL-23688: camel-jbang - add unit tests for catalog listing commands#24204

Open
ammachado wants to merge 1 commit into
apache:mainfrom
ammachado:CAMEL-23688
Open

CAMEL-23688: camel-jbang - add unit tests for catalog listing commands#24204
ammachado wants to merge 1 commit into
apache:mainfrom
ammachado:CAMEL-23688

Conversation

@ammachado

Copy link
Copy Markdown
Contributor

Description

Continues the CAMEL-23688 effort to build a regression safety net around the camel-jbang CLI commands before a planned refactor. After the action/ 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 CatalogBaseCommand and loading the bundled DefaultCamelCatalog:

  • CatalogComponentTest (component) - lists kafka; --filter narrowing; --json output; no-match --filter suggestion branch.
  • CatalogDataFormatTest (dataformat) - lists jaxb; --filter narrowing.
  • CatalogLanguageTest (language) - lists simple; --filter narrowing.
  • CatalogOtherTest (other) - lists cli-connector; --filter narrowing.
  • CatalogTransformerTest (transformer) - lists application-octet-stream; --filter narrowing.
  • CatalogDevConsoleTest (dev-console) - lists context; --filter narrowing.

The tests need no ProcessHandle/status-file harness: they construct the command directly (mirroring CatalogDocTest), set the --sort option that picocli would otherwise default, run doCall(), and assert specific catalog entries in the rendered output.

Bug fixed

The transformer --filter test surfaced a real, pre-existing NullPointerException: camel catalog transformer --filter=<anything> crashed because CatalogBaseCommand's filter predicate dereferenced the row's description and label without a null check. Transformer catalog models legitimately have a null description 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 future collectRows implementation.

Out of scope (deferred)

CatalogKamelet downloads camel-kamelets-catalog from Maven and reflectively loads KameletsCatalog; offline, a unit test reaches only its catch -> return 1 branch, so it needs an integration-style test and is not included here.

Target

  • I checked that the commit is targeting the correct branch (Camel 4 uses the main branch)

Tracking

  • If this is a large change, bug fix, or code improvement, I checked there is a JIRA issue filed for the change (usually before you start working on it).

Apache Camel coding standards and style

  • I checked that each commit in the pull request has a meaningful subject line and body.
  • I have run mvn clean install -DskipTests locally from root folder and I have committed all auto-generated changes.

Claude Code on behalf of Adriano Machado

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 davsclaus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ammachado ammachado marked this pull request as ready for review June 24, 2026 02:53
@github-actions github-actions Bot added the dsl label Jun 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@github-actions

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • dsl/camel-jbang/camel-jbang-core

⚠️ Some tests are disabled on GitHub Actions (@DisabledIfSystemProperty(named = "ci.env.name")) and require manual verification:

  • dsl/camel-jbang/camel-jbang-core: 1 test(s) disabled on GitHub Actions

💡 Manual integration tests recommended:

You modified dsl/camel-jbang/camel-jbang-core. The related integration tests in dsl/camel-jbang/camel-jbang-it are excluded from CI. Consider running them manually:

mvn verify -f dsl/camel-jbang/camel-jbang-it -Djbang-it-test
All tested modules (6 modules)
  • Camel :: JBang :: Core
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Launcher :: Container

⚙️ View full build and test results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants