0
case類需要3個參數id,由內部名稱應用。試圖使結果lenght返回3.內部名稱是一個新增加的字段/參數所以這就是爲什麼它返回0,而不是3試圖在&scala中使用&操作
我想用
result.topics.find(_.topicId == "urn:emmet:1234567").get.appliedBy should be ("human") &
result.topics.find(_.topicId == "urn:emmet:2345678").get.internalName should be ("")
它給我的語法錯誤,請提前
it should "dedup topics by id, keeping those applied by human if possible" in {
val doc = Document.empty.copy(
topics = Array(
Topic("urn:emmet:1234567", appliedBy = "machine" , internalName = ""),
Topic("urn:emmet:2345678", appliedBy = "human", internalName = ""),
Topic("urn:emmet:1234567", appliedBy = "human", internalName = ""),
Topic("urn:emmet:2345678", appliedBy = "machine", internalName = ""),
Topic("urn:emmet:3456789", appliedBy = "machine", internalName = ""),
Topic("urn:emmet:3456789", appliedBy = "machine", internalName = "")
)
)
val result = DocumentTransform.dedupSubRecords(doc)
result.topics.length should be (3)
result.topics.find(_.topicId == "urn:emmet:1234567").get.appliedBy should be ("human")
result.topics.find(_.topicId == "urn:emmet:2345678").get.appliedBy should be ("human")
result.topics.find(_.topicId == "urn:emmet:3456789").get.appliedBy should be ("machine")
}
你想用'&'來實現什麼?你能提供一個最小的工作例子嗎?它看起來像你正在使用scalatest,你能標記它,所以那些可以幫助你更有可能看到它嗎? –
這是正確的,它是單元測試。 &正是爲了另一個附加條件與'應該是「人類」'....試圖包括另一個應該是這次與internalName字段 – dedpo