Skip to content

Conversation

@rjrudin
Copy link
Contributor

@rjrudin rjrudin commented Dec 29, 2025

This doesn't test incremental writes yet, but it will soon. Just want to get a "real" test in place that wipes data from the database before it starts. Also toying with a template approach for WriteBatcher, so made DataMovementManager Closeable which is a non-breaking change.

Copilot AI review requested due to automatic review settings December 29, 2025 23:54
@github-actions
Copy link

github-actions bot commented Dec 29, 2025

Copyright Validation Results
Total: 4 | Passed: 4 | Failed: 0 | Skipped: 0 | at: 2025-12-30 01:08:01 UTC | commit: d457c72

✅ Valid Files

  • marklogic-client-api/src/main/java/com/marklogic/client/datamovement/DataMovementManager.java
  • marklogic-client-api/src/test/java/com/marklogic/client/test/AbstractClientTest.java
  • marklogic-client-api/src/test/java/com/marklogic/client/test/datamovement/IncrementalWriteTest.java
  • marklogic-client-api/src/test/java/com/marklogic/client/test/rows/AbstractOpticUpdateTest.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 initial integration with marklogic-junit5 for improved test data management and adds an experimental WriteBatcher template pattern. The main purpose is to establish a proper test cleanup mechanism that wipes data from the database before tests run, replacing the previous pattern of manual deletion in individual test classes.

Key changes:

  • Introduces AbstractClientTest base class that automatically deletes test documents before each test run using marklogic-junit5
  • Makes DataMovementManager implement Closeable for better resource management
  • Adds IncrementalWriteTest demonstrating both the new test base class and an experimental WriteBatcher template pattern

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
marklogic-client-api/src/test/java/com/marklogic/client/test/AbstractClientTest.java New base class providing automatic test data cleanup via marklogic-junit5 integration
marklogic-client-api/src/test/java/com/marklogic/client/test/rows/AbstractOpticUpdateTest.java Updated to extend AbstractClientTest and removed manual URI deletion code
marklogic-client-api/src/test/java/com/marklogic/client/test/datamovement/IncrementalWriteTest.java New test demonstrating AbstractClientTest usage and experimental WriteBatcher template pattern
marklogic-client-api/src/main/java/com/marklogic/client/datamovement/DataMovementManager.java Made Closeable with default close() implementation for try-with-resources support

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

void test() {
AtomicInteger writtenCount = new AtomicInteger();

WriteBatcherTemplate template = new WriteBatcherTemplate(Common.newClient());
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

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

The WriteBatcherTemplate instance is created but never explicitly closed, which could lead to resource leaks since it holds a DatabaseClient. Consider using try-with-resources or explicitly closing the client after use.

Copilot uses AI. Check for mistakes.
@Override
protected final String getJavascriptForDeletingDocumentsBeforeTestRuns() {
return """
declareUpdate();
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

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

The excluded collections 'test-data' and 'temporal-collection' should be documented to explain why they are preserved during test cleanup, as this filtering logic is critical for test data management.

Suggested change
declareUpdate();
declareUpdate();
// Preserve documents in the 'test-data' and 'temporal-collection' collections because they are
// created as part of deploying the test application (including temporal configuration) and must
// persist across test runs.

Copilot uses AI. Check for mistakes.
This doesn't test incremental writes yet, but it will soon. Just want to get a "real" test in place that wipes data from the database before it starts. Also toying with a template approach for WriteBatcher, so made DataMovementManager Closeable which is a non-breaking change.
@rjrudin rjrudin force-pushed the feature/26420-real-test branch from a37b359 to d457c72 Compare December 30, 2025 01:07
@rjrudin rjrudin merged commit 3e84b5c into develop Dec 30, 2025
3 checks passed
@rjrudin rjrudin deleted the feature/26420-real-test branch December 30, 2025 14:40
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.

3 participants