Skip to content

Open Food Facts as search provider#1294

Open
axgiri wants to merge 6 commits into
Epic-Breakfast-Productions:developmentfrom
axgiri:dev/698-plugin-ExtItemSearch-add-openfoodfacts-as-seatch-provider
Open

Open Food Facts as search provider#1294
axgiri wants to merge 6 commits into
Epic-Breakfast-Productions:developmentfrom
axgiri:dev/698-plugin-ExtItemSearch-add-openfoodfacts-as-seatch-provider

Conversation

@axgiri

@axgiri axgiri commented Jun 13, 2026

Copy link
Copy Markdown
Member

Checklist:

  • Tested

#698

Summary by CodeRabbit

  • Tests
    • Added comprehensive test coverage for item category REST API endpoints, including creation, updates, deletion, and error handling scenarios.

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 16a3f164-89dc-487d-808c-39855a892acc

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR adds a comprehensive integration test suite for the ItemCategories REST CRUD endpoints alongside supporting test infrastructure configuration. The test class validates successful operations, error handling, and field preservation behavior. Configuration updates include gitignore patterns for development tooling and mock service mappings for external API error scenarios.

Changes

ItemCategories CRUD Integration Tests and Configuration

Layer / File(s) Summary
ItemCategories CRUD Integration Test Suite
software/core/oqm-core-api/src/test/java/tech/ebp/oqm/core/api/interfaces/endpoints/inventory/ItemCategoriesCrudTest.java
Introduces ItemCategoriesCrudTest with seven integration tests exercising POST/PUT/DELETE/GET operations: createTest validates successful creation with persisted fields, createInvalidTest asserts 400 on empty name, updateTest verifies name updates while preserving unmapped description, updateNotFoundTest and deleteNotFoundTest assert 404 with error message content, deleteTest confirms cascading 404 on subsequent fetch, and getNotFoundTest validates not-found error messaging on fetch by id.
Test Infrastructure Configuration
software/plugins/external-item-search/.gitignore, software/plugins/external-item-search/dev/services/mappings/openfoodfacts/openfoodfacts_barcode_not_found.json, software/plugins/external-item-search/dev/services/mappings/openfoodfacts/openfoodfacts_search_not_found.json
Git ignores expanded for Quarkus CLI plugins and Eclipse IDE artifacts with **/-scoped patterns. OpenFoodFacts mock mappings added for barcode lookup returning 404 with product_not_found error and search endpoint returning HTTP 200 with empty product list for the specified query parameters.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

  • #1272 - This PR directly implements the ItemCategories REST endpoint CRUD tests requested in that feature requirement, fulfilling the integration test coverage scope.

Poem

🧭 Hoist the anchor, all is shipshape and proper!
Seven tests now chart the Categories fair,
Mock winds and waves from OpenFoodFacts waters,
.gitignore tended with a seasoned care,
This vessel's hold is packed with testing treasure! ⚓

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description follows the template structure with the checklist present, though the 'Tested' item remains unchecked and no additional context beyond issue reference #698 is provided.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed Title refers to OpenFoodFacts integration as search provider, which is supported by mock mappings and test enhancements in the changeset, aligning with PR objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@axgiri axgiri changed the base branch from main to development June 13, 2026 18:59

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🧹 Nitpick comments (2)
software/core/oqm-core-api/src/test/java/tech/ebp/oqm/core/api/interfaces/endpoints/inventory/ItemCategoriesCrudTest.java (1)

150-150: 💤 Low value

Avast! Use the imported ObjectId rather than its full title.

Lines 150 and 165 be using the full org.bson.types.ObjectId() when ObjectId already be imported at line 9. Redundant it is—keep it shipshape by using just ObjectId() like a proper deckhand.

⚓ Proposed trim for the rigging
-        ErrorMessage errorMessage = setupJwtCall(given(), testUser.getAttributes().get(TestUserService.TEST_JWT_ATT_KEY))
-            .pathParam("oqmDbIdOrName", DEFAULT_TEST_DB_NAME)
-            .pathParam("id", new org.bson.types.ObjectId().toHexString())
+        ErrorMessage errorMessage = setupJwtCall(given(), testUser.getAttributes().get(TestUserService.TEST_JWT_ATT_KEY))
+            .pathParam("oqmDbIdOrName", DEFAULT_TEST_DB_NAME)
+            .pathParam("id", new ObjectId().toHexString())

And line 165 similarly:

-        ErrorMessage errorMessage = setupJwtCall(given(), testUser.getAttributes().get(TestUserService.TEST_JWT_ATT_KEY))
-            .pathParam("oqmDbIdOrName", DEFAULT_TEST_DB_NAME)
-            .pathParam("id", new org.bson.types.ObjectId().toHexString())
+        ErrorMessage errorMessage = setupJwtCall(given(), testUser.getAttributes().get(TestUserService.TEST_JWT_ATT_KEY))
+            .pathParam("oqmDbIdOrName", DEFAULT_TEST_DB_NAME)
+            .pathParam("id", new ObjectId().toHexString())

Also applies to: 165-165

software/plugins/external-item-search/.gitignore (1)

45-46: 💤 Low value

Hoist the colors on partial redundancy in the gitignore sail.

Lines 45–46 add recursive patterns for .settings/ and .project using the **/ prefix, but the root-level versions already exist at lines 6 and 8. The recursive patterns will catch those too, but the old patterns remain. While no functional harm be done, it be cluttering the manifest. Consider consolidating by removing the root-only patterns and keeping only the recursive ones—or keeping root-only if the intent be to match only at the project root.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ecb8b30c-e0ba-48f3-bda9-7e6e9444cc79

📥 Commits

Reviewing files that changed from the base of the PR and between 87f39a7 and 749d886.

📒 Files selected for processing (7)
  • software/core/oqm-core-api/src/test/java/tech/ebp/oqm/core/api/interfaces/endpoints/inventory/ItemCategoriesCrudTest.java
  • software/plugins/external-item-search/.gitignore
  • software/plugins/external-item-search/dev/services/mappings/openfoodfacts/README.md
  • software/plugins/external-item-search/dev/services/mappings/openfoodfacts/openfoodfacts_barcode.json
  • software/plugins/external-item-search/dev/services/mappings/openfoodfacts/openfoodfacts_barcode_not_found.json
  • software/plugins/external-item-search/dev/services/mappings/openfoodfacts/openfoodfacts_search.json
  • software/plugins/external-item-search/dev/services/mappings/openfoodfacts/openfoodfacts_search_not_found.json
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: CI-Pipeline / Build
  • GitHub Check: CI-Pipeline / Build
🔇 Additional comments (1)
software/plugins/external-item-search/dev/services/mappings/openfoodfacts/openfoodfacts_search_not_found.json (1)

1-28: LGTM! This mock mapping be trimmed and ready—proper structure for an empty search result at HTTP 200. All fields present and accounted for. Shipshape!

@@ -0,0 +1,40 @@
{
"request": {
"urlPathPattern": "/openfoodfacts/api/v3/product/30469200297590000",

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.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Blimey! The barcode in the response body don't match the request URL—a breach in the hull!

Mark me words: the request be seeking product barcode 30469200297590000 (17 digits), but the response body declares code 304692002975000 (15 digits—missing the leading "00"). This mismatch means the mock may not be matched correctly by the test infrastructure, or if matched, the client code checking the returned code against the requested barcode will spot a discrepancy.

Correct the code field in the response body to 30469200297590000 to match the barcode in the request URL.

⚓ Proposed fix to seal the breach
 	"jsonBody": {
-		"code": "304692002975000",
+		"code": "30469200297590000",
 		"errors": [

Also applies to: 12-12

@axgiri axgiri force-pushed the dev/698-plugin-ExtItemSearch-add-openfoodfacts-as-seatch-provider branch from 749d886 to 69a4aa3 Compare June 13, 2026 19:04
@axgiri axgiri changed the title Enhance ItemCategory tests and add example data assertions Open Food Facts as search provider Jun 13, 2026
@axgiri axgiri marked this pull request as draft June 13, 2026 21:14
@axgiri axgiri marked this pull request as ready for review June 15, 2026 12:00
@axgiri

axgiri commented Jun 16, 2026

Copy link
Copy Markdown
Member Author

will work on #1295

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