cancel
Showing results for 
Search instead for 
Did you mean: 

Property Transfer Conditional

SOLVED
Highlighted
Occasional Contributor

Property Transfer Conditional

Hi guys, 

 

I'd like to perform a conditional Property Transfer from one response to the next request. I need to select the first DefCategoriesDispo with the StatutDispo on true and send the CatCode associated to the next request.

 

Here the response : 

 

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetAllDispoSurAgenceV2Response xmlns="http://www.hitech.fr/">
    <GetAllDispoSurAgenceV2Result>


<DefCategoriesDispo>
    <CatId>7</CatId>
    <CatCode>A</CatCode>
    <StatutDispo>false</StatutDispo>
</DefCategoriesDispo>


<DefCategoriesDispo>
    <CatId>8</CatId>
    <CatCode>B</CatCode>
    <StatutDispo>true</StatutDispo>
</DefCategoriesDispo>


<DefCategoriesDispo>
    <CatId>9</CatId>
    <CatCode>C</CatCode>
    <StatutDispo>false</StatutDispo>
</DefCategoriesDispo>


</GetAllDispoSurAgenceV2Result>
</GetAllDispoSurAgenceV2Response>
</soap:Body>
</soap:Envelope>

 

 

Can someone help me please ? 

 

Thanks !

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Community Hero

Re: Property Transfer Conditional

@Toananas 

For the first request (where you get the response and need to extract the data), add a script assertion with following snippet

 

assert context.response, 'Response is empty or null'
//Get DefCategoriesDispo first match with StatutDispo is true
def catDispo = new XmlSlurper().parseText(context.response).'**'.find {it.name() == 'DefCategoriesDispo' && it.StatutDispo == true}

//Extract data and save them into custom properties
context.testCase.setPropertyValue('CATID', catDispo.CatId.text())
context.testCase.setPropertyValue('CATCODE', catDispo.CatCode.text())

In the next step where ever CatId, CatCode are needed

use ${#TestCase#CATID}, ${#TestCase#CATCODE} respectively

 

You can apply the same logic to the rest of the fields.

 

Say for eg:

<hit:Categ>${#TestCase#CATID}</hit:Categ>

 



Regards,
Rao.

View solution in original post

Highlighted
Community Hero

Re: Property Transfer Conditional

Sorry didn't check in detail. Thought you posted the solution using existing one.

You got a trivial error. enclose O between single quotes like 'O'


Regards,
Rao.

View solution in original post

15 REPLIES 15
Highlighted
Community Hero

Re: Property Transfer Conditional

But there are multiple matches. What do you want to do when more than one match?
Sample request of next step where you need those values?


Regards,
Rao.
Highlighted
Occasional Contributor

Re: Property Transfer Conditional

Hi Rao, then so select the first response with "True" or to select one of them randomly. 

The selected CodeCat goes to <hit:Categ>?</hit:Categ>

Sure  : 

 

s<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hit="http://www.hitech.fr/">
   <soapenv:Header/>
   <soapenv:Body>
      <hit:GetDispoSurAgence>
         <hit:CodeOrigine>?</hit:CodeOrigine>
         <hit:CodeAgence>?</hit:CodeAgence>
         <hit:Categ>?</hit:Categ>
         <hit:Depart>?</hit:Depart>
         <hit:Retour>?</hit:Retour>
      </hit:GetDispoSurAgence>
   </soapenv:Body>
</soapenv:Envelope>

 

Highlighted
Community Hero

Re: Property Transfer Conditional

@Toananas 

For the first request (where you get the response and need to extract the data), add a script assertion with following snippet

 

assert context.response, 'Response is empty or null'
//Get DefCategoriesDispo first match with StatutDispo is true
def catDispo = new XmlSlurper().parseText(context.response).'**'.find {it.name() == 'DefCategoriesDispo' && it.StatutDispo == true}

//Extract data and save them into custom properties
context.testCase.setPropertyValue('CATID', catDispo.CatId.text())
context.testCase.setPropertyValue('CATCODE', catDispo.CatCode.text())

In the next step where ever CatId, CatCode are needed

use ${#TestCase#CATID}, ${#TestCase#CATCODE} respectively

 

You can apply the same logic to the rest of the fields.

 

Say for eg:

<hit:Categ>${#TestCase#CATID}</hit:Categ>

 



Regards,
Rao.

View solution in original post

Highlighted
Occasional Contributor

Re: Property Transfer Conditional

Thanks ! But I got now an error : 

 

error.JPG

Highlighted
Community Hero

Re: Property Transfer Conditional

Sorry, use 'setPropertyValue', not 'setProperty'


Regards,
Rao.
Highlighted
Occasional Contributor

Re: Property Transfer Conditional

Thanks, I still got an error 

 

error.JPG

Highlighted
Community Hero

Re: Property Transfer Conditional

Please run the test step.
It will work if the response you are going to receive and what you provided in the question matches.


Regards,
Rao.
Highlighted
Community Hero

Re: Property Transfer Conditional

You should not change, please use as the script is provided.
I see you modified last two statements.


Regards,
Rao.
Highlighted
Occasional Contributor

Re: Property Transfer Conditional

Oh god it's working, thanks a lot buddy ! Have a good day & stay safe !

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors