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


##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/substringSearch/SubstringSearchOpDescSpec.scala:
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.substringSearch
+
+import org.apache.texera.amber.core.executor.OpExecWithClassName
+import org.apache.texera.amber.core.virtualidentity.{ExecutionIdentity, 
WorkflowIdentity}
+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 SubstringSearchOpDescSpec extends AnyFlatSpec with Matchers {
+
+  private val workflowId = WorkflowIdentity(1L)
+  private val executionId = ExecutionIdentity(1L)
+
+  private def newDesc(attr: String, sub: String, caseSensitive: Boolean): 
SubstringSearchOpDesc = {
+    val d = new SubstringSearchOpDesc
+    d.attribute = attr
+    d.substring = sub
+    d.isCaseSensitive = caseSensitive
+    d
+  }
+
+  "SubstringSearchOpDesc.operatorInfo" should
+    "advertise the name, description, Search group, and reconfiguration 
support" in {
+    val info = (new SubstringSearchOpDesc).operatorInfo
+    info.userFriendlyName shouldBe "Substring Search"
+    info.operatorDescription shouldBe "Search for Substring(s) in a string 
column"
+    info.operatorGroupName shouldBe OperatorGroupConstants.SEARCH_GROUP
+    info.inputPorts should have length 1
+    info.outputPorts should have length 1
+    info.supportReconfiguration shouldBe true
+  }
+
+  "SubstringSearchOpDesc.isCaseSensitive" should "default to false" in {
+    (new SubstringSearchOpDesc).isCaseSensitive shouldBe false
+  }
+
+  "SubstringSearchOpDesc.getPhysicalOp" should "wire the SubstringSearchOpExec 
class name" in {
+    val physical =
+      newDesc("col", "ub", caseSensitive = false).getPhysicalOp(workflowId, 
executionId)
+    physical.opExecInitInfo match {
+      case OpExecWithClassName(className, descString) =>
+        className shouldBe 
"org.apache.texera.amber.operator.substringSearch.SubstringSearchOpExec"
+        descString should not be empty
+      case other => fail(s"expected OpExecWithClassName, got $other")
+    }
+    physical.inputPorts.size shouldBe 1
+    physical.outputPorts.size shouldBe 1
+  }

Review Comment:
   Good point — strengthened in eaac97b9d4. `SubstringSearchOpDescSpec` now 
asserts `physical.inputPorts.keySet` / `outputPorts.keySet` against 
`operatorInfo`'s port ids (mirroring DifferenceOpDescSpec), so a port-identity 
drift is caught even when the count is unchanged. Applied the same to the 
Keyword/Regex specs (which were also count-only) for consistency.



##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/dictionary/DictionaryMatcherOpDescSpec.scala:
##########
@@ -0,0 +1,103 @@
+/*
+ * 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.dictionary
+
+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.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 DictionaryMatcherOpDescSpec extends AnyFlatSpec with Matchers {
+
+  private val workflowId = WorkflowIdentity(1L)
+  private val executionId = ExecutionIdentity(1L)
+
+  private def newDesc(
+      dict: String,
+      attr: String,
+      result: String,
+      mt: MatchingType
+  ): DictionaryMatcherOpDesc = {
+    val d = new DictionaryMatcherOpDesc
+    d.dictionary = dict
+    d.attribute = attr
+    d.resultAttribute = result
+    d.matchingType = mt
+    d
+  }
+
+  "DictionaryMatcherOpDesc.operatorInfo" should
+    "advertise the name, Search group, and reconfiguration support" in {
+    val info = (new DictionaryMatcherOpDesc).operatorInfo
+    info.userFriendlyName shouldBe "Dictionary matcher"
+    info.operatorGroupName shouldBe OperatorGroupConstants.SEARCH_GROUP
+    info.operatorDescription.toLowerCase should include("dictionary")
+    info.inputPorts should have length 1
+    info.outputPorts should have length 1
+    info.supportReconfiguration shouldBe true
+  }
+
+  "DictionaryMatcherOpDesc.getPhysicalOp" should "wire the 
DictionaryMatcherOpExec class name" in {
+    val physical =
+      newDesc("a,b,c", "word", "matched", MatchingType.SCANBASED)
+        .getPhysicalOp(workflowId, executionId)
+    physical.opExecInitInfo match {
+      case OpExecWithClassName(className, descString) =>
+        className shouldBe 
"org.apache.texera.amber.operator.dictionary.DictionaryMatcherOpExec"
+        descString should not be empty
+      case other => fail(s"expected OpExecWithClassName, got $other")
+    }
+  }

Review Comment:
   Done in eaac97b9d4 — added the missing port assertion to 
`DictionaryMatcherOpDescSpec`'s getPhysicalOp test: it now pins 
`physical.inputPorts.keySet` / `outputPorts.keySet` against `operatorInfo`'s 
port ids alongside the OpExecWithClassName check.



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