Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

Unable to assert two json files in karate tests

$
0
0

I am trying to assert two json in karate. however the assertion fails. The following is the command i am using in my karate file.

And match pcapngEventsB[1] == expectedEventsB[1] 

The value of pcapngEventsB[1] is below

    {  key=172.22.0.5|39416|172.22.0.7|8080|1,  packet={    ip={      src=172.22.0.7,      dst=172.22.0.5    },    tcp={      src=8080,      dst=39416    },    http2={      headers=[        {"name": "3gpp-sbi-message-priority","value": "24"        },        {"name": ":status","value": "200"        },        {"name": "content-length","value": "367"        },        {"name": "content-type","value": "application\/json"        }      ],      body={"headers": [          {"key": "user-agent","value": "Vert.x-WebClient/4.4.4"          },          {"key": "header-1","value": "header-value-1"          },          {"key": "header-2","value": "header-value-2"          },          {"key": "x-request-id","value": "ffa04802-be33-43cb-a2e6-4700ef0b0511"          },          {"key": "content-type","value": "application/json"          },          {"key": "content-length","value": "55"          }        ],"content": {"key": "sample-key","value": "sample-value"        }      }    }  },  streamId=1}

and value of expectedEventsB[1] is below

{  key=172.22.0.5|39416|172.22.0.7|8080|1,  packet={    ip={      src=172.22.0.7,      dst=172.22.0.5    },    tcp={      src=8080,      dst=#number?_>=32768&&_<=60999    },    http2={      headers=[        {"name": "3gpp-sbi-message-priority","value": "24"        },        {"name": ":status","value": "200"        },        {"name": "content-length","value": "367"        },        {"name": "content-type","value": "application\/json"        }      ],      body={"headers": [          {"key": "user-agent","value": "#regex ^Vert.x-WebClient/[0-9]+.[0-9]+.[0-9]+(-.*)?$"          },          {"key": "header-1","value": "header-value-1"          },          {"key": "header-2","value": "header-value-2"          },          {"key": "x-request-id","value": "#uuid"          },          {"key": "content-type","value": "application/json"          },          {"key": "content-length","value": "55"          }        ],"content": {"key": "sample-key","value": "sample-value"        }      }    }  },  streamId=#number}

when i compare the json it fails with error

reason: all key-values did not match

I took a diff of the actual and expected json . the following is the diff

diff actual.json expected.json10c10<       dst=39416--->       dst=#number?_>=32768&&_<=6099935c35<             "value": "Vert.x-WebClient/4.4.4"--->             "value": "#regex ^Vert.x-WebClient/[0-9]+.[0-9]+.[0-9]+(-.*)?$"47c47<             "value": "ffa04802-be33-43cb-a2e6-4700ef0b0511"--->             "value": "#uuid"65c65<   streamId=1--->   streamId=#number

appreciate any help how to fix this issue. thank you


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>