Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Using Custom Responder Correlation - Groovy

sindhu_ussanar
sindhu_ussanar Posts: 2
edited March 2017 in Virtualize

I am trying to read values from the request using Custom - Responder correlation and compare it with values from excel. How do I get a unique row from excel data source in the script?

Comments

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭

    I think you probably want this one:

    List<String> com.parasoft.api.ScriptingContext.getValues(String dataSourceName, String columnName)
    

    You provide the name of your data source, the name of the column, and then it returns all the values in that data source and column. With that list, you can call get(int index) to get the value at the desired row index (0-based).

  • sindhu_ussanar
    sindhu_ussanar Posts: 2

    It gives null pointer when I try to access the data source. I have tried the above code and got a null. Somehow the same code works in the Extension tool without any issues.

  • williammccusker
    williammccusker Posts: 642 ✭✭✭

    In a responder it doesn't work because at the time that "responder correlations" are run the data source has not yet been set. This is what "datasource correlations" are for. Could you use one of the existing "datasource correlations" options? To compare if a value from the request matches a column in an excel data source you can use "Request Body"

  • [Deleted User]
    [Deleted User] Posts: 0 admin

    Hi Sindhu,

    We go over how to use Data Source correlation in this post. There is also a video that goes into the details. Take a look at that and see if that helps you out.