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