test(workflow-core): add unit test coverage for TupleUtils#4910
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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
TupleUtilsSpecwith 8 cases coveringtuple2jsonordering/null/empty-schema behavior andjson2tupleinference/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>
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
…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>
What changes were proposed in this PR?
Adds
TupleUtilsSpeccoveringTupleUtils(common/workflow-core/src/main/scala/org/apache/texera/amber/core/tuple/TupleUtils.scala). Today the only exercise oftuple2json/json2tupleis a single round-trip insideTupleSpec; 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;fieldValsare indexed viaschema.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 withtuple2json; 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:Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code