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


##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/projection/AttributeUnitSpec.scala:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.projection
+
+import org.apache.texera.amber.util.JSONUtils.objectMapper
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
+
+class AttributeUnitSpec extends AnyFlatSpec with Matchers {
+
+  "AttributeUnit.getAlias" should "return the alias when one is provided" in {
+    new AttributeUnit("col", "renamed").getAlias shouldBe "renamed"
+    new AttributeUnit("col", "renamed").getOriginalAttribute shouldBe "col"
+  }
+
+  it should "fall back to the original attribute when the alias is blank" in {
+    new AttributeUnit("col", "").getAlias shouldBe "col"
+    new AttributeUnit("col", "   ").getAlias shouldBe "col"
+    new AttributeUnit("col", null).getAlias shouldBe "col"
+  }
+
+  "AttributeUnit" should "honor equals/hashCode by original attribute and 
alias" in {
+    val a = new AttributeUnit("col", "x")
+    val b = new AttributeUnit("col", "x")
+    a shouldBe b
+    a.hashCode shouldBe b.hashCode
+    a should not be new AttributeUnit("col", "y")
+  }

Review Comment:
   The test name says equality/hashCode is checked for both originalAttribute 
and alias, but the negative assertion only varies alias. Add a case that varies 
originalAttribute to match the stated intent.



##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/projection/AttributeUnitSpec.scala:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.projection
+
+import org.apache.texera.amber.util.JSONUtils.objectMapper
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
+
+class AttributeUnitSpec extends AnyFlatSpec with Matchers {
+
+  "AttributeUnit.getAlias" should "return the alias when one is provided" in {
+    new AttributeUnit("col", "renamed").getAlias shouldBe "renamed"
+    new AttributeUnit("col", "renamed").getOriginalAttribute shouldBe "col"
+  }
+
+  it should "fall back to the original attribute when the alias is blank" in {
+    new AttributeUnit("col", "").getAlias shouldBe "col"
+    new AttributeUnit("col", "   ").getAlias shouldBe "col"
+    new AttributeUnit("col", null).getAlias shouldBe "col"
+  }
+
+  "AttributeUnit" should "honor equals/hashCode by original attribute and 
alias" in {
+    val a = new AttributeUnit("col", "x")
+    val b = new AttributeUnit("col", "x")
+    a shouldBe b
+    a.hashCode shouldBe b.hashCode
+    a should not be new AttributeUnit("col", "y")
+  }
+
+  "AttributeUnit" should "round-trip through Jackson" in {
+    val u = new AttributeUnit("col", "renamed")
+    val json = objectMapper.writeValueAsString(u)
+    json should include("\"originalAttribute\":\"col\"")
+    json should include("\"alias\":\"renamed\"")
+    objectMapper.readValue(json, classOf[AttributeUnit]) shouldBe u

Review Comment:
   Avoid asserting JSON output via substring matching; it’s brittle to 
formatting/key-order changes. Other workflow-operator tests parse into a 
JsonNode and assert on keys/values directly (e.g., 
DumbbellDotConfigSpec.scala:60-69).



##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/udf/python/LambdaAttributeUnitSpec.scala:
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.udf.python
+
+import org.apache.texera.amber.core.tuple.AttributeType
+import org.apache.texera.amber.util.JSONUtils.objectMapper
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
+
+class LambdaAttributeUnitSpec extends AnyFlatSpec with Matchers {
+
+  "LambdaAttributeUnit" should "expose its constructor-supplied fields" in {
+    val u = new LambdaAttributeUnit("score", "1 + 1", "scoreOut", 
AttributeType.INTEGER)
+    u.attributeName shouldBe "score"
+    u.expression shouldBe "1 + 1"
+    u.newAttributeName shouldBe "scoreOut"
+    u.attributeType shouldBe AttributeType.INTEGER
+  }
+
+  "LambdaAttributeUnit" should "honor equals/hashCode by all four fields" in {
+    val a = new LambdaAttributeUnit("score", "1 + 1", "scoreOut", 
AttributeType.INTEGER)
+    val b = new LambdaAttributeUnit("score", "1 + 1", "scoreOut", 
AttributeType.INTEGER)
+    a shouldBe b
+    a.hashCode shouldBe b.hashCode
+    a should not be new LambdaAttributeUnit("score", "1 + 2", "scoreOut", 
AttributeType.INTEGER)

Review Comment:
   The test name claims equals/hashCode is validated across all four fields, 
but the negative case only varies expression. Add a couple more not-equal 
assertions varying newAttributeName and attributeType so the test actually pins 
the full equality contract.



##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/udf/python/LambdaAttributeUnitSpec.scala:
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.udf.python
+
+import org.apache.texera.amber.core.tuple.AttributeType
+import org.apache.texera.amber.util.JSONUtils.objectMapper
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
+
+class LambdaAttributeUnitSpec extends AnyFlatSpec with Matchers {
+
+  "LambdaAttributeUnit" should "expose its constructor-supplied fields" in {
+    val u = new LambdaAttributeUnit("score", "1 + 1", "scoreOut", 
AttributeType.INTEGER)
+    u.attributeName shouldBe "score"
+    u.expression shouldBe "1 + 1"
+    u.newAttributeName shouldBe "scoreOut"
+    u.attributeType shouldBe AttributeType.INTEGER
+  }
+
+  "LambdaAttributeUnit" should "honor equals/hashCode by all four fields" in {
+    val a = new LambdaAttributeUnit("score", "1 + 1", "scoreOut", 
AttributeType.INTEGER)
+    val b = new LambdaAttributeUnit("score", "1 + 1", "scoreOut", 
AttributeType.INTEGER)
+    a shouldBe b
+    a.hashCode shouldBe b.hashCode
+    a should not be new LambdaAttributeUnit("score", "1 + 2", "scoreOut", 
AttributeType.INTEGER)
+  }
+
+  "LambdaAttributeUnit" should "round-trip through Jackson" in {
+    val u = new LambdaAttributeUnit("score", "1 + 1", "scoreOut", 
AttributeType.INTEGER)
+    val json = objectMapper.writeValueAsString(u)
+    json should include("\"attributeName\":\"score\"")
+    json should include("\"expression\":\"1 + 1\"")
+    objectMapper.readValue(json, classOf[LambdaAttributeUnit]) shouldBe u

Review Comment:
   Avoid asserting JSON output via substring matching; it’s brittle to 
formatting/key-order changes. Prefer objectMapper.readTree(json) + key/value 
assertions as used elsewhere in workflow-operator tests (e.g., 
DumbbellDotConfigSpec.scala:60-69).



##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/typecasting/TypeCastingUnitSpec.scala:
##########
@@ -0,0 +1,47 @@
+/*
+ * 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.typecasting
+
+import org.apache.texera.amber.core.tuple.AttributeType
+import org.apache.texera.amber.util.JSONUtils.objectMapper
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
+
+class TypeCastingUnitSpec extends AnyFlatSpec with Matchers {
+
+  "TypeCastingUnit" should "expose its attribute and result-type fields" in {
+    val u = new TypeCastingUnit
+    u.attribute = "amount"
+    u.resultType = AttributeType.DOUBLE
+    u.attribute shouldBe "amount"
+    u.resultType shouldBe AttributeType.DOUBLE
+  }
+
+  "TypeCastingUnit" should "round-trip its fields through Jackson" in {
+    val u = new TypeCastingUnit
+    u.attribute = "amount"
+    u.resultType = AttributeType.INTEGER
+    val json = objectMapper.writeValueAsString(u)
+    json should include("\"attribute\":\"amount\"")
+    val restored = objectMapper.readValue(json, classOf[TypeCastingUnit])
+    restored.attribute shouldBe "amount"
+    restored.resultType shouldBe AttributeType.INTEGER

Review Comment:
   Avoid asserting JSON output via substring matching; it’s brittle to 
formatting/key-order changes. Prefer asserting on a parsed JsonNode so the test 
stays stable if serialization formatting changes.



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