Service Virtualization

  • 1.  How to parse json in CA Lisa

    Posted Jul 30, 2018 03:29 PM

    [
    {
    "guideChannelName": "string",
    "guideCCID": 1,
    "daiEnabled": true,
    "c3Enabled": true,
    "affiliate": "string, string",
    "cDVREnabled": true,
    "callSign": "string"
    },
    {
    "guideChannelName": "string",
    "guideCCID": 2,
    "daiEnabled": true,
    "c3Enabled": true,
    "affiliate": "string, string",
    "cDVREnabled": true,
    "callSign": "string"
    },
    {
    "guideChannelName": "string",
    "guideCCID": 3,
    "daiEnabled": true,
    "c3Enabled": true,
    "affiliate": "string, string",
    "cDVREnabled": true,
    "callSign": "string"
    },
    {
    "guideChannelName": "string",
    "guideCCID": 5,
    "daiEnabled": true,
    "c3Enabled": true,
    "affiliate": "string, string",
    "cDVREnabled": true,
    "callSign": "string"
    },
    ]

     

    If I want to check in c3Enabled flag there is no False Value. How I can do?. This is small Json/ I do have json with more than 100 values and all the time list will get change. I just need to validate that c3Enabled is not False anywhere in Json



  • 2.  Re: How to parse json in CA Lisa
    Best Answer

    Broadcom Employee
    Posted Jul 31, 2018 11:25 PM

    Hi Kuldeep,

     

    I changed the JSON script as the complete JSON format like below:
    --------------------------------------------------------------------------------
    {
      "type": "definitions",
      "objectVersion": "2",
      "formatVersion": 2,
      "objects": [
    {
    "guideChannelName": "string",
    "guideCCID": 1,
    "daiEnabled": true,
    "c3Enabled": true,
    "affiliate": "string, string",
    "cDVREnabled": true,
    "callSign": "string"
    },
    {
    "guideChannelName": "string",
    "guideCCID": 2,
    "daiEnabled": true,
    "c3Enabled": true,
    "affiliate": "string, string",
    "cDVREnabled": true,
    "callSign": "string"
    },
    {
    "guideChannelName": "string",
    "guideCCID": 3,
    "daiEnabled": true,
    "c3Enabled": true,
    "affiliate": "string, string",
    "cDVREnabled": true,
    "callSign": "string"
    },
    {
    "guideChannelName": "string",
    "guideCCID": 5,
    "daiEnabled": true,
    "c3Enabled": false,
    "affiliate": "string, string",
    "cDVREnabled": true,
    "callSign": "string"
    }
      ]
    }
    --------------------------------------------------------------------------------
    And I changed last c3Enabled value to false.
    I added this whole JSON script to "Parse Text as Response step" and in this step I added one "JSON Path filter" and defined  like:
    JSON Path: $.objects[*].c3Enabled
    Save Value to Property: {{c3Enabledvalues}}
    Save length to Proerty: {{numberofc3Enabled}}
    And if I pushed "Run Filter Button", then I got the value of  {{c3Enabledvalues}} as [true,true,true,false].

    And in the same step, I added one "Ensure Property Matches Expression assertion" and defined as the screenshot below:(This assertion means if the property {{c3Enabledvalues}} includes "false" then "Generate Error".)

    And when I execute this test case in ITR, the results like below:


    I think this results may help you.
    If you need this test case, please let me know.

     

    Thank you,



  • 3.  Re: How to parse json in CA Lisa

    Posted Aug 07, 2018 11:22 PM

    Hello,

     

    I am trying to set connection for MySQL in script: So far it is throwing me error

     

    Below is the code. Can you please help me where, I am doing mistake . For url and Pwd, I am giving credentials, but didn’t mention here

     

    import java.sql.*;

    import java.sql.Connection;

    import java.sql.DriverManager;

    import java.sql.ResultSet;

    import java.sql.SQLException;

    import java.sql.Statement;

    import javax.sql.DataSource;

     

    String dbUrl ="avcmg-di.cua8asf8jbhp.us-west-2.rds.amazonaws.com :3306";

    String username = "avcmg_user";

    String password = "directv1" ;

     

     

    Class.forName("com.mysql.jdbc.Driver");

    Connection con = DriverManager.getConnection("dbUrl","username", "password");

    Statement stmt=con.createStatement();

    String query ="select guide_ccid from av_channels";

    ResultSet rs= stmt.executeQuery(query);



  • 4.  Re: How to parse json in CA Lisa

    Broadcom Employee
    Posted Aug 08, 2018 03:50 AM

    Hi Kuldeep,

     

    Why don't you use the "SQL Database Execution(JDBC) step"?
    I assume that the "SQL Database Execution(JDBC) step" has some kinds of limitation and you need to write script, but your question is already changed from your original question.
    So in this case, could you please create a new question?

     

    Thank you,



  • 5.  Re: How to parse json in CA Lisa

    Broadcom Employee
    Posted Aug 08, 2018 03:54 AM

    Hi Kuldeep,

     

    I found that you already created a new question about MySQL.

    Please ignore my previous comment.

     

    Thank you,