*As a newbie to API Automation testing I am finding this series very very helpful and confident to quickly learn and deliver in my company. A big THANKS to U.*
@@SoftwareTestingAndAutomation sure bro i wanted more complex cases in nested json and multiple arrays for pojo creation. do u have those videos. would be great if yes
I don't ve any more specific videos but I hope with this video you should able to manage any complex Jsons. If you are facing any issues you can post me that complex Json, I can create a video on that. Also you can refer the complete API automation playlist for better understanding.
Hi Subhasish, I just passed the complete json body through an external file as you showed in your previous video and it worked for me. I found the external file approach quite easier, does industries prefer to use pojo class instead of external file?
If your request body is static data, sending as as external file is good. But if you have to modify your payload as per different testing scenarios, in that time pojo is a better option.
Hi Subhashish, I am not able to serialize the array of values e.g. "options": [ "New York Bulls", "Los Angeles Kings", "Golden State Warriros", "Huston Rocket" ], and also nested arrays like this "members" : [ { "name" : "Molecule Man", "age" : 29, "secretIdentity" : "Dan Jukes", "powers" : [ "Radiation resistance", "Turning tiny", "Radiation blast" ] }, Here I am not able to serialize powers. I tried to add a list of powers to members but it is giving an error. I had created a nested static class like this SuperHeroPojo.Members.Powers pow=new SuperHeroPojo.Members.Powers(); pow.setS1("magic"); Please help
Create two classes like "TPojo" and "ComplexJson" like I ve given below and check the console output. Hope that should help you. public class TPojo { private String[] options; private List members; public String[] getOptions() { return options; } public void setOptions(String[] options) { this.options = options; } public List getMembers() { return members; } public void setMembers(List members) { this.members = members; } public static class Members{ private String name; private Integer age; private String secretIdentity; private String[] powers; public String getName() { return name; } public void setName(String name) { this.name = name; } public Integer getAge() { return age; } public void setAge(Integer age) { this.age = age; } public String getSecretIdentity() { return secretIdentity; } public void setSecretIdentity(String secretIdentity) { this.secretIdentity = secretIdentity; } public String[] getPowers() { return powers; } public void setPowers(String[] powers) { this.powers = powers; } } } -------------- public class ComplexJson { public static void main(String[] args) throws IOException { List memb = new ArrayList(); TPojo.Members m= new Members(); m.setName("Molecule Man"); m.setAge(25); m.setSecretIdentity("Dan Jukes"); m.setPowers(new String[] {"Radiation resistance","Turning tiny","Radiation blast"}); memb.add(m); TPojo tp= new TPojo(); tp.setOptions(new String[] {"New York Bulls","Los Angeles Kings","Golden State Warriros","Huston Rocket"}); tp.setMembers(memb); ObjectMapper objectMapper= new ObjectMapper(); String convertedJson=objectMapper.writeValueAsString(tp); System.out.println("convertedJson is " +convertedJson); } }
Thanks a lot sir. In our project, we have few request parameters like "cipher.firstName", is it possible to handle through POJO classes or we have to depend on the hashMaps, as we cannot create variable such as "private String cipher.firstName ". Could you please help me on this.
what I want is reverse of this. That means from postman I will get complex json. Then I have to map that to pojo. Can you do that? thanks in advance. update: thanks your video helped me to fix my issue. for some reason @SerializedName is not working. So I used same name as in pojo declaration. it is working fine now.
*As a newbie to API Automation testing I am finding this series very very helpful and confident to quickly learn and deliver in my company. A big THANKS to U.*
I am glad to hear that 😊 Thank you !!!!!
Thanks a lot. This gave me a new dimension to my idea of implementation.👍
Welcome. Keep learning new things 🙂
Great content
Thank you 😊
amazing video brother... i was literally searching for this since 3 days...
Thank you 😊 Keep sharing with your friends.
@@SoftwareTestingAndAutomation sure bro
i wanted more complex cases in nested json and multiple arrays for pojo creation. do u have those videos.
would be great if yes
I don't ve any more specific videos but I hope with this video you should able to manage any complex Jsons. If you are facing any issues you can post me that complex Json, I can create a video on that. Also you can refer the complete API automation playlist for better understanding.
@@SoftwareTestingAndAutomation amazing thanks sir
Well explained. Thank you.
Glad it was helpful! Keep learning new things :-)
Excellent job! I have been looking for a way to generate payload automatically. This is tremendous help!!! Thank you very much
Glad it helped!!! Thank you 😊
You are a life savior! :D
Thank you 😊
Amazing! thank you!
welcome 😊
Thank you very much bro it helped a lot
Glad to hear that 😊 keep sharing with your friends.
Sir, Please respond , Have you created any vedio on how to parse Dynamic and Nested JSON in Java ?
Hi Subhasish, I just passed the complete json body through an external file as you showed in your previous video and it worked for me. I found the external file approach quite easier, does industries prefer to use pojo class instead of external file?
If your request body is static data, sending as as external file is good. But if you have to modify your payload as per different testing scenarios, in that time pojo is a better option.
Hi could you make a video where we get the input from Excel and passing to it instead of hardcoding. It will be very helpful. Thanks
Sure Sudeesh. I will create a video on that.
@@SoftwareTestingAndAutomation is there a video which explains the same with data driven approach that you manage to find
Hello sir,
Is it possible to create POJO from get request response body and compare it with predefined POJO for validation
Technically you will able to do it. But why do you need it ?
Hi Subhashish, I am not able to serialize the array of values e.g. "options": [
"New York Bulls",
"Los Angeles Kings",
"Golden State Warriros",
"Huston Rocket"
],
and also nested arrays like this
"members" : [
{
"name" : "Molecule Man",
"age" : 29,
"secretIdentity" : "Dan Jukes",
"powers" : [
"Radiation resistance",
"Turning tiny",
"Radiation blast"
]
},
Here I am not able to serialize powers. I tried to add a list of powers to members but it is giving an error. I had created a nested static class like this
SuperHeroPojo.Members.Powers pow=new SuperHeroPojo.Members.Powers();
pow.setS1("magic");
Please help
Create two classes like "TPojo" and "ComplexJson" like I ve given below and check the console output. Hope that should help you.
public class TPojo {
private String[] options;
private List members;
public String[] getOptions() {
return options;
}
public void setOptions(String[] options) {
this.options = options;
}
public List getMembers() {
return members;
}
public void setMembers(List members) {
this.members = members;
}
public static class Members{
private String name;
private Integer age;
private String secretIdentity;
private String[] powers;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
public String getSecretIdentity() {
return secretIdentity;
}
public void setSecretIdentity(String secretIdentity) {
this.secretIdentity = secretIdentity;
}
public String[] getPowers() {
return powers;
}
public void setPowers(String[] powers) {
this.powers = powers;
}
}
}
--------------
public class ComplexJson {
public static void main(String[] args) throws IOException {
List memb = new ArrayList();
TPojo.Members m= new Members();
m.setName("Molecule Man");
m.setAge(25);
m.setSecretIdentity("Dan Jukes");
m.setPowers(new String[] {"Radiation resistance","Turning tiny","Radiation blast"});
memb.add(m);
TPojo tp= new TPojo();
tp.setOptions(new String[] {"New York Bulls","Los Angeles Kings","Golden State Warriros","Huston Rocket"});
tp.setMembers(memb);
ObjectMapper objectMapper= new ObjectMapper();
String convertedJson=objectMapper.writeValueAsString(tp);
System.out.println("convertedJson is " +convertedJson);
}
}
@@SoftwareTestingAndAutomation Thanks Guru
Thanks and nicely explained , is it possible to create an video framework level for rest api ,so that we may have knowledge at framework level
Thank you. I will create a video on framework soon.
Hi @Software Testing And Automation how do I post more than one Objects in single array using Rest API.
You can use same technique. Let me know your payload, ll help you.
Hello Subhasish , will you develop a framework level series for RestAssured?
Yes it is in my bucket list, it may take little more time.
Thanks a lot sir. In our project, we have few request parameters like "cipher.firstName", is it possible to handle through POJO classes or we have to depend on the hashMaps, as we cannot create variable such as "private String cipher.firstName ". Could you please help me on this.
Please paste your sample request here and let me check
what I want is reverse of this. That means from postman I will get complex json. Then I have to map that to pojo. Can you do that?
thanks in advance.
update: thanks your video helped me to fix my issue. for some reason @SerializedName is not working. So I used same name as in pojo declaration. it is working fine now.
That's great. Thank you.
Sir can u give this JSON Data which is you used so we can use it and write for practice purpose
Please find the payload
{
"instructor": "Subhasish",
"url": "softwaretestingandautomation.com",
"services": "Software Testing",
"expertise": "Testing",
"courses": {
"webAutomation": [
{
"courseTitle": "Selenium",
"price": 4000
},
{
"courseTitle": "Protractor",
"price": 5000
}
],
"apiAutomation": [
{
"courseTitle": "RestAssure",
"price": 5000
},
{
"courseTitle": "SOAP API Automation",
"price": 3000
}
],
"mobileAutomation": [
{
"courseTitle": "Appium",
"price": 5000
}
]
},
"linkedIn": "linkedinId"
}
@@SoftwareTestingAndAutomation thanks sir
Could you please make a video on oauth2
sure I will make it.
Here is the video link on Oauth2 ruclips.net/video/et7ISF99Qik/видео.html and ruclips.net/video/Fs8fsrngI3Q/видео.html
Please Share the link to download the code
I have not added it in Git, ll share once I do it.
Sir I'm stuck in a post request of my project. Can I send you the Request , if I get your email id?
sure, send it to subhasishhelpinghand@gmail.com
@@SoftwareTestingAndAutomation please check Sir, email sent.
Responded, please check.