Copilot commented on code in PR #5844:
URL: https://github.com/apache/texera/pull/5844#discussion_r3447913678


##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/dumbbellPlot/DumbbellPlotOpDescSpec.scala:
##########
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.amber.operator.visualization.dumbbellPlot
+
+import org.apache.texera.amber.core.tuple.{AttributeType, Schema}
+import org.apache.texera.amber.operator.LogicalOp
+import org.apache.texera.amber.operator.metadata.OperatorGroupConstants
+import org.apache.texera.amber.util.JSONUtils.objectMapper
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
+
+class DumbbellPlotOpDescSpec extends AnyFlatSpec with Matchers {
+
+  "DumbbellPlotOpDesc.operatorInfo" should
+    "advertise the name and Basic visualization group" in {
+    val info = (new DumbbellPlotOpDesc).operatorInfo
+    info.userFriendlyName shouldBe "Dumbbell Plot"
+    info.operatorGroupName shouldBe 
OperatorGroupConstants.VISUALIZATION_BASIC_GROUP
+    info.inputPorts should have length 1
+    info.outputPorts should have length 1
+  }
+
+  "DumbbellPlotOpDesc" should "default its column fields to empty and 
showLegends to false" in {
+    val d = new DumbbellPlotOpDesc
+    d.categoryColumnName shouldBe ""
+    d.dumbbellStartValue shouldBe ""
+    d.dumbbellEndValue shouldBe ""
+    d.measurementColumnName shouldBe ""
+    d.comparedColumnName shouldBe ""
+    d.showLegends shouldBe false
+  }
+
+  "DumbbellPlotOpDesc.getOutputSchemas" should
+    "produce a single html-content STRING column keyed by the declared output 
port" in {
+    val op = new DumbbellPlotOpDesc
+    op.getOutputSchemas(Map.empty) shouldBe Map(
+      op.operatorInfo.outputPorts.head.id -> Schema().add("html-content", 
AttributeType.STRING)
+    )
+  }
+
+  "DumbbellPlotOpDesc.generatePythonCode" should "emit a Plotly Scatter 
(dumbbell) figure" in {
+    val d = new DumbbellPlotOpDesc
+    d.categoryColumnName = "entity"
+    d.measurementColumnName = "metric"
+    d.comparedColumnName = "phase"
+    d.dumbbellStartValue = "before"
+    d.dumbbellEndValue = "after"
+    val code = d.generatePythonCode()
+    code should include("class ProcessTableOperator(UDFTableOperator)")
+    code should include("go.Scatter(")
+  }
+
+  "DumbbellPlotOpDesc" should "round-trip its column fields through the 
polymorphic base" in {
+    val d = new DumbbellPlotOpDesc
+    d.categoryColumnName = "entity"
+    d.measurementColumnName = "metric"
+    d.comparedColumnName = "phase"
+    d.showLegends = true
+    val restored = objectMapper.readValue(objectMapper.writeValueAsString(d), 
classOf[LogicalOp])
+    restored shouldBe a[DumbbellPlotOpDesc]
+    val dp = restored.asInstanceOf[DumbbellPlotOpDesc]
+    dp.categoryColumnName shouldBe "entity"
+    dp.measurementColumnName shouldBe "metric"
+    dp.comparedColumnName shouldBe "phase"
+    dp.showLegends shouldBe true
+  }

Review Comment:
   The "round-trip" assertion for DumbbellPlotOpDesc doesn't exercise/pin the 
`dumbbellStartValue` / `dumbbellEndValue` fields (they’re part of the 
descriptor config and are used by codegen). Adding them here better matches the 
intent of round-tripping the descriptor’s key configuration through the 
polymorphic base.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to