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


##########
common/workflow-core/src/test/scala/org/apache/texera/amber/core/storage/result/WorkflowResultStoreSpec.scala:
##########
@@ -0,0 +1,101 @@
+/*
+ * 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.core.storage.result
+
+import org.apache.texera.amber.core.virtualidentity.OperatorIdentity
+import org.scalatest.flatspec.AnyFlatSpec
+
+class WorkflowResultStoreSpec extends AnyFlatSpec {
+
+  // 
---------------------------------------------------------------------------
+  // Fixtures
+  // 
---------------------------------------------------------------------------
+
+  private val opA = OperatorIdentity("op-a")
+  private val opB = OperatorIdentity("op-b")
+
+  // 
---------------------------------------------------------------------------
+  // Default state
+  // 
---------------------------------------------------------------------------
+
+  "WorkflowResultStore()" should "default resultInfo to Map.empty" in {
+    assert(WorkflowResultStore().resultInfo.isEmpty)
+  }
+
+  // 
---------------------------------------------------------------------------
+  // Custom map preserves entries
+  // 
---------------------------------------------------------------------------
+
+  "WorkflowResultStore(...)" should
+    "preserve a Map carrying multiple operator metadatas" in {

Review Comment:
   Fixed in 04b6c077ae — case-name now says "metadata entries for multiple 
operators" (treats "metadata" as uncountable, per the convention you flagged).



##########
common/workflow-core/src/test/scala/org/apache/texera/amber/core/storage/model/OnDatasetSpec.scala:
##########
@@ -0,0 +1,104 @@
+/*
+ * 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.core.storage.model
+
+import org.scalatest.flatspec.AnyFlatSpec
+
+class OnDatasetSpec extends AnyFlatSpec {
+
+  // 
---------------------------------------------------------------------------
+  // Test-only concrete subclass — exposes the three accessors the trait
+  // declares. `OnDataset` is purely a contract; the behavior to pin is
+  // that a value of type `OnDataset` can be constructed, that its accessors
+  // return the values passed in, and that pattern-matching against the
+  // trait works for cross-module dispatch.
+  // 
---------------------------------------------------------------------------
+
+  private class StubOnDataset(repo: String, hash: String, relPath: String) 
extends OnDataset {
+    override def getRepositoryName(): String = repo
+    override def getVersionHash(): String = hash
+    override def getFileRelativePath(): String = relPath
+  }
+
+  // 
---------------------------------------------------------------------------
+  // Accessor surface — return verbatim
+  // 
---------------------------------------------------------------------------
+
+  "OnDataset.getRepositoryName" should "return the value supplied by the 
concrete impl" in {
+    val ds: OnDataset = new StubOnDataset("my-repo", "abc123", "data/file.csv")
+    assert(ds.getRepositoryName() == "my-repo")
+  }
+
+  "OnDataset.getVersionHash" should "return the value supplied by the concrete 
impl" in {
+    val ds: OnDataset = new StubOnDataset("my-repo", "abc123", "data/file.csv")
+    assert(ds.getVersionHash() == "abc123")
+  }
+
+  "OnDataset.getFileRelativePath" should "return the value supplied by the 
concrete impl" in {
+    val ds: OnDataset = new StubOnDataset("my-repo", "abc123", "data/file.csv")
+    assert(ds.getFileRelativePath() == "data/file.csv")
+  }
+
+  // 
---------------------------------------------------------------------------
+  // Empty / unusual values are passed through unchanged
+  // 
---------------------------------------------------------------------------
+
+  "OnDataset accessors" should
+    "pass empty strings through unchanged (the trait imposes no validation)" 
in {
+    val ds: OnDataset = new StubOnDataset("", "", "")
+    assert(ds.getRepositoryName() == "")
+    assert(ds.getVersionHash() == "")
+    assert(ds.getFileRelativePath() == "")
+  }
+
+  it should "return distinct values across two distinct implementations" in {
+    val a: OnDataset = new StubOnDataset("repo-a", "h-a", "p-a")
+    val b: OnDataset = new StubOnDataset("repo-b", "h-b", "p-b")
+    assert(a.getRepositoryName() != b.getRepositoryName())
+    assert(a.getVersionHash() != b.getVersionHash())
+    assert(a.getFileRelativePath() != b.getFileRelativePath())
+  }

Review Comment:
   Fixed in 04b6c077ae — added a second concrete impl `HardcodedOnDataset` 
(returns fixed strings) and rewrote the case to use one `StubOnDataset` + one 
`HardcodedOnDataset`. The test now exercises two genuinely distinct classes 
rather than two instances of the same one, matching the case-name.



##########
common/workflow-core/src/test/scala/org/apache/texera/amber/core/storage/model/OnDatasetSpec.scala:
##########
@@ -0,0 +1,104 @@
+/*
+ * 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.core.storage.model
+
+import org.scalatest.flatspec.AnyFlatSpec
+
+class OnDatasetSpec extends AnyFlatSpec {
+
+  // 
---------------------------------------------------------------------------
+  // Test-only concrete subclass — exposes the three accessors the trait
+  // declares. `OnDataset` is purely a contract; the behavior to pin is
+  // that a value of type `OnDataset` can be constructed, that its accessors
+  // return the values passed in, and that pattern-matching against the
+  // trait works for cross-module dispatch.
+  // 
---------------------------------------------------------------------------
+
+  private class StubOnDataset(repo: String, hash: String, relPath: String) 
extends OnDataset {
+    override def getRepositoryName(): String = repo
+    override def getVersionHash(): String = hash
+    override def getFileRelativePath(): String = relPath
+  }
+
+  // 
---------------------------------------------------------------------------
+  // Accessor surface — return verbatim
+  // 
---------------------------------------------------------------------------
+
+  "OnDataset.getRepositoryName" should "return the value supplied by the 
concrete impl" in {
+    val ds: OnDataset = new StubOnDataset("my-repo", "abc123", "data/file.csv")
+    assert(ds.getRepositoryName() == "my-repo")
+  }
+
+  "OnDataset.getVersionHash" should "return the value supplied by the concrete 
impl" in {
+    val ds: OnDataset = new StubOnDataset("my-repo", "abc123", "data/file.csv")
+    assert(ds.getVersionHash() == "abc123")
+  }
+
+  "OnDataset.getFileRelativePath" should "return the value supplied by the 
concrete impl" in {
+    val ds: OnDataset = new StubOnDataset("my-repo", "abc123", "data/file.csv")
+    assert(ds.getFileRelativePath() == "data/file.csv")
+  }
+
+  // 
---------------------------------------------------------------------------
+  // Empty / unusual values are passed through unchanged
+  // 
---------------------------------------------------------------------------
+
+  "OnDataset accessors" should
+    "pass empty strings through unchanged (the trait imposes no validation)" 
in {
+    val ds: OnDataset = new StubOnDataset("", "", "")
+    assert(ds.getRepositoryName() == "")
+    assert(ds.getVersionHash() == "")
+    assert(ds.getFileRelativePath() == "")
+  }
+
+  it should "return distinct values across two distinct implementations" in {
+    val a: OnDataset = new StubOnDataset("repo-a", "h-a", "p-a")
+    val b: OnDataset = new StubOnDataset("repo-b", "h-b", "p-b")
+    assert(a.getRepositoryName() != b.getRepositoryName())
+    assert(a.getVersionHash() != b.getVersionHash())
+    assert(a.getFileRelativePath() != b.getFileRelativePath())
+  }
+
+  // 
---------------------------------------------------------------------------
+  // Pattern-matching contract — consumers branch on `case _: OnDataset`
+  // 
---------------------------------------------------------------------------
+
+  "An OnDataset value" should "match the OnDataset trait via type-pattern" in {
+    val ds: OnDataset = new StubOnDataset("r", "h", "p")
+    val matched: Boolean = ds match {
+      case _: OnDataset => true
+      case _            => false
+    }
+    assert(matched)
+  }
+
+  it should
+    "not match a different unrelated type via type-pattern (sanity check)" in {
+    // Asymmetry sanity: a String is NOT an OnDataset. This catches a
+    // bizarre regression where someone made `OnDataset` extend `AnyRef`-
+    // less-specific.

Review Comment:
   Fixed in 04b6c077ae — reworded the comment to describe the actual failure 
mode it guards: a refactor that widened `OnDataset` to a type alias (e.g. `type 
OnDataset = AnyRef`). Traits already extend `AnyRef`, so "extends `AnyRef`" was 
the wrong framing.



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