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


##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/map/MapOpExecSpec.scala:
##########
@@ -0,0 +1,78 @@
+/*
+ * 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.map
+
+import org.apache.texera.amber.core.tuple.{Attribute, AttributeType, Schema, 
Tuple}
+import org.scalatest.flatspec.AnyFlatSpec
+
+class MapOpExecSpec extends AnyFlatSpec {
+
+  private val schema: Schema =
+    Schema().add(new Attribute("v", AttributeType.INTEGER))
+
+  private def tuple(v: Int): Tuple =
+    Tuple.builder(schema).add(new Attribute("v", AttributeType.INTEGER), 
Integer.valueOf(v)).build()
+
+  private class TestMap extends MapOpExec
+
+  "MapOpExec.processTuple" should "emit exactly one tuple per input by 
applying the configured mapFunc" in {
+    val exec = new TestMap()
+    exec.setMapFunc((t: Tuple) => tuple(t.getField[Int]("v") * 2))
+
+    val out = exec.processTuple(tuple(3), 0).toList
+    assert(out == List(tuple(6)))
+  }
+
+  it should "preserve identity when mapFunc returns the input tuple" in {
+    val exec = new TestMap()
+    exec.setMapFunc((t: Tuple) => t)
+
+    val input = tuple(7)
+    val out = exec.processTuple(input, 0).toList
+    assert(out.size == 1)
+    assert(out.head.asInstanceOf[Tuple] == input)

Review Comment:
   Done in 9985d7209d. Switched to reference equality (`eq`) and dropped the 
`asInstanceOf[Tuple]` cast.



##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/map/MapOpExecSpec.scala:
##########
@@ -0,0 +1,78 @@
+/*
+ * 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.map
+
+import org.apache.texera.amber.core.tuple.{Attribute, AttributeType, Schema, 
Tuple}
+import org.scalatest.flatspec.AnyFlatSpec
+
+class MapOpExecSpec extends AnyFlatSpec {
+
+  private val schema: Schema =
+    Schema().add(new Attribute("v", AttributeType.INTEGER))
+
+  private def tuple(v: Int): Tuple =
+    Tuple.builder(schema).add(new Attribute("v", AttributeType.INTEGER), 
Integer.valueOf(v)).build()

Review Comment:
   Done in 9985d7209d. The `tuple` helper now uses `schema.getAttribute("v")` 
so it stays consistent with the schema under test.



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