Service Virtualization

  • 1.  SDK custom filter: reading attribute value in code

    Posted Sep 18, 2017 05:22 AM

    Hi All,

     

    I am trying to build a custom filter and I need to select an attribute and read the value it contains.

    Everything works fine except fot the last step.

    I can get to select the attribute but can't find the proper command to get the value it contains.

     

    To make it a little bit more clear what I am trying to do I isolated the problem in a test class which I attach.

    When I select the attribute in the filter it gets the name of the filter but I need to get the value. e.g.

    flStartDatetime                       <-- this is read and returned

    2017-09-17 10:30:22.123      <-- I need the value the attribute contains

     

    This is the command in the custom filter I use: Object objToString = paramTestExec.getStateValue(this.prop);

    But this and everything else I tried does not work and I can not find any documentation on it.

    I hope you can help me with the right command or an example that I can copy.

     

    Thanks in advance. Regards Oscar Betgen

    Attachment(s)

    zip
    Test.java.zip   1 KB 1 version


  • 2.  Re: SDK custom filter: reading attribute value in code

    Posted Sep 18, 2017 06:29 AM

    Oscar, Thank you for posting the question in communities. I will get back to you as soon as I can after inquiring within the team/Dev. 

     

    Regards

    Neelima K



  • 3.  Re: SDK custom filter: reading attribute value in code

    Posted Sep 18, 2017 09:54 AM

    Hi Oscar, 

    I am trying to understand the purpose of the filter, please explain. 

    Also, I looked into the code, I don't see any line of code that is taking extracting value from response and setting it to the given property name. 



  • 4.  Re: SDK custom filter: reading attribute value in code

    Posted Sep 18, 2017 11:26 AM

    Hi Monika,

     

    This is just a test setup to read the value of a attribute as I am struggling to get the value out of another attribute and only get the name of the attribute.

    I do not know how to get the value as .getStatevalue does not seem to work in my code…

     

    I will attach my original code where I try to do something usefull.

     

    I take a starttimestamp and endtimestamp (both with shortdateformat string)

    Subtract these

    And get the result in milliseconds                            (result also with shortdateformat string)

     

    It only works with the values typed in directly  but not with reading the values from another attribute.

     

     

     

     

    With kind regards/

    Met vriendelijke groet,

    Oscar Betgen

    Solution Consultant

     

     

     

     

     

    T     +31 (0)88 303 11 11

    M   +31 (0)6 42787918

    I      www.systemation.nl<http://www.systemation.nl/>

     

     

    <https://www.linkedin.com/in/martinwallenburg>[cid:image003.jpg@01D03AE1.94793B50]<https://twitter.com/systemation>

     

    Atoomweg 50

     

    3542 AB  Utrecht

     

    The Netherlands

     

     

     

     

     

     

     

     

     

     

     

     

     

    Van: monika_mehta

    Verzonden: maandag 18 september 2017 15:54

    Aan: Oscar Betgen <Oscar.Betgen@systemation.nl>

    Onderwerp: Re:  - Re: SDK custom filter: reading attribute value in code

     

    CA Communities <https://communities.ca.com/?et=watches.email.thread>

     

     

    Re: SDK custom filter: reading attribute value in code

     

    reply from Monika Mehta<https://communities.ca.com/people/monika_mehta?et=watches.email.thread> in DevTest Community - View the full discussion<https://communities.ca.com/message/242007857-re-sdk-custom-filter-reading-attribute-value-in-code?commentID=242007857&et=watches.email.thread#comment-242007857>

    Attachment(s)



  • 5.  Re: SDK custom filter: reading attribute value in code
    Best Answer

    Posted Sep 18, 2017 11:48 AM

    Hi Oscar, 

     

    Could you please try replacing the code for subPostFilter with below? We have tried declaring the value as String rather than as Object and later changing it to String.  

     

    public boolean subPostFilter(TestExec paramTestExec)
    throws TestRunException
    {
    try
    {
    String parm = paramTestExec.getStateValue(this.prop);
    }
    catch (Exception e)
    {
    logger.error(e.getMessage(), e);
    throw new RuntimeException(e.getMessage(), e);
    }
    paramTestExec.log(parm);
    }

     

    Thank you 

    Neelima Kadimi



  • 6.  Re: SDK custom filter: reading attribute value in code

    Posted Sep 18, 2017 01:23 PM

    Hi Neelima,

     

    Yes that works!

     

    I tried it in the test project and will use this in the datediff filter I am building.

    I hope I can get it right but now I have an example to work from so thanks!

    Have a good evening and talk to you soon.

    Thanks again!

     

     

    With kind regards/

    Met vriendelijke groet,

    Oscar Betgen

    Solution Consultant

     

     

     

     

     

    T     +31 (0)88 303 11 11

    M   +31 (0)6 42787918

    I      www.systemation.nl<http://www.systemation.nl/>

     

     

    <https://www.linkedin.com/in/martinwallenburg>[cid:image003.jpg@01D03AE1.94793B50]<https://twitter.com/systemation>

     

    Atoomweg 50

     

    3542 AB  Utrecht

     

    The Netherlands

     

     

     

     

     

     

     

     

     

     

     

     

     

    Van: kadne01

    Verzonden: maandag 18 september 2017 17:49

    Aan: Oscar Betgen <Oscar.Betgen@systemation.nl>

    Onderwerp: Re:  - Re: SDK custom filter: reading attribute value in code

     

    CA Communities <https://communities.ca.com/?et=watches.email.thread>

     

     

    Re: SDK custom filter: reading attribute value in code

     

    reply from Neelima Kadimi<https://communities.ca.com/people/kadne01?et=watches.email.thread> in DevTest Community - View the full discussion<https://communities.ca.com/message/242007981-re-sdk-custom-filter-reading-attribute-value-in-code?commentID=242007981&et=watches.email.thread#comment-242007981>



  • 7.  Re: SDK custom filter: reading attribute value in code

    Posted Sep 18, 2017 02:03 PM

    Hi Neelima,

     

    It works, thank you!

     

     

     

     

    With kind regards/

    Met vriendelijke groet,

    Oscar Betgen

    Solution Consultant

     

     

     

     

     

    T     +31 (0)88 303 11 11

    M   +31 (0)6 42787918

    I      www.systemation.nl<http://www.systemation.nl/>

     

     

    <https://www.linkedin.com/in/martinwallenburg>[cid:image003.jpg@01D03AE1.94793B50]<https://twitter.com/systemation>

     

    Atoomweg 50

     

    3542 AB  Utrecht

     

    The Netherlands

     

     

     

     

     

     

     

     

     

     

     

     

     

    Van: kadne01

    Verzonden: maandag 18 september 2017 17:49

    Aan: Oscar Betgen <Oscar.Betgen@systemation.nl>

    Onderwerp: Re:  - Re: SDK custom filter: reading attribute value in code

     

    CA Communities <https://communities.ca.com/?et=watches.email.thread>

     

     

    Re: SDK custom filter: reading attribute value in code

     

    reply from Neelima Kadimi<https://communities.ca.com/people/kadne01?et=watches.email.thread> in DevTest Community - View the full discussion<https://communities.ca.com/message/242007981-re-sdk-custom-filter-reading-attribute-value-in-code?commentID=242007981&et=watches.email.thread#comment-242007981>