test(workflow-operator): add unit test coverage for visualization chart-config classes#5697
test(workflow-operator): add unit test coverage for visualization chart-config classes#5697aglinxinyuan wants to merge 2 commits into
Conversation
…rt-config classes Pins behavior of four previously-uncovered Jackson-annotated configs in `common/workflow-operator/operator/visualization/`: - `TablesConfig` — required attributeName, @NotNull contract - `NestedTableConfig` — three fields, wire-key renaming for newName, required vs. optional split - `FigureFactoryTableConfig` — single required attributeName + autofill - `DumbbellDotConfig` — wire-key renaming for dotValue, @NotNull + autofill, plus the class-level @JsonSchemaInject restricting `dot` to numeric attribute types Each spec pins defaults, mutability, JSON round-trip, instance independence, and the Jackson + jakarta-validation annotations via reflection — drift in any of those breaks UI dropdown behavior or silently bypasses required-field validation. Closes apache#5694
There was a problem hiding this comment.
Pull request overview
This PR adds Scala unit specs to pin the Jackson/validation/metadata-annotation contracts of four visualization operator config “bag” classes under common/workflow-operator/operator/visualization/, addressing the missing coverage described in #5694. It focuses on defaults, mutability, JSON serde round-trips, and reflection-based annotation checks, without changing production code.
Changes:
- Added
AnyFlatSpec-based unit tests forTablesConfig,NestedTableConfig,FigureFactoryTableConfig, andDumbbellDotConfig. - Verified
@JsonProperty(required = true)(and where relevant,@JsonProperty(value=...)) contracts via reflection. - Added JSON round-trip tests using the project
JSONUtils.objectMapper.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/tablesChart/TablesConfigSpec.scala | Adds unit coverage for TablesConfig defaults/mutability/serde/annotation contract. |
| common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/nestedTable/NestedTableConfigSpec.scala | Adds unit coverage for NestedTableConfig, including the newName ↔ wire-key name mapping. |
| common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/figureFactoryTable/FigureFactoryTableConfigSpec.scala | Adds unit coverage for FigureFactoryTableConfig, including @AutofillAttributeName. |
| common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/dumbbellPlot/DumbbellDotConfigSpec.scala | Adds unit coverage for DumbbellDotConfig, including wire-key dot and schema-inject annotation presence. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5697 +/- ##
============================================
- Coverage 52.79% 52.63% -0.16%
+ Complexity 2548 2542 -6
============================================
Files 1090 1090
Lines 42150 42150
Branches 4529 4529
============================================
- Hits 22253 22186 -67
- Misses 18575 18656 +81
+ Partials 1322 1308 -14
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
✅ No material benchmark regressions detected🟢 0 better · 🔴 0 worse · ⚪ 15 noise (<±5%) · 0 without baseline
Baseline detailsLatest main
Raw CSVconfig_idx,batch_size,schema_width,string_len,num_batches,total_ms,total_tuples,total_bytes,tuples_per_sec,mb_per_sec,lat_p50_us,lat_p95_us,lat_p99_us
0,10,10,64,20,508.55,200,128000,393,0.240,24869.42,36240.77,36240.77
1,100,10,64,20,2467.42,2000,1280000,811,0.495,122359.19,144486.26,144486.26
2,1000,10,64,20,21347.09,20000,12800000,937,0.572,1076053.62,1140882.58,1140882.58 |
- Reword "jakarta validation" -> "javax.validation" in TablesConfigSpec and DumbbellDotConfigSpec (codebase uses javax.validation.constraints). - Pin @AutofillAttributeName on TablesConfig.attributeName via reflection (UI-dropdown contract; parallel to FigureFactoryTableConfig). - Replace string-contains assertions on serialized JSON with ObjectMapper.readTree + JsonNode lookups in NestedTableConfigSpec and DumbbellDotConfigSpec, so the wire-key tests stay robust to Jackson formatting changes (spaces, key ordering).
What changes were proposed in this PR?
Pin behavior of four previously-uncovered Jackson-annotated config classes that back visualization operators in
common/workflow-operator/operator/visualization/. No production-code changes.TablesConfigSpecTablesConfigNestedTableConfigSpecNestedTableConfigFigureFactoryTableConfigSpecFigureFactoryTableConfigDumbbellDotConfigSpecDumbbellDotConfigAll four spec files follow the
<srcClassName>Spec.scalaone-to-one convention.Behavior pinned (each class)
varfields are assignable post-constructionobjectMapper.writeValueAsString+readValue@JsonProperty(required = true)annotationnewcallsPer-class specifics
TablesConfigSpec@NotNullannotation onattributeName(jakarta validation)NestedTableConfigSpecnewNameserializes under wire-keyname(per@JsonProperty(value = "name")); the field namenewNameMUST NOT appear as a JSON key; deserialization from{"name":...}re-populatesnewNameFigureFactoryTableConfigSpec@AutofillAttributeNameannotation onattributeName(UI dropdown contract)DumbbellDotConfigSpecdotValueserializes under wire-keydot;@NotNull+@AutofillAttributeNameannotations; class-level@JsonSchemaInjectrestrictsdotto integer/long/double attribute typesAny related issues, documentation, discussions?
Closes #5694.
How was this PR tested?
Pure unit-test additions; verified locally with:
sbt "WorkflowOperator/testOnly org.apache.texera.amber.operator.visualization.tablesChart.TablesConfigSpec org.apache.texera.amber.operator.visualization.nestedTable.NestedTableConfigSpec org.apache.texera.amber.operator.visualization.figureFactoryTable.FigureFactoryTableConfigSpec org.apache.texera.amber.operator.visualization.dumbbellPlot.DumbbellDotConfigSpec"— 32 tests, all greensbt scalafmtCheckAll— cleanWas this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.7 [1M context])