Forum Discussion

kbourdel's avatar
kbourdel
Occasional Contributor
9 years ago

What is best practice when trying to compare a large json response to what is in the db

Looking for some advice to see if there is a more efficent way to do this - comparing json object in the response to the db.

 

I have a restful api which returns a large response (6000 objects).

I need to compare the response, to what is in the database.

So I created the following flow in the test case:

1. JDBC datasource - reading from the database, getting the 6000 names

2. Restful api (GET) - contained assertion is looking at the datasource to make sure it exists

3. Datasource loop

 

So when this runs, its looping through 6000 times, running the api & making sure in each iteriation the datasource property name exists. Not very efficent.

 

Is there a way to take the response from the api, and compare it in one shot to what is in the database?

5 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    It is mentioned "jdbc getting 6000 names, and rest response gets 6000 objects" - so you want to compare on these ? then why there exists #3?
    • kbourdel's avatar
      kbourdel
      Occasional Contributor

      Correct, I want to compare the JDBC result (6000 rows) with the Rest method.

      For clarification, JDBC steps is getting a list of values from a type table, and the Rest method should be returning the same set of values. 

      What would be the most efficent way of doing this?

      • nmrao's avatar
        nmrao
        Champion Level 3
        Basically you need to bring the data in manner so that it can be easy to compare both.
        1. either by transforming data to common xml for jdbc and rest response
        2. use of class / model and create object list