{\"msgType\":\"Message\",\"message\":{\"variable1\":\"<value>\",\"variable2\":[{\"variable2a\":\"<value>\",\"variable2b\":\"<value>\",\"variable2c\":\"<value>\",\"variable2d\":\"<value>\"}]}}
def msg = context.receivedMessage
def isMatch = expectedMsgs.stream().any { em -> org.skyscreamer.jsonassert.JSONCompare.compareJSON(em, msg, org.skyscreamer.jsonassert.JSONCompareMode.LENIENT).passed()}
log.info (\"Websocket message #${context.messagetCount} ${isMatch ? \"matched\" : \"did not match\"} the list of expected string\")
assert(isMatch)
Some of these values I do want to check an exact response is received and that's easy enough. But some of them, I just want to make sure the variable itself is present and value isn't null. Can't sort out how to handle that part.
Thanks!
Jonathan
","kudosSumWeight":0,"postTime":"2023-12-11T07:48:16.692-08:00","images":{"__typename":"AssociatedImageConnection","edges":[],"totalCount":0,"pageInfo":{"__typename":"PageInfo","hasNextPage":false,"endCursor":null,"hasPreviousPage":false,"startCursor":null}},"attachments":{"__typename":"AttachmentConnection","pageInfo":{"__typename":"PageInfo","hasNextPage":false,"endCursor":null,"hasPreviousPage":false,"startCursor":null},"edges":[]},"tags":{"__typename":"TagConnection","pageInfo":{"__typename":"PageInfo","hasNextPage":false,"endCursor":null,"hasPreviousPage":false,"startCursor":null},"edges":[{"__typename":"TagEdge","cursor":"MjUuNHwyLjF8b3wxMHxfTlZffDE","node":{"__typename":"Tag","id":"tag:Function Tests","text":"Function Tests","time":"2021-08-24T02:50:27.810-07:00","lastActivityTime":null,"messagesCount":null,"followersCount":null}},{"__typename":"TagEdge","cursor":"MjUuNHwyLjF8b3wxMHxfTlZffDI","node":{"__typename":"Tag","id":"tag:Scripting","text":"Scripting","time":"2015-05-29T05:46:36.658-07:00","lastActivityTime":null,"messagesCount":null,"followersCount":null}}]},"timeToRead":1,"currentRevision":{"__ref":"Revision:revision:261262_3"},"latestVersion":null,"metrics":{"__typename":"MessageMetrics","views":2616},"read":false,"visibilityScope":"PUBLIC","canonicalUrl":null,"seoTitle":null,"seoDescription":null,"isEscalated":null,"placeholder":false,"originalMessageForPlaceholder":null,"messagePolicies":{"__typename":"MessagePolicies","canModerateSpamMessage":{"__typename":"PolicyResult","failureReason":{"__typename":"FailureReason","message":"error.lithium.policies.feature.moderation_spam.action.moderate_entity.allowed.accessDenied","key":"error.lithium.policies.feature.moderation_spam.action.moderate_entity.allowed.accessDenied","args":[]}}},"archivalData":null,"customFields":[],"body":"I have an existing Groovy script (for an assertion) that I need to change to check whether a variable exists, but not caring about the actual value. The script is using results from the test step.
def expectedMsgs = [\"\"\"
{\"msgType\":\"Message\",\"message\":{\"variable1\":\"<value>\",\"variable2\":[{\"variable2a\":\"<value>\",\"variable2b\":\"<value>\",\"variable2c\":\"<value>\",\"variable2d\":\"<value>\"}]}}
def msg = context.receivedMessage
def isMatch = expectedMsgs.stream().any { em -> org.skyscreamer.jsonassert.JSONCompare.compareJSON(em, msg, org.skyscreamer.jsonassert.JSONCompareMode.LENIENT).passed()}
log.info (\"Websocket message #${context.messagetCount} ${isMatch ? \"matched\" : \"did not match\"} the list of expected string\")
assert(isMatch)
Some of these values I do want to check an exact response is received and that's easy enough. But some of them, I just want to make sure the variable itself is present and value isn't null. Can't sort out how to handle that part.
Thanks!
Jonathan
"},"Conversation:conversation:261262":{"__typename":"Conversation","id":"conversation:261262","solved":false,"topic":{"__ref":"ForumTopicMessage:message:261262"},"lastPostingActivityTime":"2023-12-19T05:24:25.887-08:00","lastPostTime":"2023-12-19T05:24:25.887-08:00","unreadReplyCount":5,"isSubscribed":false},"ModerationData:moderation_data:261262":{"__typename":"ModerationData","id":"moderation_data:261262","status":"APPROVED","rejectReason":null,"isReportedAbuse":false,"rejectUser":null,"rejectTime":null,"rejectActorType":null},"Revision:revision:261262_3":{"__typename":"Revision","id":"revision:261262_3","lastEditTime":"2023-12-17T21:09:51.711-08:00"},"ForumReplyMessage:message:261406":{"__typename":"ForumReplyMessage","id":"message:261406","conversation":{"__ref":"Conversation:conversation:261262"},"author":{"__ref":"User:user:122761"},"entityType":"FORUM_REPLY","eventPath":"category:ready_api_forums/community:nwkab66374board:readyapi-questions/message:261262/message:261406","revisionNum":1,"uid":261406,"depth":1,"hasGivenKudo":false,"subscribed":false,"board":{"__ref":"Forum:board:readyapi-questions"},"subject":"Re: How to check for the existence of a value in Groovy script","readOnly":false,"editFrozen":false,"showMoveIndicator":false,"moderationData":{"__ref":"ModerationData:moderation_data:261406"},"parent":{"__ref":"ForumTopicMessage:message:261262"},"body":"Thanks nmrao and soniya-01 for the help! We'll look into re-writing the Groovy script based on the examples above.
","body@stringLength":"502","rawBody":"Thanks