Skip to content

test(workflow-core): add unit test coverage for TupleUtils#4910

Merged
aglinxinyuan merged 3 commits into
apache:mainfrom
aglinxinyuan:test-tuple-utils-spec
May 4, 2026
Merged

test(workflow-core): add unit test coverage for TupleUtils#4910
aglinxinyuan merged 3 commits into
apache:mainfrom
aglinxinyuan:test-tuple-utils-spec

Conversation

@aglinxinyuan
Copy link
Copy Markdown
Contributor

@aglinxinyuan aglinxinyuan commented May 4, 2026

What changes were proposed in this PR?

Adds TupleUtilsSpec covering TupleUtils (common/workflow-core/src/main/scala/org/apache/texera/amber/core/tuple/TupleUtils.scala). Today the only exercise of tuple2json / json2tuple is a single round-trip inside TupleSpec; this PR adds dedicated edge-case coverage.

The new spec pins:

  • tuple2json: emits one JSON field per schema attribute in the schema's declared order; fieldVals are indexed via schema.getIndex(name) so a reordered schema selects different slots; null field values become JSON null; an empty schema yields an empty JSON object.
  • json2tuple: schema is inferred from a flat JSON object's keys + types; values round-trip with tuple2json; non-object roots (e.g. JSON arrays) yield an empty tuple rather than silently succeeding with a populated one; malformed JSON throws.

No production code changed; this is test-only.

Any related issues, documentation, discussions?

Closes #4909

How was this PR tested?

Added 8 new unit tests in TupleUtilsSpec. Verified locally:

sbt 'WorkflowCore/Test/testOnly org.apache.texera.amber.core.tuple.TupleUtilsSpec'
# → Tests: succeeded 8, failed 0

sbt 'WorkflowCore/Test/scalafmtCheck'
# → clean

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code

Pin the contract of `TupleUtils`:
- `tuple2json` emits one JSON field per schema attribute in the schema's
  declared order, indexes `fieldVals` via `schema.getIndex` (so a reordered
  schema picks different slots), emits JSON null for null values, and
  yields an empty object for an empty schema.
- `json2tuple` infers a schema from a flat JSON object, round-trips faithfully
  alongside `tuple2json`, drops non-object roots into an empty tuple
  (rather than silently succeeding with a populated tuple), and throws on
  malformed JSON.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.66%. Comparing base (6da0a35) to head (2e8cd43).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #4910      +/-   ##
============================================
+ Coverage     42.04%   47.66%   +5.62%     
- Complexity     2155     2157       +2     
============================================
  Files           980      818     -162     
  Lines         36292    25952   -10340     
  Branches       3783     2346    -1437     
============================================
- Hits          15260    12371    -2889     
+ Misses        20108    12833    -7275     
+ Partials        924      748     -176     
Flag Coverage Δ
access-control-service 39.53% <ø> (ø)
amber 42.88% <ø> (+0.01%) ⬆️
computing-unit-managing-service 0.00% <ø> (ø)
config-service 0.00% <ø> (ø)
file-service 33.24% <ø> (ø)
workflow-compiling-service 47.72% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

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

Adds dedicated unit test coverage for TupleUtils in workflow-core, pinning its Tuple ↔ JSON conversion contract and edge-case behavior (per #4909).

Changes:

  • Introduces TupleUtilsSpec with 8 cases covering tuple2json ordering/null/empty-schema behavior and json2tuple inference/round-trip/non-object-root/malformed-JSON behavior.

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

…sSpec

Address Copilot feedback on apache#4910: replace the awkward
`scala.jdk.CollectionConverters.ListHasAsScala(keys).asScala` (which
explicitly constructs the implicit-class wrapper) with the idiomatic
Scala 2.13 form: `import scala.jdk.CollectionConverters._` and call
`.asScala` directly on the returned `java.util.Iterator[String]`. Drops
the intermediate `java.util.ArrayList` buffer entirely.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


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

Copy link
Copy Markdown
Contributor

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


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

Copy link
Copy Markdown
Contributor

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

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


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

@aglinxinyuan aglinxinyuan merged commit 1c6021c into apache:main May 4, 2026
22 checks passed
aglinxinyuan added a commit to aglinxinyuan/texera that referenced this pull request May 4, 2026
…eption

Address Copilot feedback on apache#4910: `intercept[Exception]` was too broad
and would have masked unrelated runtime errors. Pin the intended
failure mode instead — `com.fasterxml.jackson.core.JsonProcessingException`
is the Jackson base class for parse-time failures, so the test now
fails (rather than passes) if some other exception is thrown by
upstream changes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

add unit test coverage for TupleUtils

4 participants