我有一个响应存储在我的一个空手道var holdingid中:
And def holdingID = $GetDataSet_greaterThan_Filter_Response.rowData[*].7
holdingID = [ 21015000, 146066000, 10497015000, 58765000, 27790000, 4.308709302E7, 2.0360701868295E7, 21710000, 331720000, 62327000, 57210000, 19430000, 19129000, 2.0168081879E8, 35242933, 7.0444591772E8, 2.551241528E7, 1.948655045E7, 2.520400137E7, 3.8540777658E8, 103001450, 1.957371122E7, 1.6805940819E8, 20907400, 19500118, 1.8480989443E8, 181875000, 5.609840033E7, 6.931536767E7, 5.32741731109984E8, 188974032, 591381346, 8.419481045E7, 19868866, 5.5488624902E7, 30759197, 8.926510191E7, 5.382712107E7, 3.095059546E7, 7.174669486E7, 23828000, 42558698, 1.777676693E7, 21695100, 7.198816072E8, 322132495, 19120000 ]
现在,我需要使用一些值(例如:17559097)来检查以下操作:
我尝试过的事情:
第一种方法:
我做了以下事情来找到解决方案: *断言holdingID> 17559097
此消息失败:断言失败:断言评估为假:holdingID> 17559097
第二种方法: 创建了一个列表并尝试执行排序。这样我就可以检查第一个值并对其应用断言。
And def listAsDescending = new ArrayList()
* eval for(var i = 0; i < holdingID.length; i++) listAsDescending.add(holdingID[i])
And print listAsDescending
* eval Collections.sort(listAsDescending)
但是我遇到以下错误:Collections.sort(listAsDescending),java.lang.Integer无法转换为java.lang.Long
如何对存储的变量执行这些操作?
答案 0 :(得分:1)
仔细阅读文档,方法有很多。我把它留给你去寻找其他方法:
* def holdingId = [ 21015000, 146066000, 10497015000, 58765000, 27790000, 4.308709302E7, 2.0360701868295E7, 21710000, 331720000, 62327000, 57210000, 19430000, 19129000, 2.0168081879E8, 35242933, 7.0444591772E8, 2.551241528E7, 1.948655045E7, 2.520400137E7, 3.8540777658E8, 103001450, 1.957371122E7, 1.6805940819E8, 20907400, 19500118, 1.8480989443E8, 181875000, 5.609840033E7, 6.931536767E7, 5.32741731109984E8, 188974032, 591381346, 8.419481045E7, 19868866, 5.5488624902E7, 30759197, 8.926510191E7, 5.382712107E7, 3.095059546E7, 7.174669486E7, 23828000, 42558698, 1.777676693E7, 21695100, 7.198816072E8, 322132495, 19120000 ]
* match each holdingId == '#? _ > 17559097'
* def fun = function(x){ return x > 17559097 }
* def actual = karate.filter(holdingId, fun)
* match holdingId == actual