aglinxinyuan commented on code in PR #5827:
URL: https://github.com/apache/texera/pull/5827#discussion_r3445627050


##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/htmlviz/HtmlVizOpDescSpec.scala:
##########
@@ -0,0 +1,69 @@
+/*
+ * 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.htmlviz
+
+import org.apache.texera.amber.core.executor.OpExecWithClassName
+import org.apache.texera.amber.core.tuple.{Attribute, AttributeType, Schema}
+import org.apache.texera.amber.core.virtualidentity.{ExecutionIdentity, 
WorkflowIdentity}
+import org.apache.texera.amber.core.workflow.PortIdentity
+import org.apache.texera.amber.operator.metadata.OperatorGroupConstants
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
+
+class HtmlVizOpDescSpec extends AnyFlatSpec with Matchers {
+
+  private val workflowId = WorkflowIdentity(1L)
+  private val executionId = ExecutionIdentity(1L)
+
+  "HtmlVizOpDesc.operatorInfo" should "advertise the name and Media 
visualization group" in {
+    val info = (new HtmlVizOpDesc).operatorInfo
+    info.userFriendlyName shouldBe "HTML Visualizer"
+    info.operatorGroupName shouldBe 
OperatorGroupConstants.VISUALIZATION_MEDIA_GROUP
+    info.inputPorts should have length 1
+    info.outputPorts should have length 1
+  }
+
+  "HtmlVizOpDesc.htmlContentAttrName" should "default to the empty string" in {
+    (new HtmlVizOpDesc).htmlContentAttrName shouldBe ""
+  }
+
+  "HtmlVizOpDesc.getPhysicalOp" should "wire HtmlVizOpExec and carry port 
identities" in {
+    val op = new HtmlVizOpDesc
+    op.htmlContentAttrName = "html"
+    val physical = op.getPhysicalOp(workflowId, executionId)
+    physical.opExecInitInfo match {
+      case OpExecWithClassName(className, descString) =>
+        className shouldBe 
"org.apache.texera.amber.operator.visualization.htmlviz.HtmlVizOpExec"
+        descString should not be empty
+      case other => fail(s"expected OpExecWithClassName, got $other")
+    }
+    physical.inputPorts.keySet shouldBe 
op.operatorInfo.inputPorts.map(_.id).toSet
+    physical.outputPorts.keySet shouldBe 
op.operatorInfo.outputPorts.map(_.id).toSet
+  }
+
+  "HtmlVizOpDesc schema propagation" should
+    "emit a single html-content STRING column regardless of input" in {
+    val op = new HtmlVizOpDesc
+    op.htmlContentAttrName = "html"
+    val input = Schema().add(new Attribute("html", AttributeType.STRING))
+    val out = op.getExternalOutputSchemas(Map(PortIdentity() -> 
input)).values.head
+    out shouldBe Schema().add("html-content", AttributeType.STRING)

Review Comment:
   Good point — strengthened in 77e5b3a232. `HtmlVizOpDescSpec` now asserts the 
full `getExternalOutputSchemas` map equals 
`Map(operatorInfo.outputPorts.head.id -> Schema().add("html-content", 
STRING))`, and feeds the input under `operatorInfo.inputPorts.head.id` — so a 
wrong output-port key now fails.



##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/candlestickChart/CandlestickChartOpDescSpec.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.candlestickChart
+
+import org.apache.texera.amber.core.tuple.{AttributeType, Schema}
+import org.apache.texera.amber.core.workflow.PortIdentity
+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 CandlestickChartOpDescSpec extends AnyFlatSpec with Matchers {
+
+  private def configured(): CandlestickChartOpDesc = {
+    val d = new CandlestickChartOpDesc
+    d.date = "day"
+    d.open = "o"
+    d.high = "h"
+    d.low = "l"
+    d.close = "c"
+    d
+  }
+
+  "CandlestickChartOpDesc.operatorInfo" should
+    "advertise the name and Financial visualization group" in {
+    val info = (new CandlestickChartOpDesc).operatorInfo
+    info.userFriendlyName shouldBe "Candlestick Chart"
+    info.operatorGroupName shouldBe 
OperatorGroupConstants.VISUALIZATION_FINANCIAL_GROUP
+    info.inputPorts should have length 1
+    info.outputPorts should have length 1
+  }
+
+  "CandlestickChartOpDesc" should "default all OHLC column fields to the empty 
string" in {
+    val d = new CandlestickChartOpDesc
+    d.date shouldBe ""
+    d.open shouldBe ""
+    d.high shouldBe ""
+    d.low shouldBe ""
+    d.close shouldBe ""
+  }
+
+  "CandlestickChartOpDesc.getOutputSchemas" should
+    "produce a single html-content STRING column" in {
+    val out =
+      (new CandlestickChartOpDesc).getOutputSchemas(Map(PortIdentity() -> 
Schema())).values.head
+    out shouldBe Schema().add("html-content", AttributeType.STRING)

Review Comment:
   Done in 77e5b3a232 — `CandlestickChartOpDescSpec` now asserts 
`getOutputSchemas` returns `Map(operatorInfo.outputPorts.head.id -> 
<html-content schema>)` (full map, keyed by the declared output port), not just 
`.values.head`.



##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/histogram2d/Histogram2DOpDescSpec.scala:
##########
@@ -0,0 +1,91 @@
+/*
+ * 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.histogram2d
+
+import org.apache.texera.amber.core.tuple.{AttributeType, Schema}
+import org.apache.texera.amber.core.workflow.PortIdentity
+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 Histogram2DOpDescSpec extends AnyFlatSpec with Matchers {
+
+  private def configured(): Histogram2DOpDesc = {
+    val d = new Histogram2DOpDesc
+    d.xColumn = "x"
+    d.yColumn = "y"
+    d
+  }
+
+  "Histogram2DOpDesc.operatorInfo" should
+    "advertise the name and Statistical visualization group" in {
+    val info = (new Histogram2DOpDesc).operatorInfo
+    info.userFriendlyName shouldBe "Histogram2D"
+    info.operatorGroupName shouldBe 
OperatorGroupConstants.VISUALIZATION_STATISTICAL_GROUP
+    info.inputPorts should have length 1
+    info.outputPorts should have length 1
+  }
+
+  "Histogram2DOpDesc" should "default bins to 10 and normalization to DENSITY" 
in {
+    val d = new Histogram2DOpDesc
+    d.xBins shouldBe 10
+    d.yBins shouldBe 10
+    d.normalize shouldBe NormalizationType.DENSITY
+    d.xColumn shouldBe ""
+    d.yColumn shouldBe ""
+  }
+
+  "Histogram2DOpDesc.getOutputSchemas" should "produce a single html-content 
STRING column" in {
+    val out =
+      (new Histogram2DOpDesc).getOutputSchemas(Map(PortIdentity() -> 
Schema())).values.head
+    out shouldBe Schema().add("html-content", AttributeType.STRING)

Review Comment:
   Done in 77e5b3a232 — same key assertion applied to `Histogram2DOpDescSpec`: 
it now pins `Map(operatorInfo.outputPorts.head.id -> <html-content schema>)`.



-- 
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