SOAP UI 스크립트에서 이상한 것을 보았습니다. 난 그냥 올바른으로 데이터가 그래서 다음은이 코드를 작성했다고 주장을 수행 할 :groovy를 통해 json 출력을 주문하는 방법은 무엇입니까?
import com.eviware.soapui.support.GroovyUtils
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
def response = messageExchange.response.responseContent
def json = new JsonSlurper().parseText(response)
def jsonFormat = (response).toString()
def policies = [
[x: 28, xxx: 41, xxxxx: 1, name: 'Individual 18-50', aaa: true],
[x: 31, xxx: 41, xxxxx: 1, name: 'Individual 51-60', aaa: true],
[x: 34, xxx: 41, xxxxx: 1, name: 'Individual 61-75', aaa: true],
[x: 37, xxx: 41, xxxxx: 1, name: 'Individual 76-85', aaa: false]
]
log.warn json.policies
log.error policies
assert json.policies == policies
나는 log.warn 및 log.error 정보를 보면, 그것은 잘못된에서 JSON 응답을 표시합니다 'isActive'필드가 먼저 표시되므로 주문하십시오.
log.warn json.policies
표시이 :
[{aaa=true, xx=28, xxxxx=1, name=Individual 18-50, xxxx=41}, {aaa=true, x=31, xxxxx=1, name=Individual 51-60, xxx=41}, {aaa=true, x=34, xxxxx=1, name=Individual 61-75, xxx=41}, {aaa=true, x=37, xxxxx=1, name=Individual 76-85, xxx=41}]
log.error policies
표시이 : 나는 DTO들은 그래서 그 json.policies
와 올바른 순서 내에 표시 할 수있는 방법
[{x=28, xxx=41, xxxxx=1, name=Individual 18-50, aaa=true}, {x=31, xxx=41, xxxxx=1, name=Individual 51-60, aaa=true}, {x=34, xxxx=41, xxxxxx=1, name=Individual 61-75, aaa=true}, {x=37, xxx=41, xxxxx=1, name=Individual 76-85, aaa=false}]
정책으로 올바른 순서로 표시됩니까?
이상한 일이 또 하나 있는데, 테스트 케이스를 10 번 실행하고이 어설 션 검사가 10 회 중에 3 번 통과 한 테스트 단계입니다. 최종 DTO를 policies
의 끝으로 비교하는 경우와 같이를 false으로 표시하고 json.policies
의 마지막 isActive는 true입니다.
Json지도에 주문 번호 –
@ ok ok가 없습니다. 그런 다음 어떻게 가끔 전달되고 어설 션에 실패합니까? 내가 코드에서 잘못한 부분이 있습니까? –
가끔은 올바른 순서로 나오기 때문에, 다른 것들은 나오지 않기 때문입니다. –