07 - Create Complex Nested Post Request body Using POJO Classes in RestAssured

Поделиться
HTML-код
  • Опубликовано: 4 фев 2025

Комментарии • 57

  • @prikalpanda7864
    @prikalpanda7864 Год назад +2

    *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.*

  • @madhusudandevaraju1207
    @madhusudandevaraju1207 4 года назад +2

    Thanks a lot. This gave me a new dimension to my idea of implementation.👍

  • @surajtiwary7350
    @surajtiwary7350 Год назад +1

    Great content

  • @Vishalfootball
    @Vishalfootball 3 года назад +1

    amazing video brother... i was literally searching for this since 3 days...

    • @SoftwareTestingAndAutomation
      @SoftwareTestingAndAutomation  3 года назад

      Thank you 😊 Keep sharing with your friends.

    • @Vishalfootball
      @Vishalfootball 3 года назад

      @@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

    • @SoftwareTestingAndAutomation
      @SoftwareTestingAndAutomation  3 года назад +1

      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.

    • @Vishalfootball
      @Vishalfootball 3 года назад

      @@SoftwareTestingAndAutomation amazing thanks sir

  • @brookf5
    @brookf5 4 года назад +1

    Well explained. Thank you.

  • @alfredabate3176
    @alfredabate3176 2 года назад +1

    Excellent job! I have been looking for a way to generate payload automatically. This is tremendous help!!! Thank you very much

  • @gm4afsal
    @gm4afsal 3 года назад +1

    You are a life savior! :D

  • @kayalvizhigoogle
    @kayalvizhigoogle 3 года назад +1

    Amazing! thank you!

  • @chetanreddybathula7023
    @chetanreddybathula7023 3 года назад

    Thank you very much bro it helped a lot

  • @AfwanKhan232
    @AfwanKhan232 11 месяцев назад

    Sir, Please respond , Have you created any vedio on how to parse Dynamic and Nested JSON in Java ?

  • @sourinroy992
    @sourinroy992 3 года назад +1

    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?

    • @SoftwareTestingAndAutomation
      @SoftwareTestingAndAutomation  3 года назад +1

      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.

  • @sudeeshkumar7006
    @sudeeshkumar7006 4 года назад +4

    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

    • @SoftwareTestingAndAutomation
      @SoftwareTestingAndAutomation  4 года назад +1

      Sure Sudeesh. I will create a video on that.

    • @pardonmhlanga2192
      @pardonmhlanga2192 3 года назад

      @@SoftwareTestingAndAutomation is there a video which explains the same with data driven approach that you manage to find

  • @ss-do1bp
    @ss-do1bp 2 года назад

    Hello sir,
    Is it possible to create POJO from get request response body and compare it with predefined POJO for validation

  • @flight_of_phoenix
    @flight_of_phoenix 3 года назад +1

    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

    • @SoftwareTestingAndAutomation
      @SoftwareTestingAndAutomation  3 года назад +1

      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);
      }
      }

    • @flight_of_phoenix
      @flight_of_phoenix 3 года назад +1

      @@SoftwareTestingAndAutomation Thanks Guru

  • @gurumurthys1914
    @gurumurthys1914 4 года назад +1

    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

  • @ashishdixit8627
    @ashishdixit8627 3 года назад +1

    Hi @Software Testing And Automation how do I post more than one Objects in single array using Rest API.

  • @WorldReviews24
    @WorldReviews24 3 года назад +2

    Hello Subhasish , will you develop a framework level series for RestAssured?

  • @amitrath839
    @amitrath839 3 года назад +1

    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.

  • @sivakrishnat5471
    @sivakrishnat5471 3 года назад +1

    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.

  • @yogeshnarayanupadhyay7451
    @yogeshnarayanupadhyay7451 4 года назад +1

    Sir can u give this JSON Data which is you used so we can use it and write for practice purpose

    • @SoftwareTestingAndAutomation
      @SoftwareTestingAndAutomation  4 года назад +2

      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"
      }

    • @yogeshnarayanupadhyay7451
      @yogeshnarayanupadhyay7451 4 года назад

      @@SoftwareTestingAndAutomation thanks sir

  • @brookf5
    @brookf5 4 года назад +1

    Could you please make a video on oauth2

  • @sudhakarthangavelu7164
    @sudhakarthangavelu7164 3 года назад +1

    Please Share the link to download the code

  • @sonaliganguly2543
    @sonaliganguly2543 4 года назад +1

    Sir I'm stuck in a post request of my project. Can I send you the Request , if I get your email id?