mardi 2 janvier 2018

How to pass response values to Java API from Karate

How can I pass values from Karate API to Java class?

As mentioned in the documentation, I used the following code snippet to get the response from Java API. But its returning the response with un-formatted JSON content.

Map<String, Object> result = CucumberRunner.runClasspathFeature("demo/java/from-java.feature", args, true);

And then, I used the following script to print the response.

for(Map.Entry<String , Object> entry: getMbrWksMembershipDetailsResponse.entrySet())
{
    if (entry.getKey().equalsIgnoreCase("response"))
    {
        System.out.println(entry.getValue());
    }
}

It shows like,

{soap:Envelope={_={soap:Body={ns1:getMbrWksMembershipDetailsResponse={_={ns4:WksMembershipSummaryResponse={_={ns2:customerSummary={ns2:address={ns2:city=SOUTH CHESTERFIELD, ns2:country=USA, ns2:isoCountryCode=US, ns2:line1=9998, N. MICHIGAN ROAD., ns2:postalCode=23834, ns2:state=VA}, ns2:allowPasswordChange=true, ns2:arpMember=false, ns2:brandCode=RCI, ns2:brandId=1, ns2:companyCode=RCI, ns2:eliteMemberRewardStatus=false, ns2:eliteRewardStatus=true, ns2:europePointsClubMember=false, ns2:firstName=FRANK, ns2:homePhone=804/733-3004, ns2:isoCurrencyCode=USD, ns2:isoLanguageCode=EN, ns2:language=EN, ns2:lastName=BROWNING B, ns2:locale=en_US, ns2:memberDeveloperRenewed=false, ns2:memberEnrolledDate=2009-10-26T00:00:00-04:00, ns2:memberEnrolledForDirectDebit=false, ns2:memberEnrolledForPltDirectDebit=false, ns2:memberStatus=A, ns2:middleName=B, ns2:msgTranslationLanguageCode=EN, ns2:officePhone=0/-0, ns2:pointsCurrencyCode=0......

So it's little difficult to split the data based on the fields / tags from Map.

Please suggest what is the best option to get the values field wize / tag wise from Java API.

Thanks.

Aucun commentaire:

Enregistrer un commentaire