-
Notifications
You must be signed in to change notification settings - Fork 74
MLE-27881 Add cts.param support to Java Client API #1936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rjdew-progress
wants to merge
1
commit into
develop
Choose a base branch
from
MLE-27881
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # Project Guidelines | ||
|
|
||
| ## Architecture | ||
| - `marklogic-client-api`: core Java client library for interacting with the MarkLogic REST API. | ||
| - `ml-development-tools`: Gradle plugin and generators for Data Services endpoint proxies/tests. | ||
| - `marklogic-client-api-functionaltests`: functional/regression-style tests, split into fragile/fast/slow groups. | ||
| - `test-app`: ml-gradle deployment project that provisions test infrastructure in MarkLogic. | ||
| - `examples`: supporting code used by tests and usage examples. | ||
|
|
||
| ## Build And Test | ||
| - Prefer Gradle from the repo root. | ||
| - Quick compile verification: `./gradlew clean build -x test` | ||
| - Core module tests: `./gradlew marklogic-client-api:test` | ||
| - Plugin tests (includes generated tests workflow): `./gradlew ml-development-tools:test` | ||
| - Functional tests must run in this order to reduce flakiness: | ||
| 1. `./gradlew marklogic-client-api-functionaltests:runFragileTests` | ||
| 2. `./gradlew marklogic-client-api-functionaltests:runFastFunctionalTests` | ||
| 3. `./gradlew marklogic-client-api-functionaltests:runSlowFunctionalTests` | ||
|
|
||
| ## Test Environment | ||
| - Java 17+ is required for current releases. | ||
| - Most tests require a running MarkLogic instance and deployed test resources. | ||
| - Typical setup sequence: | ||
| 1. `docker compose up -d --build` | ||
| 2. `./gradlew -i mlWaitTillReady` | ||
| 3. `./gradlew -i mlDeploy` | ||
| 4. Run module tests | ||
| - Override local MarkLogic connection settings via `gradle-local.properties` (`mlHost`, `mlPassword`). | ||
|
|
||
| ## Quality Controls | ||
| - Treat compile warnings as failures: project builds enforce `-Xlint:unchecked`, `-Xlint:deprecation`, and `-Werror`. | ||
| - Keep dependency security constraints intact (e.g. forced/excluded dependencies for CVE mitigation in Gradle files). | ||
| - When adding or changing first-party Java/Kotlin code, run security scanning steps used by this workspace workflow before finalizing changes. | ||
| - Do not relax quality gates (tests/compilation) to make a change pass; fix the underlying issue. | ||
|
|
||
| ## Code Generation And Automation | ||
| - Data Services proxy generation is automated; use `generateEndpointProxies` instead of hand-writing proxy classes. | ||
| - `ml-development-tools` test automation uses `generateTests` and `fixMjsModulesForMarkLogic12` before `test`. | ||
| - Generated sources commonly include an "IMPORTANT: Do not edit" header. Regenerate from source declarations instead of editing generated output directly. | ||
| - For changes affecting generation logic, validate both generator behavior and generated artifact compilation/tests. | ||
|
|
||
| ## Conventions For Changes | ||
| - Keep edits scoped to the target module; avoid cross-module churn unless required. | ||
| - Prefer existing patterns in nearby code over introducing new abstractions. | ||
| - For test-related fixes, document whether behavior changes impact unit tests, functional tests, or deployment setup. | ||
|
|
||
| ## Docs To Link (Do Not Duplicate) | ||
| - `README.md`: product overview, dependency usage, Java compatibility. | ||
| - `CONTRIBUTING.md`: local build/test workflow and MarkLogic test setup. | ||
| - `ml-development-tools/src/test/example-project/README.md`: plugin-focused usage/testing notes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
marklogic-client-api/src/test/java/com/marklogic/client/impl/CtsParamExprTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /* | ||
| * Copyright (c) 2010-2026 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved. | ||
| */ | ||
| package com.marklogic.client.impl; | ||
|
|
||
| import com.fasterxml.jackson.databind.node.ObjectNode; | ||
| import com.marklogic.client.expression.PlanBuilder; | ||
| import com.marklogic.client.io.JacksonHandle; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
|
||
| public class CtsParamExprTest { | ||
|
|
||
| @Test | ||
| void exportsCtsParamInCollectionQuery() { | ||
| PlanBuilderSubImpl p = new PlanBuilderSubImpl(); | ||
|
|
||
| PlanBuilder.ModifyPlan employeesPlan = p | ||
| .fromView("main", "employees") | ||
| .select(p.col("EmployeeID"), p.col("FirstName"), p.col("LastName")) | ||
| .where(p.cts.collectionQuery(p.cts.param("collection"))); | ||
|
|
||
| JacksonHandle handle = new JacksonHandle(); | ||
| employeesPlan.export(handle); | ||
| ObjectNode exportNode = (ObjectNode) handle.get(); | ||
|
|
||
| assertEquals("op", exportNode.path("$optic").path("ns").asText()); | ||
| assertEquals("operators", exportNode.path("$optic").path("fn").asText()); | ||
| assertEquals("from-view", exportNode.path("$optic").path("args").get(0).path("fn").asText()); | ||
| assertEquals("select", exportNode.path("$optic").path("args").get(1).path("fn").asText()); | ||
| assertEquals("where", exportNode.path("$optic").path("args").get(2).path("fn").asText()); | ||
| assertEquals("collection-query", exportNode.path("$optic").path("args").get(2).path("args").get(0).path("fn").asText()); | ||
| assertEquals("param", exportNode.path("$optic").path("args").get(2).path("args").get(0).path("args").get(0).path("fn").asText()); | ||
| assertEquals("cts", exportNode.path("$optic").path("args").get(2).path("args").get(0).path("args").get(0).path("ns").asText()); | ||
| assertEquals("collection", exportNode.path("$optic").path("args").get(2).path("args").get(0).path("args").get(0).path("args").get(0).asText()); | ||
| } | ||
|
|
||
| @Test | ||
| void rejectsOpParamInCtsNamespace() { | ||
| PlanBuilderSubImpl p = new PlanBuilderSubImpl(); | ||
|
|
||
| IllegalArgumentException ex = assertThrows( | ||
| IllegalArgumentException.class, | ||
| () -> p.cts.collectionQuery(p.param("collection")) | ||
| ); | ||
|
|
||
| assertEquals( | ||
| "Cannot pass op:param() to cts:collection-query(). Use cts:param() for cts namespace expressions.", | ||
| ex.getMessage() | ||
| ); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.