Note that there are some explanatory texts on larger screens.

plurals
  1. POSelective and Specific printing of hash Map key - value pairs
    primarykey
    data
    text
    <p>While writing test automation, i was required to leverage the api's provided by the developers and these api accepts HashMap as arguments. The test code involves calling several such api with hashmap as the parameter as shown below.</p> <pre><code> Map&lt;String,String&gt; testMap = new HashMap&lt;String,String&gt;(); setName() { testMap.put("firstName","James"); testMap.put("lastName","Bond"); String fullName=devApi1.submitMap(testMap); testMap.put("realName",fullName); } setAddress() { testMap.put("city","London"); testMap.put("country","Britain"); testMap.put("studio","Hollywood"); testMap.put("firstName",""); testMap.put("person",myMap.get("realName")); devApi2.submitMap(testMap); } </code></pre> <p>However the requirement was to print the testMap in both setName and setAddress functions, but the map should print only those elements (key-value pairs) in alternate lines which are set in the respective function. I mean setName should print 2 elements in the Map which are set before submitMap api is invoked and similarly setAddress should print 5 elements which are set before submitMap is invoked.</p> <p>setName Output must be:</p> <pre><code> The data used for firstName is James. The data used for lastName is Bond </code></pre> <p>setAddress Output must be:</p> <pre><code> The data used for city is London. The data used for country is Britain. The data used for studio is Hollywood. The data used for firstName is null. The data used for person is James Bond </code></pre> <p>Any help, in order to acheive this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload