Skip to content

MLE-26966 Added mock of NuaClient for testing#611

Merged
rjrudin merged 1 commit intodevelopfrom
feature/nuclia-tests
Feb 5, 2026
Merged

MLE-26966 Added mock of NuaClient for testing#611
rjrudin merged 1 commit intodevelopfrom
feature/nuclia-tests

Conversation

@rjrudin
Copy link
Contributor

@rjrudin rjrudin commented Feb 5, 2026

Not testing any connection to Nuclia, but able to test that the model-name and chunk-metadata are handled correctly.

NuaClient is now an interface, DefaultNuaClient is the impl, and MockNuaClient is for testing.

Copilot AI review requested due to automatic review settings February 5, 2026 19:14
@github-actions
Copy link

github-actions bot commented Feb 5, 2026

Copyright Validation Results
Total: 8 | Passed: 8 | Failed: 0 | Skipped: 0 | at: 2026-02-05 19:29:06 UTC | commit: fc54dfc

✅ Valid Files

  • marklogic-spark-connector/src/main/java/com/marklogic/spark/core/DocumentPipeline.java
  • marklogic-spark-connector/src/main/java/com/marklogic/spark/core/DocumentPipelineFactory.java
  • marklogic-spark-connector/src/main/java/com/marklogic/spark/core/nuclia/DefaultNuaClient.java
  • marklogic-spark-connector/src/main/java/com/marklogic/spark/core/nuclia/MockNuaClient.java
  • marklogic-spark-connector/src/main/java/com/marklogic/spark/core/nuclia/NuaClient.java
  • marklogic-spark-connector/src/main/java/com/marklogic/spark/core/nuclia/NucliaDocumentProcessor.java
  • marklogic-spark-connector/src/test/java/com/marklogic/spark/core/DocumentPipelineFactoryTest.java
  • marklogic-spark-connector/src/test/java/com/marklogic/spark/writer/nuclia/ProcessWithNucliaTest.java

✅ All files have valid copyright headers!

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a mock implementation of the Nuclia Understanding API (NUA) client to enable testing without making actual API calls. The changes refactor NucliaClient into an interface-based design with DefaultNuaClient as the implementation and MockNuaClient for testing purposes.

Changes:

  • Extracted NuaClient interface from the original NucliaClient class
  • Renamed NucliaClient to DefaultNuaClient and made it implement NuaClient
  • Added MockNuaClient for testing with canned responses
  • Updated all references throughout the codebase from NucliaClient to NuaClient/DefaultNuaClient

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
ProcessWithNucliaTest.java New integration test using MockNuaClient to verify chunk processing and metadata handling
DocumentPipelineFactoryTest.java Updated test assertions to use renamed getNuaClient() method
NucliaDocumentProcessor.java Updated to use NuaClient interface instead of concrete class
NuaClient.java New interface defining the contract for Nuclia API interactions
MockNuaClient.java New mock implementation returning canned responses for testing
DefaultNuaClient.java Renamed from NucliaClient, now implements NuaClient interface
DocumentPipelineFactory.java Updated to instantiate MockNuaClient or DefaultNuaClient based on configuration
DocumentPipeline.java Updated to use NuaClient interface and simplified resource cleanup

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


final String expectedChunkUri = "/split-test.json-extracted-text.json-chunks-1.xml";
XmlNode doc = readXmlDocument(expectedChunkUri);
System.out.println(doc.getPrettyXml());
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

Debug print statement should be removed before merging to production code. Use a logger instead if this output is needed for debugging purposes.

Suggested change
System.out.println(doc.getPrettyXml());

Copilot uses AI. Check for mistakes.
Not testing any connection to Nuclia, but able to test that the model-name and chunk-metadata are handled correctly.

NuaClient is now an interface, DefaultNuaClient is the impl, and MockNuaClient is for testing.
@rjrudin rjrudin force-pushed the feature/nuclia-tests branch from c6fca45 to fc54dfc Compare February 5, 2026 19:28
@rjrudin rjrudin merged commit 368c389 into develop Feb 5, 2026
4 checks passed
@rjrudin rjrudin deleted the feature/nuclia-tests branch February 5, 2026 19:59
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