Service Virtualization

  • 1.  I have a file with JSON Request, each Key is mapped with DB Cols. How to compare a file with DB Rows ?

    Posted Aug 24, 2017 05:09 AM

    Hi Team,

     

    Good Evening...

     

    I have a Source system as a "dat file" in json format. Below is one of the request. When i run the interface, the Values in the JSON attribute is reaching the Target system : DB Cols. 

     

    How can i read this File and store the values in Property ? So, that i can compare with DB Cols.

     

    JSON Row in a File:

    {"uuid":"asdfsdf","assetType":["assetType:image/product-image"],"assetName":"asdfasdf324","class":["asdf23"],"sku":["2340000"],"subclass":["0000"],"renditions":{"original":"/C:/Local/image/product-image/41/4154/415483/415483an.psd",,"319x319":"/C:/Local/approved/image/product-image/41/4154/415483/415483an.psd.renditionpicker.319x319.png"}}

     

    Mapping :

     

    json field from a file

    table field from DB

    asset/assetName

    ASSET_NAME

    asset/assetType

    ASSET_TYPE

    asset/uuid

    ASSET_UUID

    asset/logoName

    LOGO_NAME

    asset/brand

    BRAND

    asset/sku

    SKU

    asset/expirationDate

    EXPIRATION_DT

    asset/class

    CLASS_NAME

    asset/subclass

    SUBCLASS_NAME

    asset/renditions/original

    ORIG_FILE_PATH

    asset/renditions/319x319

    THUMBNAIL_FILE_PATH

     

    Can anyone help on this. Thanks much.



  • 2.  Re: I have a file with JSON Request, each Key is mapped with DB Cols. How to compare a file with DB Rows ?

    Posted Aug 28, 2017 11:01 AM

    Hi Manoj,

                    This might help you Format of JSON and XML Path in filters  

                                                     Thanks,

    Regards,

    Vish



  • 3.  Re: I have a file with JSON Request, each Key is mapped with DB Cols. How to compare a file with DB Rows ?
    Best Answer

    Broadcom Employee
    Posted Aug 28, 2017 09:56 PM

    Hi Preethi,

        You can try by reading a data file and print the content to "Output log message step" and then apply JSON path filter to read data from JSON path and store it in a property. Then compare this property with data in DB columns.

     

    Thanks & Regards

    Srikanth Gajawada



  • 4.  Re: I have a file with JSON Request, each Key is mapped with DB Cols. How to compare a file with DB Rows ?

    Posted Aug 28, 2017 10:29 PM

    Thanks Srikanth.

     

    I have done the same for reading the JSON Content. Then applied JSON Filter to store the values in a property to compare with my DB Columns.

     

    One more query, if possible please give suggestions on it.

     

    I am having the Excel File with each row is JSON Content. In DB Step I am executing my Query and it prints some 10 rows. Now, I want to compare the 1st JSON with my 1st DB Row. I applied filter for storing the property from JSON Content and also for DB Content. With help of Assertion "Ensure properties are equal" I am validating it.

     

    I done parameterization for JSON (it iterates correctly). But in DB Section, it prints all the 10 row and does comparison with all the 10 row, for each iteration of JSON content.

     

    Ex :

    for 1st iteration

    JSON : SSN Number (1st row JSON Content)

    DB : SSN Number(1st row)  - Stores in property - Assertion evaluated

    DB : SSN Number(2nd row) - Stores in property - Assertion fails

    ...... till my 10th row

     

    for 2nd iteration

    JSON : SSN Number(2nd row JSON Content)

    DB : SSN Number(1st row)  - Stores in property - Assertion fails

    DB : SSN Number(2nd row) - Stores in property - Assertion evaluated

    DB : SSN Number(3rd row) - Stores in property - Assertion fails

    ...... till my 10th row

     

    for 10th iteration

    JSON : SSN Number(10th row JSON Content)

    DB : SSN Number(1st row)  - Stores in property - Assertion fails

    DB : SSN Number(2nd row) - Stores in property - Assertion fails

    ...... till my 10th row

    DB : SSN Number(10th row) - Stores in property - Assertion evaluated

     

    Do we have any one-on-one comparison. 1st iteration goes as 1st JSON SSN with 1st DB SSN.  2nd iteration goes 2nd JSON SSN with 2nd DB SSN..

     

     

    Thanks much...

    Preethi R