Transcript for:
Creating an API Test Automation Framework

hey friends how's it going so in today's video we will be building a complete API test automation framework from scratch now if you haven't met yet hi my name is jutan and I'm a principal QA with 10 plus years of experience in automation testing and devops now this video comes from my main course the live sessions which I take for the sad Mastery Program where I help students and professionals transform their career from manual to automation testing now in this particular video you will learn how to create an API test automation framework from scratch you will also learn how to use the rest assured library in your automation framework okay next we will learn the different design patterns that you need to know while you create your API test automation framework along with that we will learn how to write clean and maintainable test scripts in your frame work now throughout this entire video I will be discussing the common challenges students and professionals face while creating the framework okay now the beauty of this particular video guys is that I will be building the entire framework in front of you guys so you will be seeing the live coding happening okay throughout the entire video you will also hear the discussions the doubts that I'm having with students so probably probably these questions will be something that you might also think so you will get the direct Clarity on why certain topics are used for your convenience I have created the notes for this entire course and you will find it in the description section for this video now without wasting time guys let's get started okay and this is actually um a kind of a group session that I decided so I was not having any class in the weekend for today and uh people from other batches have also joined uh anyways so the main thing um over here guys is um it's going to be a quick recap for everyone and uh the most important thing is for the next two days that is today and tomorrow we will be building an API automation framework okay I believe um it's um you have Sol the Tet interview question which is there on the LMS okay um that particular assignment um would be the backbone okay if you haven't solved it I would suggest you this is like the month of December so please make sure that you try to complete it off this month itself so you are aware of your entire API as well as your UI automation framework most of the around 30 40% uh things will be similar for that would you what would you have seen it in the Tet interview cion rest of the stuff I'll be introducing it in today's class uh so what I've done um over here guys is for your convenience uh just give me one moment let me uh select that page yeah let me know if my screen is visible yeah I hope you guys are able to see the screen right now yep okay perfect okay what I've done for your convenience guys I've given it a more like a stepbystep guide for you guys to practice it off especially for people who have just started and they really don't know what exactly is apis and all those things but I don't think there is going to be any person who is not aware of apis so um over here it is going to be a little bit different a lot of things um I won't be discussing uh in this particular class what we will be discussing and what will be the major premise of this particular class I'll just first talk about that the major focus is only going to be on building the API automation framework okay so the first thing and the only thing that I want to focus on is building the framework okay that's the only thing this uh two days is going to be focusing on um I want to but I can't really go into discussing the various type of authorization and all those things so you will be finding those things in the LMS in future right now that's not something really important because if you're giving interview also they'll probably ask you what is the authorization technique used in your project how did you uh pass the authorization token how did you write the test in apis so and so forth so this is going to be more from the Practical implementation perspective rather than conceptual perspective though I will try to discuss those things as much as I can but you know like we have a timeline so we need to complete it in 2 days the next thing that comes over here guys is uh um this is the entire documentation probably it would be a great idea for you guys that you download it off uh take a print out of it and when you are practicing it you know like you have some some kind of a reference for you guys okay so you can use it for your reference I broken it down into scripts so whenever I will be coming and writing code I'll just try to use this as a reference okay not 90% of the time I'll probably write it by myself over there but for you guys I have given this particular notes so that you understand how exactly the framework needs to be created okay uh for your convenience um the different design patterns uh that will come into picture how exactly service object model will be different from page object model okay I'll come to this particular page probably tomorrow okay but not something really need to be worried about so the end to endend structure of this particular framework I have created it off how exactly logger needs to be created um logger will be more or less similar that what you have seen it in the tell it okay the only thing is what are filters and rest assured that's something that I'll probably discuss it off in tomorrow's class it's for day two so technically nothing to worry on all those things okay now um when you guys probably I'm talking about the everyone over here like when you saw the old application was Phoenix application most of you guys would be I'm I still see you guys test that particular application so I know that part but uh over the period of time like uh there were a couple of new applications that I was building I was trying to learn different things so I created uh a separate application itself now which um is uh Swift actually okay so it's it's a kind of a different application um which gives more or less more scenarios compared to that of your Phoenix Phoenix was simple cred application of course this is also cred application but um over there the number of apis I try to increase it off the number of scenarios number of challenges that you face in your uh API testing I try to add it off overo okay so for you guys uh you can use this particular application which is uh swift. um something like swift. Tech Jan you can just visit this particular website and uh just for the folks who are not aware of this particular stuff it's just a simple banking application okay trying to depict a banking application but the way it is created is um it has only bugs okay you will never find anything okay such uh like something which works but still doesn't work over here and the reason for that is uh instead of giving you an application which is already working properly and I then tell you guys to test it off that doesn't make sense right because then you won't be able to understand why why are we testing something so I thought we'll do the reverse stuff we created the application then we introduced the bugs now for your convenience what needs to be tested how it needs to be tested I have already created these um scenarios for you if I'm not wrong these are all your API testing scenarios okay so check whether the user is able to register check whether uh existing uh user is um registration with existing username is happening or not so it should fail so whether it's a positive scenario or negative scenario I've covered it off so when you guys are practicing it also what needs to be tested how it what all scenarios are there these things are written over here so you can take it as a reference and practice it off okay it's just going to help you guys speed up your entire testing part over here uh as of for today I will be using this particular stuff itself so the entire API documentation of your Swift application is this Swagger do which is this new server which is there I'll probably put it inside um um this documentation itself so that uh you know like even if you want to use it off you'll find it at one place I hope this part is clear to everyone okay just for you guys I'll comment it off also uh where is this PDF uh it's not a PDF uh it's a web page buddy so okay um see if you are able to open this particular documentation for UI and API both as in I did not get that particular question what exactly that means let me just see that part where is this PDF UI and API both as in I didn't catch that particular question anyways so let's get started over here now uh the thing is let's try to do it in a bit different way okay uh let me share the Whiteboard I hope you guys are able to see my screen right now mhm okay perfect so this is the API automation framework that we need to create now let's say that in interview they ask you about the framework that you have created okay particularly from apis okay generally whenever you're creating the framework um for your application it's always better that you say that you have created one framework which is able to do multiple things okay because then you have only one Center Point to look at now over here let's let's say that you have created an API automation framework so the first thing that comes into picture is which libraries are you going to use so the library that we have used is of course rest assured okay plus test AG we'll come to this particular library now when you are trying to test an application okay a common question that can come into picture is how many apis you have tested how many apis you have tested over there so you can just say whatever the count which is there okay right now I've just increased it off to let's say 27 28 API whatever coming into picture but the point that comes into picture is how the framework is created how did you write your API test okay today the team actually released one lecture over there in the E uh in the LMS which is the epam interview question and the first question which is very commonly asked question is write the snippet for your rest a short script write the snippet for your rest a short script so generally whenever people try to take interviews they will see if you're able to write the API scripts or not that's the first thing like how exactly you'll be using your rest assured library now whenever we are testing any application the first thing that the developer would be giving it giving to us is this Swagger document okay creating this document is not a big thing it's something which is generated by the system itself but this document will be available and over here you see there are various sections account controller admin controller authentication kyc controller mock UI mock UPI controller report controller transaction user management controller these are basically what you call as service each tab over here is called as a service over here okay so let's say this becomes a service so in an application I have authentication as a service now when authentication as a service comes into picture there are multiple things that can happen with au authentication someone can login someone can create account someone can say that I forgot my password right so this tab which you see is my authentication Service section and if you're not able to remember remember that part just open any of these things you see this area API for/ API for/ this is basically your o authentication Service that's popping up what you see over here sign up reset password login and forgot password these becomes my end point now the thing that comes into picture is I have to test this particular end point yes or no that's the most simplest thing that comes over there now when you're talking about apis just for a quick revision data from UI will be given to API and API is going to give the data or is going to fire a query over the database and it's going to retrieve the data and it is going to give the data back to UI that's what the working of API is it's just it's like a mediator okay and generally what this mediator tries to does it it tries to create abstraction or it's trying to hide the direct access to database as simple as that the reason we have to do that part is because if you're trying to hide it off you know like illegal access to the database is not going to happen Okay dat operation perform dat right so that's the thing that comes into picture now now over here the thing is how do I come to know what data needs to be sent of course if there is going to be a Swagger documentation it becomes pretty easy where I can see these things happening over into picture that this is going to be the payload this is the response which will come into picture and I can cross check the same thing from here also let's say I say log out now I forgot the password just give me a moment what is the new password over here same yeah now over here this is the UI if I right click click on inspect go to the networks tab over here I will see all the API calls which are happening note that you have to be in Fetch for/ xhr tab you can be in all also but I am not interested in all operations like I don't want to see all the calls which are happening over the network I just want to see the API calls which are coming into picture so that's the reason I have written fetch for/ XR of mar those sign in so of course when I try to do sign in and the credentials is bad let me just cross check what can be the credentials over here is it right ah this is the right one okay I keep on forgetting the stuff anyways so over here even though the login has happened but uh let's go to all log out okay sign in it's not showing me just give me a moment update the password okay so here you can see the login API call which is coming into picture now you see the credentials over there which was written was if I go to the payload UD 1234 UD 12 34 that's the credentials which was there so the username and password is given from the UI to the API from the UI the user would have entered UD 1 2 3 4 UD 1 2 3 4 and the credentials would have been given to the API when API try to fire the data or fire the query let's say select star from data space where the username is going to be udai 123 4 and password is going to be 1 12 34 there would be a response coming some entry needs to be there so when I go to the response this is the response which is coming back and the journey over here is that I have to test whether the apis are working correctly or not as is this part clear to everyone yes or no okay so I know the payload and I know the response which is coming over here and this is something that I need to test okay now over here how to approach this particular stuff now we'll go step by step the first thing uh that what I want to do over here is let's say let's close all the tabs over here everything let's close and one moment yeah perfect let's create a new project itself I'm going to create a new project and I'm going to call this as a maven based project so the API automation framework that we have created is a maven based project and I'm going to call this particular project as uh demo API automation framework because I've already used a lot of words like API framework and all okay I'm going to copy this and I'm going to put it off over you now over here guys let's click on finish and where exactly comes yeah this is where the demo API automation framework comes into picture so this is my your API automation framework which is there now over here the first thing that I need to do is I need to make sure that I'm updating my Java versions better to go for Java 11 version Java 17 version than to stick to 1.8 so I'm just going to go to build path configure build path and make sure you change the version from 1.8 and just click on edit and change it to Java 11 okay Finish apply and close the change has happened next go to the pom.xml file and you have to introduce the dependencies what dependencies you're going to introduce rest assured and testng so if I go to your document just scroll to the first section of course you can go to the m repository and all I'm just trying to keep things simple for now uh if I just scroll down you're going to take these dependencies pal. examl dependencies copy it off and pasted it off over here nothing fancy stuff I have done over here so I have this rest assured and I have this test NG dependency which is there and over here the only focus right now for me the entire thing the entire purpose of my life is to just test this login API apart from that I don't want to focus on anything else that I have been given this API I have to make API request and rest assured and I have to assert whether the status code turns out to be 200 or not that's the ultimate purpose of my life that's all okay and along with that along with that probably I'll just check whether token and all those things gets generated something like that we can do those things now how do we do that part just a quick revision for rest ass short for people now whenever you writing test you will always be writing the test in sassc test Chava that's the whole purpose if you if you are going to write any test okay reason because ultimately you want to run your framework and you will be running your framework with the command what mavin test okay you will write something called uh mavin okay test and what Maven test is going to do is it's going to run whatever is there over here so Maven test compiles this particular package and whatever is there in this particular folder and it's going to execute it off test it's going to start executing all right that's that's the reason now over here the first thing that I want to do is I want to create a package so I'm going to create the first package of your automation framework you want to make a note of this particular package if you want com. api. test so all the test related to my application particularly my API t test will be available over here now what is the test that we want to focus on login API test so I'm going to quickly create a class let's call this particular class as login API test okay let's uh drop this thing off zoom in and what we do over here guys is we're going to create a test method please be on mute public void let's say this is going to be login test something like that now of course this is a test NG test so you're going to introduce the test NG annotation you know you have to give name and all those things okay just for your revision I'll put it off over here verify if login API is working something like that I put it off okay now sorry description my bad my bad okay now over here the story starts over here I want to test the API in order to test the API the library that comes into picture is rest assured I have added the dependency of rest assured into my application for.xml file this is where rest assured is now of course rest assured is a class it's a class so do I need to create an object of rest assured yes or no do I need to create an object of rest ass short people were aware of that part yes no you're not supposed to create an object of rest ass short class and the reason for that is if I go to the rest ass short class let's go to this particular class okay observe carefully if I go to this particular class guys all the variables are static in nature all the variables are static in nature scroll down all the methods are static in nature okay all the methods are static in nature so this is not a normal class this is a utility class what class utility class what is a utility Class A utility class is a class in which all the variables and the methods are going to be static in nature okay all the variables and methods are going to be static in nature so if you are going to have variables and methods in a class as static generally that particular class is called as utility class like the answer is yes this is something which is there now a lot of things in Java let's say if you go to a class called let's say arrays class arrays is a utility class look at the package name java.util whenever you are using or decide to use arrays class St okay similarly there's a class in Java which is called as math. random I can say math which belongs to java. Lang but it is also a utility class it has all the variables and methods as static okay so utility classes are something which is reusable component you I'm like you have to keep on using it again and again anywhere without creating the object that's the reason so rest assured is like that now in order to make a login request in rest assured or let's say I have to make a request and rest assured I can just say rest assured dot because variables and methods are static in nature what I have to use given method this is the first thing that I'm supposed to give now what is the return type of given method what does given method returns me yeah it's going to give me request specification this is the return type okay given returns you request specification so I'm just going to put it off something like this over here or let's take it in a much more different way the first thing that I want to do is I want to give the base URI so I'm going to say base UI okay what is the base URI of this application now when I was creating this application I just took things a little bit in a different way you see you will not be able to see the IP address of this or the application uh the sorry the back end C server path or the IP address over there okay this is for the security reasons okay so only if you are aware of the IP address you will be able to connect to the back end are you getting the point if you know the IP address to have API request if you try to make it from this particular URL which is written over here it's not going to work so it's a rapper that is there over here so we have to rely on this chap now so let's say the developer says that go and use the Swagger UI and uh over here I'm supposed to enter the credentials to just understand how exactly this uh login API works so I'm going to go to this API o/ login if you see carefully this is the login API API o login so I'm coming over here I'm going to say I want to try it off in the request body you give the username what was the username UD 1 2 3 4 what was the password UD 1 2 3 4 up execute so I am able to see the curl and I'm able to see the response coming into picture so if I will be entering this particular credentials in Json format if the header is going to be content type application Jason this becomes the end sorry the base URL of the application this becomes the base path and this becomes the end point is this part clear to everyone I'm able to see that information over here is this part clear to everyone perfect and here I'm able to see the response coming into picture so I know the base URI I'm going to copy this path go back to my application uh over here I'm going to set the base Ur next thing next thing over here rest short. base URI this is the first thing now what is restur it's a class which has methods as static now the next thing I do is I say rest assured dot given method this is the start because this is what you have to call for making the request given method returns you request specification now I'll tell you something which is very important return type Focus sub given method is going to return me request specification so if given is returning me request specification I want to store it inside a variable Java is a uh what do you call typed language so over here whatever is the data type what given is going to give me back X data type if given method is return you returning you integer value X data type should be integer if given is returning me string value X data type should be string but given is returning me what request specification so I have to use request specification now the main thing that comes into picture over here is what is request specification okay that can be an interview question what is the purpose of request specification if I have to explain you what is request specification in the simplest term it's written over here it allows you to specify how the request is going to look to my request I have to attach header to the request I want to attach body to my head uh to my request I want to attach authorization token right all those things I can handle it with request specification so whatever will be the payload end point your uh HTTP verb your body all those things I want to pass mu request specification is this part clear so this will take care of how the request is going to look okay now over here I have to attach my header okay my header is going to be pretty simple so if I go x. header I can pass the header in key value format simple key value format header pass so what is my header over here header is content type is application Json this is not really required okay this is something you can ignore it of content type application Json so I'm going to take this content type I'm going to attach it to my header and the second one is going to be application Chason just copy this double quot okay so the header key and value you need to give it in the string format now if I bring my cursor to header method header returns me what what is the return type of header you can see after the Green Dot which is written it returns you what request specification f a request specification there okay so over here let's say I create another variable called request specification I'll say y okay now to this y I want to attach the body a body is a overloaded method same method name different parameters you can pass the body from the file you can pass it in a bite array you can pass it as a p model or a pojo object you can pass it in the form of a string okay life simple pass it in the string format so I'm going to go over here and I'm going to take this entire Json as it is okay copy this paste it over here and I'm going to put it in double Cotes and now I have to fix this backwards slash backward this is correct okay body just give me a moment something went wrong but here yeah pass one remain thank you I'll fix it all thank you done bring your cursor to body what does body returns you request specification so over here I'm going to copy this put it off over here make it XY Z and then to this Zed I want to make a post request and this is where I decide to give my end point so what is the end point this is the chap I'm going to copy API login now if You observe I have given everything whatever I had I've given this it to this chat okay all the things are available at one place so over here you have the base URI you have the base URI you have the head header you have the body this is a post request and this is the end point whatever things which is required to make the request is available over here okay now if you look at the uh return type of this particular method just bring your cursor to post method and if I bring my cursor over here post is going to return you what response this is where my response comes into picture and I can say response response okay I can just say system.out.print Ln print me the response as pretty string okay as pretty string something like that now keeping my fingers crossed let's clip on run and see whether it works and here you will see that I am able to see the response I'm not testing anything as such but over here I'm able to see the response coming into picture that this is the token the type of the token is a bearer token ID is three username is UD 1 2 3 4 email address is this this is a user and if I go back to my uh response body it's the same kind of response token type ID username email rules and all those things are available now this is the script which I have written knowing nothing about rest assured variable continue so this is my script how it looks okay probably you want to do a simplest assertion I can just say assert that assert do assert equals which comes from test NG and I can say response. get me the status code and I can say status code okay that's something that I want to check over here okay so if I run this particular stuff the test runs it works but if I just change the status code of course it's going to fail something like this if I try to do it the test is going to fail okay and the reason for this particular failure is going to be assertion has failed because we were expecting the status code to be 200 but we found 2112 okay now this is a actually the premise the starting point for our framework like J we have seen this particular script you have written the same stuff again the story is also same you don't change the story also you always come up with the same stuff creating XY Z variable and all now over here rest assured already implements something which is called as the Builder design pattern simple time if you have seen or studied what exactly methods are and how EXA exactly methods needs to be created from the LMS topic I've always said that whenever you are creating a method a method needs to return something okay void is never a good return type void is never a good return type in fact even if you look at the objectoriented part which I've kept over there okay for people you know like some people were saying that it's there in uh Hindi you just make it a little bit in English so the entire from the lecture of object Orient module all those things are in English only okay we just decided to change it off over there so all the lectures are kept in in English language so if you can use it you can study it from there so over there this void return type is a very bad return type it's not good okay test can be void test can be void your main method can be void because they are the only methods that get executed at the end return okay but any other method words that you call it's always good that they return something even when I have created the page classes I have always told that make sure the page methods returns something because if methods are going to return I can chain them together yeah do login with so and so credentials return the page object then you can connect the dashboard page object so and so forth if you're able to recollect that's something that you're supposed to do so one of the best practices whenever you are creating applications or writing any code me return in simple terms this is a method call if you are calling someone you expect them to answer it hello as simple as that okay so over here whenever there is going to be methods which are returning something you can chain them together so the script takes a little bit of maturity now he Baba if these methods can are returning the same thing request specification request specification instead of writing x x equal to rest ass short. given x equal to rest ass short. given to replace the answer is yes y do body Y is what rest assure dog. header I can take the this thing can I replace it and put it over here the answer is yes z. post I can just take this thing and I can put it off over here Association now if x = 10 y = x then y = 10 are you getting the point okay I don't even need to write this line so instead of writing the same thing again and again again and again because there is this return type chaining which is happening you can keep on connecting them together rest assur dot given header body okay make the post request to the following end point response low response in the pretty format printing it off checking whether the status code is 2112 let's change it to 200 and this is where we are clear to everyone yes or no what I have written so far perfect everyone in the call yeah perfect great now comes the second concept see whenever you are using a class uh interface which is going to have static methods inside them it's always better that you do a static input the only benefit of static UT is the readability that comes into picture so if I go to rest assur class I am 100% sure K Baba all the methods and variables are static I showed you okay so whenever you are using rest assured makes sure make sure that you are doing a static UT now you'll say what is the benefit of static import P readability I don't need to write rest or short dot base U this line goes away so the script becomes this given header body and all those things so if an interview they ask why do you do static UT for rest assured the straight away answer is improves readability byy there's no change in the performance and all you don't have to write the class name dot something getting the point so without class name I'll be able to access it off now the thing that comes into picture over here is the thing that comes picture over here is this base I don't like this thing over here like your half of the family is over here one guy is sitting you know like fooling around here so it didn't look good so it's always better that you connect this also together so in your rest ass short class they have created I don't know why but they have created a method called base URI and you can just pass it off over here okay sem and you don't need this chck if I run this particular stuff the output is still the same so after some time when you start writing the script I've always said don't focus on the output script now is the time to optimize it is this part making sense output is not going to change clear to everyone so this is the script which we have written okay and this becomes your first rest assured script rest assured script coming into picture now suppose let's try to think of a bigger number tomorrow uh right now at at this particular moment I have 27 apis to test okay right now can we create a class variable if base URI is same for multiple test uh I'll come to that I'll come to that in a moment you are close enough that's not the major thing start so right now guys I have 27 apis to test let's try to increase the number tomorrow you have 270 apis to test then these many API you decide to test up if you try to imagine this is the test I have written for uh this is the script I have written for one API test if tomorrow the requirement is that go and test a lot of apis so I have to write a lot of test scripts a lot of classes will be created and this is how my script will look what's wrong with that the problem that comes into picture is hard coding log usern mobile OTP log is going to happen two Factor Lo authentication comes into picture and they have modified the login feature you have to make changes everywhere wherever login scripts are getting called yes or no if there is going to be any slight change that comes into picture in your uh application in your apis the entire test scripts will get modified so the problem with this script is that this is a a quite brittle script if if I'm using the word correct brittle be change and when I say to you have to come and start modifying it everywhere okay this is the problem that comes into picture are you understanding the problem statement over here that what we what we have written even though the code works correctly you are getting the output but this is not the framework or the test script that you can use is this part clear to everyone okay up then we start thinking what exactly we can do in this kind of a scenario then I go back to the Swagger document for a moment or I start observing something if You observe the Swagger dog which is in front of you either pattern in the way the apis are arranged and given to you f Authentication R apis I have a section called authentication authentication becomes a service for me and this service gives me four end points that needs to be tested so if tomorrow any change or any new API is going to come into picture for authentication if tomorrow there is going to be any modification for login this section will get updated so over here if I tell you guys to imagine this as a class imagine this as a class that I have an authentication class get post put delete these are all methods HTTP methods forgot password will become a method login will become a method reset password is going to become method sign up is going to become become a method so what I'm able to imagine at this particular moment is I'm going to have an authentication Service class which has four methods inside them forgot password login password reset uh login reset password and sign up these are the functionalities of my authentication are you able to connect to this thing okay that when I look at Swagger documentation this is how the structure is given to us yes or no this is the first thing unless you imagine okay so this is something you need to First Connect that this is what I'm able to see I'm like okay now the story starts over here we again go back to the script I'm again saying story starts over there's there's another thing that comes into picture over here let's go back to the script now the next thing what swap was saying B right because this is common to all my end points or my services this is base URL it is going to be common to all the services which is coming into picture so if something is common if something is common okay and you are able to see that contact controller is going to become a class admin controller is going to become class authentication controller is going to become class kyc controller is going to become class and there is something common which I want to share it across everyone how can I do that you will say either make it static I'm able to see that there can be a component coming into picture which I can call it as a base service where whatever is common across all these service components I can keep it off over here make sense to everyone yes or no anything which is common okay across all these Services I can keep it in the base service what can be common if I go back to my script given base URI header to request specification in every test script that you will be writing will you create a request specification will you use the given method let's say there are 10 15 test scripts I have written given method call yes or no will you write given method for all those test scripts yes or no will this method given method would have been called in all the test yes or no yes or no given method what I've been called now I have called it over here also for this method here also so the thing is given method is common but what is given method giving me request specification so the thing my dear friends is base service will be responsible for setting up request specification is this part clear to everyone is this part clear to everyone so this is where the new component of your automation framework or I would say the first component of your automation framework comes into picture which is your pace service so let's go back and what I decide is I decide to create a new package you can create it in SRC main Java you can create it in SRC test Java I'll create it in SRC test Java I'm going to create this particular package and I'm going to call this particular package as com. api. base and over here this introduces a new um design pattern which is the service object model okay so I'm going to come to that but I'm going to call first this as AP uh sorry Base Service that's the name of my class I'll write it down for you what exactly this class is going to do this class is going to be responsible for handling the base URI IP address hand second thing is it is going to be responsible for creating the the request is this part clear to everyone it is also going to be responsible for handling the response so this is the rapper for your rest assur in simple terms if I have to explain yeah rapper for rest assur because this is where abstraction starts to come into picture hold on hold on I'll show what happens now over here the first thing that I decide to do is I decide to create a private string variable called base URL okay and I'm going to initialize this chap with this guy so I'm going to take it from here or you can take it from anywhere wherever you want man so you can just go to login okay yeah this is the chap you good put it over here is this a constant the answer is yes constants are always going to be written in uppercase okay if anything is constant it is going to be marked with final keyword if something becomes final static because final will never come alone final will come with static for variables not for methods is this part clear to everyone is this part clear to everyone yes or no let's go to the documentation for a moment over here okay first I've added the dependencies just to repeat it off I created the test this is my test script and over here we are introducing a new design pattern which is called a service object model I'll come to this particular document in a moment don't worry about it but over here this is the base service which you see okay the base service class and what this Base Service class I'm not able to zoom it let's this is the base service class and what this Base Service class is doing it has a instance variable here Ive just kept the snippet mean I'm doing it over there take what is this config manager and all don't worry protected request specification I'm creating a off and it is going to have a Constructor by mistake it is written protected it should be public okay so over here this will become public so over here you just create an instance variable private request specification request specification and I'm going to have a Constructor over here a default Constructor and job of the default Constructor what is the job of the Constructor what is the job of the Constructor to initialize the instance variable varable is base URL my instance variable is base URL my instance variable static variable this becomes the class variable only request specification will be initialized so I'm going to say base request specification equal to rest short dot given because given method returns me the given method returns me the request specification to this request specification I will attach the base URL this over here is the exact same line which you see in the login API test yes or no isn't just the same line clear to everyone yes or no exactly I could have done the static import but right now I am not like if you want you can do that it's not a big thing I can just see over here static import but the only thing is I have changed it off and instead of mugging up these things now just remember the rule what is the rule request specification is instance variable initialize Constructor so inside the Constructor I need to create initialize request specification I cannot create an object of request specification because this chap is an interface so over here whenever you have to create request specification you have to write given. base URI and pass the URL is this part clear yes or no can I go ahead now the requirement is he Baba I will create a post request because if you go to the login API test over here you are attaching the header you are passing the body and you are making the post request out of all these things the data is hardcoded but up attach header you are passing the body and you are making the post request so here I'm doing three method called header body post so I go to the base service and I will say Baba I will create a method protected post is going to be my method or I can say post request in order to make the post request I need three things header body and end point but I'm only going to give two string body or use a technical term payload next what do I need end point okay now imagine request specification was set either request how would you have made it request specification dot dot over here over here I want to attach the body body I will pass in the string format pass payload and I will make the post request to this end point clear is this part clear I will be giving the payload I will be giving the endpoint and over here this request will be made is this part clear to everyone yes or no is this part clear to everyone let me read this stuff now what does post method returns me what does post method returns you if I bring my cursor over response response response thank you but I did a cheating in order to make post request I need three things header next body that is the payload and the end point so what I can do is I can use something which is the inbuilt functionality called content type because he was passing the content type is application Json so over here I can use this content type method and I can just say content type which is my enum and content type is going to be Json up okay J what if I have to attach other headers wait will come to that my major focus is only on login apart from me login exist okay so request specification do content type it is going to take care of attaching content type as Json body whatever the body I'm passing and end point now this entire thing returns me what look at the last method post post returns mean response void is a very bad return type so now tell me what this request what this method is going to return me respon finish done congrats okay done okay this is something that we have created so I have created the base service and what this Base Service is it is a wrapper over your rest assured in your selenium I created browser utility which was rapper over selenium web driver okay so in life whenever you want to make things better create a rapper now the next thing that comes into picture this is the base service but service controller admin controller authentication we are focusing in only on authentication so what we will do over here guys is I'm going to create a class inside API base and I'm going to call this particular class okay as as uh o service o service is going to depict this chap tab now service is going to have a relationship with base service so I'm going to say all service extends Base Service is this part clear to everyone so the request specification variable the post method which I have created I can access it over here over here I am going to create a variable called base underscore U path base path sorry and base path is API forward slash either I sorry over here I'm just going to take this path API for/ API underscore path this is constant across all my uh HTTP uh end points for this authentication Service forgot password May login May reset password May sign in API API API API this is constant constants are always marked with final keyword final static be and we will write it in Upper Pie as simple as that now the next thing that comes into picture over here o service may all service has a method called login I hope this part is now making sense Au service is going to have a method called login public void login in order to make a login request what do I need I need the payload end point I'll give the end point login method will internally call the Post request you're going to pass the payload and endpoint will be attached here because of course if it's going to be login method log method okay is this part clear to everyone so login I will be passing the payload and this login method internally calls the post request I want to ask you post request return the post request that we have cre cre it returns response return and if post request return whatever post request is giving so what will be the return type of this method response and congratulations you have created your first service that is the authentication Service authentication Service has a endpoint called login call you will be passing the p Lo okay now how exactly my test looks then it takes me to the third level where I don't need any of these chaps anymore login test start telling me from the Swagger login HTTP or login endpoint belongs to with service login uh uh endpoint belongs to authentication Service so I have to create an object of authentication Service o service has multiple uh what you call end points kco test login Au service. login I need to pass the payload over here so payload I'll just copy it from here okay and I attach it over here login returns me whaton response finish story is over here response uh response and I can just say system.out.print Ln if everything works correctly the way we want over here I have to put a disclaimer because you know like while talking I can just make a mistake but let's see if it works okay if I click on the Run button and if everything works correctly by output are no see something went wrong but we'll check on that part so over here you see I'm getting an error unauthorized and uh if I am trying to let's try to debug what went wrong over here let's go to it's not ah smart Chu so just take the B path smart logo done finish base path plus forward SL login now if I click on the play button okay if I bring Tada done okay so like yeah benefit mil the benefit is from where you started and where you ended the first test which I wrote was this the second test which I wrote was this this the third test which I wrote over here is this F is tomorrow if my manager says Baba go and run only authentication Service Test authentication Service methods are you getting the point so if I'm going to have multiple microservices and out of those microservices I only want to test certain microservices I don't want to test all I just want to test authentication I want to test only kyc object methods are you getting the point is this part making sense to everyone so even the segregation the management becomes better in this approach this is what you call as your service object model you use page object model in your UI automation framework in your API automation framework you use service object model so basically the purpose of subject uh service object model is to handle the business logic and application rules where did I handle the business logic handle authentication Service has an endpoint called login it will make the post request return whatever you want to test that is up to you I will return you the response you test whatever you want the next thing that comes into picture is it is only going to have business and service layer so that's the reason Services I have created I will create the respective service class for them make sense to whatever you are seeing now you start imagining K Baba account controller this will become my class it is going to have three methods post account account and pass the account number account and it is going to have user okay admin controller it is going to have 1 2 3 4 5 6 six 7even eight eight methods this particular class authentication will have four methods user management is going to have five methods is this part clear this is how you will structure it off yes or no is this part clear to everyone there one question here so if we want to test any flow like first of all login then some other API and then some other so this type of thing will work in that case of course you start creating the objects in certain way first you will call the authentication login API then you will create the object of admin controller and you will call that method then you will create let's say account controller whatever you want I have done that particular flow also I'll show it in probably tomorrow's class or something CH but keep on creating the object if you want to see where good question just give me a moment h can you see API automation framework H first create o service you see I'll come to the script over okay I will get the token you see I will attach the token to user service and I'm taking the token from the authentication Service I'm giving it to the user service service make sense I'm taking the data from like then that token I'm giving it to update user profile service so these are different methods one method second method third method so on and so forth getting the point so every time I'm creating a different object for that service clear then service make sense okay that becomes easier thank you any other questions can I go ahead can I go ahead yes but we have a problem here also you'll be like J hard code data yeah this is the problem hard coding is bad so over here we will create the next component of your framework which you are pretty much aware of I've taught you n number of times which is Ojos okay another the term for pojo for these days not these days they technically call it off models so I'm going to create something called models com. api. models and what are models in simple terms if I have to explain you so if I go to login open this chat I have a request payload I have a response payload so I will create a request model I will create a response model so over here I have to create a Java class which depicts this chap so what I'm going to do I'm going to right click create a new uh package and I'm going to call this as request request request package then I'm going to create a new package and I'm going to call this as response so all my response models will be kept over here but first let's focus on request model and I'm going to call this as login request and over here my job is pretty simple just create a pojo class okay this depicts username and password right click go to Source generate the Constructor using the fields right click go to Source generate the uh Getters and Setters right click go to Source generate the two string method done can I save it yes up save it now now we have to go to the API test and here the story takes a different turn login method requires the data in which format login data requires the data in which format string string format now I will be creating a Java object okay converting Java object into Json object is called as serialization okay for that which Library comes into picture your Jackson Jon all those libraries come into picture but I want to take things to a different level now over here if I ask you this is Java concept who is the parent of login request which class is the parent class for login request object object class object class first thing now for people who are not aware of this thing whenever you create a class now let's say you decide to create a class you see automatically there's a super class which is written java. lang. object um the other way I look at it is like my used to say if you don't give it to your if you don't don't give a parent to your class Java gives a implicit parent call object class Java gives a implicit parent call object class so object class is like a God God class okay so over here this particular class is going to play a very important role in a moment so what I'm am going to do is uh instead of passing this like this I will create a login request poo Okay uh that is a login request object so I'm going to say login request login request equal to new login request 2 3 2 34 okay and I will pass it off over here now log request L sorry login method what I'm passing over here login request login request pojo reference but this login method requires string value I'll say I'm going to come over here and I'm going to change it I'm going to say login request I'm going to go to the Post request and now change it to login request the issue is solved okay if I come back over here save it and if I try to run the program you will see something that is happening over here the test fails of course what did I expect can I pass just a normal pojo object and it's going to take care of it on its own but the answer is no because we have not serialized it okay so cannot serialize object because no Jason serializer found in class path please put Jackson gon Johnson Yassin whatever these libraries are like this library is not there so I'm going to go to the p. XML file my dear friends I'm going to scroll down okay and what we will do over here is if you go to the documentation uh yeah whenever you are working with Jackson there are going to be three libraries that you are supposed to use okay those three libraries those three libraries just give me one moment here uh those three libraries are going to be data bind core or did I miss something annotations this is something which is wrong over here I'll fix it off you need data bind core and annotation te Library okay so this is something that you need to add it off I'm just going to copy this go back to the pom.xml introduce this dependencies okay core and data bind I have added it off so if I going to click on the play button now just give me a moment but click on the play button now did it work so when you introduce the Jackson Library you don't have to write the script of converting it into your uh Java Json object okay you don't need to convert it into two string and two Json and put it off over there it can take it on its own is this part clear to everyone see the object provided those two dependencies were there is this part clear to everyone what I've done so far yes or no is this part clear to everyone are we on the same page so what has changed over here which is something which is interesting that you are not serializing it by yourself inbuilt rest assur is taking it for for you but you have introduced a major problem output R what can be the problem the problem is if I go to the login this is fine you are passing the login request okay the post request method which is should be a generalized method there is not one um end point which has post request right so I can I have to make forgot password so that forgot password I have to pass a a pojo which is just going to have email makes sense me no so the rule of java says whenever remember this like generally people don't talk about it like this so but remember it this is a rule over here did you create the object of login request my question is to you this did you create the object of login request script L request object yes or no yes this cannot be the parameter if you are going to create a method okay and you will be deciding to pass a class reference over here reference okay so if I'll will be creating an object of login request okay in this particular method I have to make sure that this method is Loosely coupled so that it's like a Lego piece tomorrow if you give me a different pojo I should be able to handle it you will pass the parent reference over here who is the parent of login request object so just change one word from login request to pojo and you make this particular method Loosely couple so tomorrow if I'll be calling the forgot password post request provided I'm giving the end point correctly that's it okay so this is what you need to do whenever you try to create a universal uh method it should handle it properly this is what you call as polymorphism and now you see I still don't have any compilation error it works okay but this method has become Loosely coupled now all right so I save it run it the output should not change life is good I need 20 30 minutes more over here guys did you understand the script so far what I have written okay look at the four lines is this four lines clear to everyone is this part clear to everyone perfect now the next thing that comes over here is if serialization is there deserialization will come into pitch I have to deserialize this response now so I have to create a model for the response I'm going to create a class in the com. API model. response and I'm going to call this particular class as login response login response okay private string uh token type is going to be string because type is storing beer what will be the type for ID what will be the data type of integer integer okay integer username string then we have email don't change the variable names whatever is a this key name given just use the same stuff roles is what roles is what AR Json AR what you can do is you can create a list of string you can create an array it doesn't really matter but I'll create a list of string and I'm going to say roles kah nothing that's it okay because it just has a value roles okay if it was having another Json object then I have to create a Json object uh model for that also okay we don't have that so I'm going to right click this is something which I've created right click Source generate the Constructor using the fields generate right click Source generate the two string method generate the two string uh method okay and I also need the Getters and Setter save it save it now let's go back to the login request 3 because it's time to Der serialize it off so over here over here if I want to deserialize it I can just say response dot as and over here you are supposed to pass the class reference response model login response so I'm going to say response of login response do class this CH is going to give me a login response object so over here this was the login request object we created a login request uh reference variable so now I'll be creating like what is the benefit of it that I can retrieve individual values I can say login request login response dot what do you want token get me the token let's click on the play button if life is good it should print the data but up and the reason for the failure is because it does not have a default Constructor I know that particular issue but the thing is you need to create a default Constructor so if I go back to the login response one more time just create a default Constructor what is a default Constructor a Constructor which does not have any parameter it's called as a default Constructor finish okay done can you see the token value which is getting printed this is the entire Json object deserialize and I'm printing get me the token I got the token if tomorrow you say that get me the username can I get it yes we have the get and sets individual values I can say login response login response. get me the what email system.out.print Ln what else you want login response dot get me the ID so email address ID token all these things will be printed Raj gmail.com is the email address three is the token can I test all these things yes assert do assert equals what do you want to test that take this chap put it off over here token token Co I think we can check whether it should be not null okay so I'm just going not equal to okay and then it is going to become true because it's an alpha numeric number right you can't really check on that stuff so the next thing that comes into picture is uh I want to check for email and email next is what id done bro finish okay first I printed it off you don't really want to print it but just want to show it okay uh sure the the thing that comes into picture is this as is a special method and the job of as method is it is going to convert the response body and map it into Java object okay and internally it is going to call your uh Jason utility or Jackson utility my bad okay okay so over here whatever is the response body that you will be getting okay it is going to convert that Jon object into Java object and it is going to return that Java object of that particular class Lo response response so if it's going to give me a l response Lan response refence reference variable right that's all clear yes how to make EnV file when we have different environment and base URLs why do I need a default Constructor uh that is the requirement of Jackson in your class only I showed you that part whenever you are working with Jackson it requires a default Constructor gon okay over here just to to explain this particular line just for your Simplicity response format it's coming in a Json format the purpose of as method is to convert your your Json object into the Java object of your type so over here what it is going to do is whatever the response which will come into picture okay I'm saying convert it into the Java object of login response so this entire line actually returns you this object right that's what is going to happen make sense would you please show the Au service class and serialization done I haven't uh done the serial okay I'll show you the class I'll just walk through the entire code but before that I'll just take one question which is there uh how to make EnV file when we have different environments and base URL uh I'll take that part later but but the same thing we have done it in the property files there's something called as Maven profiling I I got your question over here but the best way to handle it off is not via Java code but with Maven profiling so just to explain you in simple terms what Maven profiling gives you the functionality is I can create one profile for Dev environment one profile for QA environment one profile file for uat okay that is something you can do if you go to the tell it in for question over there I had created system properties when you're going to run your program M and run or okay and you're going to uh pass those things uh the parameters and all those things so that time I can pass the environment let's say I write over Dev so I have to create a structure in such a way I have to write the code in such way that it start picking up the dev property file in which you will have your respective base URL tell it C fourth fifth part okay that's where I've soled that particular stuff okay you'll find it over there if you want to go with that particular stuff profiling I'll keep it off over there could you please show the OD service class okay I'll I'll just go through the entire question one more time can I ask one question so if you have in one environment even for one environment my basl is a different different different Services has a difference base URL Bas URL uh different Services yeah just like I inan Telecom so so for the OS mean a provisioning API has a different base URL something like uh uh deactivation activation has a different URL so all Bas URL different sense see if you look at you have to focus it on the base layer itself in the Constructor I'm setting the base URI base U setting it off over here I can put it into the respective path and I will pass it to the request also make sense so when I'll be making the post request I will pass the end point also along with the base URL getting the point only the things which are common I have kept so if tomorrow you say that Baba no the base URI will be different for all the services let's say Au Services there I have user service also coming into picture so that time what I will do is I will try maybe overload this particular method for now and I can just say that I will be giving the base URL and the script Remains the Same request specification dot base URI pass base URI make sense and this particular base URI I will be creating it as a variable over here because tomorrow if I want to make any change I can take it from here are you getting the point yeah got it because see you if your class let's say if your service class have their respective data class as simple as that just to take this particular question a little bit over because it's a good question let's say I have different Services which are running on different IP addresses or different uh containers so over here let's say uh this works on something let's say as 13959 9196 this works on 6484 okay uh 7196 I don't know this is 192.168 9191 something like that this is au service this is uh user service uh this is uh going to be let's say UPI service something like that that's the reason base path basw was something which was responsive was common only to O service be end points there I created over there now if this information is also related to the OD service oh Baba it has to sit here only now I have to create it over here I cannot give it to the base service but what is common across all these Services he Baba you will be making the post request you will be making the get request you will be making the put and patch and S request B you will be getting the response back makes sense is this part making sense now so when you have those informations you can keep it in the respective classes okay and then pass it off over there I hope it I have answered it off now uh just to take thank you yes this is the entire documentation guys if if you if you don't have any questions you can leave it off uh leave for now pretty late for you guys um you can just go through this entire documentation what I've written over here so far for day two day one in tomorrow's class uh I'll just probably just focus on logging reporting and uh you know uh filters all those things which requires listeners and all uh running the test in parallel mode and something all those things I'll do it off all right so that's something that I'll be doing it in tomorrow's class if you guys are free you can follow the document and you can practice It Off by yourself okay see if you're able to do it okay whether you want to run a particular Suite whether you want to run it in the parallel mode whether you want to run a certain service that's the most important thing because if tomorrow I just want to run Au or user service I can just do that okay that's something that we have complete control on so uh that's the thing tomorrow can you take one flow like for 2 three apis that you have shown earlier 2 three apis yeah I'll do that part okay now of course you will not get it for the first time because unless you have written the code over here but the thing is step by step follow now uh the flow what we have built so far if I go back to the login request 3 guys I've have created the o service the OD service is going to have its respective base path and inside this base path is API forward SL okay so over here this is API for/ common everywhere so you have to make sure that this layer is there everywhere next thing inside the OD service I have this login method that is the login endpoint meod internally it calls the post request from the base service which is this chart over here there is no serialization happening no deserialization happening nothing is happening over here okay now over here request specification content type body payload the only change that I have made over here is my payload is of object type Whoever has asked this particular question is of object type why object type because I have a login request pojo class who is the parent of this particular class object so whenever you are passing parameter of a particular class just object that's the reason you know like you have those when you're doing inheritance you write something like this person P equal to new student okay because it is going to give you the flexibility of polymorphism coming into picture okay this is something that we always do so okay so over here the next thing that comes into picture is I have created the object of login request like why you did not write object over it doesn't matter for me because it's it's even if you put object over it will still work so over here um all service I'm doing login I'll be getting the response now now when we are passing or calling the login request I'm directly passing the login request reference it's directly getting passed now rest assured takes care of your serialization and deserialization internally could so for that you just need to make sure that your libraries Jackson or gson whatever you are using it should be added and kept is this part clear so data bind and core I have added it off so these two things which should be there the next thing that comes into picture over here is when I'll be getting the response back I will deserialize the response by calling the as method response I'll be getting it in the Json format I want to convert it into the object Java object of a certain class so all the request and response I kept it over here in the model section models. request consist of all the request payload and models. response consist of all your response payload response just for the management sake and then once I get the response this is just to show the pretty response okay once I deserialize it response. getet token is going to get me the token login response. getet email is going to get me the email of the response that is Raj gmail.com is getting printed over here right and then is three coming into picture that is ID is going to be three as simple as that okay so I want you guys to at least practice day one and come tomorrow else clear to everyone is this part clear to everyone yes try to write the code for the same okay whatever at least don't go and start writing your own code over there the first goal is whatever I have written write that part first by yourself okay up okay I'll have to first stop this meeting okay so the same solution will be uploaded uh in the LMS in the future in the LMS probably in the month of December or January or something like that this lecture I'll upload it in the zoom meeting and all okay in the zoom sections of the respective batches all right so other people can you can use it over there all right I'll discuss it in the in the LMS itself how to handle the SSL Sears and all we don't have that scenario right now right so if Sears and all those things comes into picture there's a you know like you have to have that connection like this is how you are supposed to pass it off and all those things I'll discuss that part later okay tired okay will you be able to explain these things practice it off but you make sure that you are able to answer it off for interview okay other people in the call is this part clear to everyone how many 60 70% Perfect all right so this is something like the reason I had to take this particular stuff guys right now is um as I've said like start you need to keep on applying for interviews and all right so this is just the end to endend solution just like how I've done it for T it you practice this part over here okay probably this lecture will take a a little bit time to come in a different better quality on the LMS and all probably on the LMS I'll solve all the services okay and those things but for you guys to get started what are the various components of your API automization framework and all those things it's more than enough because here you are able to explain this thing off one more thing like uh I'm not using a Macbook yet I'm windows0 days there's no hdle as such I I'll tell you what the only thing I don't know if most of the time I just tell people fake it though at least for certain interviews just so that you get that experience of giving the interviews now you start giving you know like you fake it off I'll be very honest solution you need okay even the reason is there's a lot of uh folks you know it's like uh Left Right coming into picture so 90 days you can say you're serving notice period I usually tell people tell them you're serving notice period you got an offer finish it off I I I to just I used to just say the same thing like tell the folks same himself and even if they ask you like show me the offer letter you're blun is supposed to say no Z they'll not take the interview as simple as that but at least the point that comes into picture is see these days uh when the market look look a little bit desperate and all those things but like there's too many people who are giving interviews and all you have your own stand K Baba this is my company Prof uh you know like this is professionalism that I cannot show the what do you call the offer letter and all unless you know like there's a tangible offer that I'm getting from you guys and first I'm not supposed to show it are you going to judge me on the salary offer that I'm getting or I'm I'm going to be judged on the knowledge that I'm having okay you have to say these things but I'm telling you this part yes Indian it Market is Indian what every it Market is like this only unless you know that this is what I deserve okay other people are not going to give it to you guys trust me on that personal life professional life this is going to be the same stuff Max to Max they'll only send this guy is taking you know like but I just just want to make sure that if I am giving the interview over there they should feel K Baba this person is always going to be an asset to the organization if he or she joins him okay so your major goal is to make sure that when you're giving the interviews you're you you know all the things in and out that's the reason build projects you sol this particular stuff you build it off show it off to them this is how like I can plan it off over there okay and always come like whenever you're answering any questions and interview you always say that this is the case study or this is a kind of scenario that you have faced in your office project as simple as that yeah yes yeah yeah recently got new job uhhuh and uh yeah I just went to the same process like I used to tell H that I'm serving notice I have offer and like the same thing I followed and first I took offer from TCS and then I resigned and after that like I kept telling the HR that I have only one month notice period so like interviews were lined up because of that and ultimately I had like many offers in hand that's only joined recently which company you joined recently now H works sorry thought works okay thought thought works yeah oh okay okay thought works good good okay someon I don't know VW work popped up into my thought okay that's nice yeah all life is good over there on side cut right but I this is one benefit I like to sorry just to cut people off over here just remember one thing guys you know like people hate me for saying that part but keep on changing the job after one year unless you are doing that that part there is no way you know you will you will reach the level you want over there some people like I want to stay in a company for two three years nothing inflation is rising bro so so make sure even if they say that the hike is going to be good or something like that unless this is this is this is the thing which I tell to most of the folks unless they're telling you guys to that you are going onsite or you know like um you are getting a better increment or something 50% to minimum salary right so it doesn't make sense to stay over there yeah what are you saying SW yeah actually and they have like that's why I asked like I saw you you open Notes uh in between of the class so I thought you are also using MacBook so they have given MacBook and I I'm not able to use it at all so this is just the notion app so you can like just the place where I've kept the notes for you guys okay okay any other questions guys uh do share me the question swap whatever they have asked you just WhatsApp me those things okay and do we need to create account on the swift. with Swift yeah you can do that part there's nothing as such like you can use your own credentials previously in Phoenix I used to give the credentials over here you can create your own account okay you can handle those things off by yourself okay that's something that you can take care yeah okay any other questions guys Monica did I gave you the end to end solution for the API I thought you you did not join today yeah yes it is very useful so I'll you have to practice the to tomorrow I'll give the project to you guys I'll tell the folks to you know like create a one shot big lecture only and give it to you guys so you can use it over there okay so make sure you guys you practice this particular stuff whatever we have built over there that's the only thing I can see on this I can just build it once and I can show it over there but the point is um tomorrow's class I will wrap up with the user management system change password profile and all those things okay the different HTTP verbs so all these methods will be created in the base service layer I'll create the user management okay and um I think looking at what we need to do I need one more lecture probably on next Saturday I'll update you on that part guarante I Because unless I don't want to push it off to the next level so we'll stop over here for today guys uh this lecture I'll put it in most of all the batches okay and I'll tell these guys to create one combined lecture and it will be there in the salpas section please you have the notes okay so try to practice it off tomorrow okay so that's something that you guys can do it at your end all right okay paru long time no see all good okay uh J uh Have you shared the uh Have you shared this Swagger link sorry I missed that there's the first link in the document if you go up all the way up yeah yeah right yeah okay yeah thank you take care bye-bye all right guys take care thank you so much good night take care bye-bye the today's class this is going to be the second part uh I wanted to complete the entire framework for today but then there was a request that they wanted um end to end flow so what I'm going to do for today is I'll write the test scripts little bit test scripts I'll write it off for you guys uh for one flow so you understand how it's going to work the listener And all I'll try to implement it in the next class okay so next Saturday also there will be a session the link will be SE okay so that's the only thing that I wanted to give a quick update on uh yeah yes message delete else what happens is people will think the class did not start okay oh sorry okay so let me just um share the screen let me know if you're able to see the screen right now okay I'm I'll probably be using this particular document itself uh Theory I think so you guys can read it off over there there's nothing fancy about that stuff not something major I have added it off uh we were able to complete yesterday only tell authorization service and all uh day two uh day two yeah day two I've just changed it off the thing which was required for day three I moved it at the end now so I'll just focus over here I'll parall be updating this particular documentation there's some spelling mistake which I need to fix I'll do those things now this is the flow of the application just the state diagram that I've given over here first the user logs in into the application that is it is he or she is going to be using the authentication Service so let's say the user decides K Baba I will be doing login so he or she is going to use the login API once he or like once they use the login API they will be logged in into the application and from there they can go to the profile management they can change the password they can get the profile details they can update the profile details you know so on and so forth similarly authentication Service has different option if I'm trying to sign up into the application let's say my account gets created I'll again use the sign up and the moment I sign up I will be able to log into the application and then I'll be able to use the profile file management service if I'm saying forgot password what happens in forgot password I will be using the forgot password API it is going to send a email uh to your inbox and from there I have to reset I have to click on the link and it will reset the password generally that what that's what happens for security purpose so when you look at authentication Service there are 1 2 3 four four ENT points or four uh actions or operations that can be done okay and when you look at project profile management you can delete the account you can update the details okay one API name got deleted over here this is going to be uh modifications that you can use in your account so for example let's say if I decide to go to this particular application um yeah my voice is breaking we'll fix it right away I start started the just minute I started the extension but I did not connect to it it should not break now all good yes is my voice breaking now no as of now good oh good that's all right cool so over here let's say uh this is the logged in user if I try to click on sign in I forgot my password I think I updated the password 1 2 3 4 five 1 2 3 4 five bad credentials anyways um I'll just reset the password in front front of you guys so this is a normal scenario I forgot my password so uh technically I will be going to the forgot password option where I need to give my email address please be on mute yeah so over here um over here I have to give the email address for this particular account I did change the email address so let's say if I go to this particular account and I go to Gmail uh let's select this particular account okay I am going to enter the email ID over here and I'm going to click on send instructions now if I'm not wrong there is a link which is there yeah you see an error message popping up into picture now over here the reason I'm getting this error message because there is already a link which is sent to my account at 908 okay that please use this particular link to update the password so I'm going to just click on this link and I'm going to give the new password over here so let's say the new password is going to be uh temp 1 2 3 4 let's keep it udai only UD 1 2 3 4 UD 1 2 3 4 let's click on reset the password the password has been updated okay so this is one of the flow let's say if the user was has forgotten the password he is just going to go to the forgot password option I'll just take away this option of muting yourself mute all and uh perfect okay you you won't be able to unmute yourself just put the questions in the chat box so over here guys um now that my account password has been updated it okay if I try to enter this thing UD 1 2 3 4 I should be able to log in into the application is this part clear to everyone nothing fancy just the normal flow how you do it off all the time that you're you forgot the password you click on the forgot password and then the email was sent to the user account and from there you have updated the password all right this is something normal we do all the time now over here once the user logs in you see I did a forgot password my password was updated I came back over here I did a sign in and now I am in the dashboard page so when I go to this particular dashboard page right now what you'll observe there are multiple Services each tab over here is a different service okay so out of this thing my major focus is on profile so when I go to profile I can do a lot of things over here that is I can update the username okay I can update my email address so the email address right now is this I can update my mobile number as well as I can update or change my um address okay along with that uh there are few other apis which are not being shown on the UI like if I want to delete my account I cannot delete it from here but I have created a service I have created an endo in the user management where the user can be deleted is this part clear to everyone so you can change the password okay so if I go to change password this is this is the one which comes into picture this change password I can give a I have to enter my current password and I will be able I just can give a new password over here okay so this is the change password API that we we have then you can get the profile details so if I go to the profile section name email mobile number address whatever it is these are the things which are coming because of the get profile details make sense to everyone put profile I want to edit the profile edit Click mobile number change I give a different number over here let's say 9869 237 627 and I click on Save the changes the profile details are getting updated okay I can change the name if I'm required so all these things this is the profile user Management Service which is there clear to everyone is this part clear to everyone what are the things which are there okay apart from that I probably want to create an account let's yesterday people were telling meem don't have an account sign up okay so click over here you can create an account so when I'm trying to enter username email address password confirm password okay and I enter my personal details then in your authentication your sign up API will be called because sign up API requires all these things username password email first name last name mobile number is this part clear to everyone section you create or you use this sign up API coming into picture now it totally depends on the flow of the application what do you want like what kind of a service you are trying to create so let's say my manager says Baba or let's say there is a requirement he you need to check the complete authentication Service we'll go step by step rather than see when you're testing apis now end to end flow SE okay so if I want to go to that particular State diagram that I want something all these things to come into picture you just make sure that you have everything about authentication Service tested so individually I can check whether the authentication is working correctly or not are you getting the point then I will have another uh section for profile Management Service so all the apis which are going to related to profile management I'll be testing that and then I will be connecting them together makes sense to everyone simple because then I can just create uh objects and I just need to call those methods is this part clear so what we will do first is we will go back to the application uh that we have created over here and uh step by step we'll start it off don't look over here this is something which I was trying it off for today let's close all the tabs close all and we were having this demo API automation framework if I go to this SRC test yesterday we created the O service of a service May there are few things that we have done a service extends the base service if I ask you what is the purpose of Base Service Base Service is just a wrapper over rest assured so all your rest assured methods are popping up over here and that is something that I can use it off now uh whether I want to make post request whether I want to make your put request your get request for upes I will be taking care it over here only as simple as that okay now yesterday someone had asked me that okay the base URL is something if it's going to be different how I'm going to do it off but let's just focus on this particular application so given in the Constructor only I'm just going to say set the base URI and I can just give the base URL whatever is the URL of the app application so I don't want to use this particular method I have just overloaded it if you want you can use it off but I won't be using this um now I will not come to the base service class unless there is a requirement because if I go to the um Swagger UI the authentication only takes care of post there's only post HTTP Verve so I have already taken care of for post as simple as that so I will not modify the base service unless there is going to be a get put delete HTTP verbs popping up into picture is this part clear to everyone when there is a requirement for making a different API request that time you will be making changes in the base service class is this part clear can I go ahead okay yes no perfect now what what we need to do in this scenario what we need to do in this scenario over here is we are going to go to the O service and in authentication Service yesterday we introduced login but now I want to go for something else I want to go for let's say sign up this is the thing which I want to test as simple as that check he signup API is working correctly or not so what I need to do we'll go step by step the first thing is over here in the login sorry in the OD service I will create a method and I will call this particular method as sign up because that is the name of the endpoint sign up endpoint right now the payload of sign up if you look at the payload of sign up that is sign sign up request payload the username is there password is there email is there first name is there last name is there mobile number is there so what I need to do for this chap I need to create a what model right we need to create a model over here so how we can create it off just copy this thing okay I'm going to go back to your framework we have to go to the com. API model. request because we are handling the request right now and over here I will be creating a new new model for the request and I'm going to call this as sign up request okay up this is what I want to introduce quickly we'll create a pojo class out of it control F okay find me a double code replace it with nothing replace all find me a colon uh replace it with a semicolon replace all okay once you get comfortable with all these things now you can use your chat GPT and all those things I generally don't like to use it in the class s you need to understand how and why you are creating it first because then um in coming years it's just going to be copy paste copy paste and you just need to make sure that these things gets created quickly all right so now what I want to do is I want to make sure that these are going to be instance variable and when I'm saying that this is going to be instance variable they will be marked as nonstatic that is static keyword will not be there and it is going to be this okay so I'm going to copy this chap paste it over here here here here now what do I want in life I want to create this as a hjo class so I'm just going to right click go to say and generate a Constructor using the fields right click go to Source generate Getters and Setters select all generate right click Source generate the two string method is there anything that you did not understand what I've done over here why did I create sign up request is this part clear to everyone over here yes okay everyone is the same thing the story Remains the Same change story okay I created the same story in the Ted when we wanted to create pojo classes I created it over here but today let's do something different also I want to introduce something which is called as a builder design pattern in this scenario now over here if you look carefully parameters username password email first name last name mobile number and if You observe sometimes when I'm creating the object I forget what was the parameter one what was the parameter to I make mistakes right and it happens with you also because then you think start thinking username username was coming as first field second field third field are you getting the point this is a very known issue that is happens with everyone because if you are giving a lot of parameters to your Constructor you will always forget Baba username position 1 2 3 4 right so this problem can easily be solved using a design pattern which is called as a builder design pattern okay now Builder design pattern basically is a a special way of creating a class and this particular class basically helps you to make sure that you are able to assign the values in any order but I can pass mobile number first then I can pass email second then I can pass name third so on and so forth something that we have done during the initial uh stage of the script this given base URI dohe header body so and so forth so this is basically your Builder design pattern and this is something that I want to implement into my automation framework okay this is just for the practice purpose so that you know like if in interview they ask you the question uh tell me the different design patterns that you have created in your automation framework I know you will be able to talk about page object you will be able to talk about Factory design pattern you I hope you will be able to talk about service design pattern that we have seen so far and the most important thing over here I hope you will be able to now talk about the fact uh your uh build build a design pattern also just give me a moment over here now over here when you're are looking at creating the Builder design pattern Builder design pattern basically is actually inner class I don't know if you remember what exactly inner classes in Java okay we'll talk about inner classes over here a class inside a class is basically what you call as inner class can I have a class in inside another class the answer is yes this is my class called sign up request class class B okay and that class is apparently going to become my inner class now there is a rule about inner class which classes in Java can be inner class static class so the next question that comes into picture Jan can you make a class as static the answer is yes we can make a class as static and in which scenario you will be making the class as static the answer is in front of you Builder design pattern when I want to implement Builder design pattern I created a class inside a class yes or no and this class is static in nature first rule inst Vari copy all the instance variable put it inside this particular class is this part clear to everyone what I've done so far I created a class and inside this particular class I created another class which is static in nature and this particular class has all the instance variable whatever is there over here okay class Constructor this particular class builder class is not going to have Constructor inside it then what is will be there what will be there just the methods I'm going to create a meod in front of you public void I'll say username public void username you are going to give the username and then I'm going to say this do username equal to username have you seen this script anywhere when you write this. username equal to username this is your seter this is your Setter yes or no yes no set not get set because you setting the value Builder design pattern does not have any return type uh does not use void as a return type I always said void is not never a good return type so over here once I will set this thing once I will set this thing I'm going to return the current object is class be current object the the the programmer is using I will be returning that now how do I get the current object of the class how do I get the current object of the class plus this keyword that was the thing which I uploaded a couple of days back this keyword this is going to return me the current object for you guys I'll write it in a little bit different step this means current object object means new Builder I'll writing it in front of you like this if I'm going to create a builder object and X is going to be my reference variable what will be the data type of X what will be the data type of X you will say Builder because of current object return you creating an object of Builder and X is going to be the reference f variable I say return x what will be the return type of this method now what this method is going to return me what will be the return type of this method now Builder data type of X will be the return type is this part clear to everyone what I've written over here yes no everyone can I go ahead but when I when I wrote over your new Builder up current object you said Java go and create a new object it is not talking about the current object you said go and create a new object what happens when you write new Builder class will be loaded into the memory instance variable will be created Constructor will be called I don't want to create an object I want the current object to be there so this basically gives me the current object I can either it like this it will still work or what I can do is I am going to create another way okay I'm just going to say password you will give me the password password either either and instead of writing all these things I will just say return this finish makes sense to everyone choice is yours start slow but then pick up to the next mode what exactly this line technically signifies is this part clear to everyone now what I've written yes no perfect both the two methods username and password method is clear to everyone technically it is the setter only set password password okay I've just written this now what we will do is I will take this to 3 4 now just take email username and password word is done email email email email this is my set email method okay first name first name first name first name first name then last name method last name last name last name last name done mobile number is left take this okay paste it I'm going to say mobile number okay mobile number mobile number oops mobile number Mobile number is this part created to everyone what I've done so far I created a builder class which has the same instance variable which is there in your sign up request class builder design pattern Builder class so take the sign up request whatever the instance variable are there take that put that in the inner class okay the static class and for each instance variable I have the respective methods okay it is going to set that instance variable and return the current object clear to everyone clear to everyone is the job done over here the answer is no once everything is done I will be creating a method called as build and what build is going to do observe it is going to create the object of sign up request done now what did I say about Builder design pattern in Builder design pattern the methods will always return something methods will always return something so over here in the build method also I will be returning the sign up request object so this is what is going to be there okay done so I created a class the this is just a pojo class but it also implements Builder design pattern every time he build something new so the benefit that you are getting when you write something like this is uh let's say this is use account creation test okay and and let's take this particular method only as a reference copy this public void create account test okay over here what we want is just give me a moment over here what we want is I want to create an account so if I want to create an account payLo of course I can just call the service okay service all service equal to new OD service okay and I can say OD service. create account if that method is there sign up okay but the thing is the payload that I have to give is going to be of sign up request yes or no sign up request payLo so I need to create the sign up uh pojo object okay so one thing I can do is I can write something like this okay or pass so right now I was having username password email first name last name mobile number but if your payload is going to be big let's say you have 30 40 fields which are there 30 40 10 15 fields which are there the Constructor is going to look very complicated over there so what we do in this kind of scenario we use Builder sign up request sign up request has a class inside it h enough sign up request has a class inside it yes or no sign up request class yes no what is the nature of that class it is a normal class or it is a static class static class so if you have a static variable do you create an object to access that variable no we just need the class name if I am going to have a static method do I need to create an object no class name is enough so the same way if a class is having another class inside it and that class by de friends and that class my dear friends is actually a static class I can just say sign up do Builder sign up dot Builder dot dot what do you want I want to set the username okay I want to use the username first so I can just say dot username why it's giving me user name like this just a moment yeah it should be the object over here my bad now it will pop up username new signup request. Builder do Builder I will set the username first usern I'm going to say this okay usern return what does username returns me what does username returns me Builder it returns you Builder now the return type of username method is what Builder it returns you the current object is he current object see current object I'm just going to say dot I want to attach let's say email what is your email address disha atate yahoo. to this particular current object I want to attach first name okay I'll say thisa let's say the username I give a different number 1 2 3 to the current object that we have first name also returns me Builder I can say attach password I'll put it off over there say say thisa 1 2 3 4 or 1 2 3 this also I'm going to keep it simple for my for me then I'm going to say dot this uh dot last name okay I'll say but dot mobile number 777777 7 1 2 3 4 what's the number 1 2 3 4 5 okay for safety and once you have used all the instance variable like you have done the setting what is the last method that I'm supposed to call what will be the last method method use method which is that method the build method now what does build method returns you build method returns me the sign up request it is going to internally create that object of sign up request okay and this entire stuff will create it like this finish this is your Builder design pattern o is this part clear to everyone simple is this part clear to everyone in interview they can ask the question what is the benefit of this benefit is are you getting the point you could have done it with the Constructor but the thing with the Constructor you have to remember the parameter what whatever works for you then I have to remember the parameters but as I've said if you're going to have multiple parameters if you're going to have a lot of parameters 10 15 your Constructor length is going to be pretty big Mak sense this becomes easy for you to read it username is thisha email is this first name is this password is this last name is this mobile number is this and then you say build and give me the object of sign up request okay and then attach it off over here okay everyone can I get an input from you guys yes no then you're done what does sign up request returns you guys sign up request returns be your response and this is where my response comes out to picture and I will say sis out response I have to check what would work what will not work but it fails API authentication log that's the Endo mistake I made path is API o login so over here let's go to sign up and we need to fix this path okay that is just uh you know like my silly mistakes that I always make all the time I'm just going to copy this it's uh just change it over here life is good okay it's just going to be sign up okay copy paste it and uh I can run this part and if I hope it works now okay what do you see the message over here user registered successfully you want to write the test all you will need to say is assert do assert equals response do as pretty string you will be like Artin you did not create an object for you know like a pojo object for this I don't need to create an object for this and the reason for that uh guys is because this is a normal string that I'm getting back in response I'm getting a on line description back normal text message okay simple text so that's the reason it's a simple string which is printed and I'm just checking the string values they are equal or not is this part clear is this part clear to everyone if I save it up test pass so you don't need object creation for this test works completely fine okay so if you start observing the benefit that I'm getting with the design design patterns and the structure that we have created I not using rest assur anymore did I go to the base service class and I did I did I make any kind of a modification over there no service I introduced this method my job is done just change the sign up to payload whatever the payload I need to pass base path I already know I just gave the end point and even if I am trying to write your test this is pure Java nothing else do you see any for Loop do you see any conditional statement ni see the object B pass okay created the object called the method got the data done my job is done make sense is this part making sense to everyone so this becomes better in terms of Maintenance what people were writing before what M so maintenance is pretty high in this scenarios but over here like in all these things maintenance is pretty high but what we have written over is pretty simple tomorrow you say check the status code simple just go over here change it to response do status code what do you want 200 just change this to 200 and we are done save it run it output is still the same I did not understand the function of Builder method the request. Builder is basically if I have to create if you look carefully this is a static class right so if I have to access the static class I have to access it like this getting the point OBC sign up new request is equal to new sign up request you have to first create the object from that stuff I am trying to access the Builder object and then for that Builder object I'll keep on passing username email first name okay password last name any order whatever you want okay sorry I forgot did you pass the authorization token somewhere why would you pass an authorization token by account do you need an authorization token before you create an account or what you need authorization token when you try to access the services after you have logged in this is sign up account creation make sense everyone account creation okay other people make sense to everyone now uh I'll go with uh another flow just a simple one I'll go for forgot password now the reason I'm taking this forgot password is just so that you can understand another way of passing the data or P data pass to your your request body I'll show you another way now look at this particular stuff and you guys start telling me I'll take this one very slowly I have been given to test this API call forward password where should I make start making changes should I make change in the base URI sorry Base Service is there anything that I need to change in the base service post request is there okay I have already created a method for handling the post request so nothing needs to be changed in the base service authentication Service May there is a new method new API coming into picture forgot password so I can know that I have to create a new method in the OD service class now I can see that it requires a payload a payload this is just a one field yes or no there is only one field inside this particular payload so I can create a class but should I create the classi I you can create it off but we'll go with a short solution for this if you want Baba your payload is only going to have one key okay you don't really need to create a class you can go for a different approach in this scenario so what we will do is we'll go to the O service and we will introduce a new method as usual because that's what we want all the methods in the all service will always return response because API calls okay so response will come into picture and the name of that API I will what is this forgot okay password forgot password Emil to you will be giving me directly the email address for the first time I am not passing any pojo I say give me the email address directly email address why I'll explain you I have to make the post request so this is what I will be passing over here in a moment but in a different way now before I do that I'll take this forgot password endpoint and I'll put it over here up the magic is going to happen K Baba you will be giving me the email address in double quotes disab B1 123 at the yahoo.com all those will come over there but I need to create a payload so we go with a different solution over here we will create a key value we will create a key value in a in Java ecosystem is there a data structure that can handle key value maps map is a data structure that can handle key value values key value pair of data so I'm going to create a hashmap in which key will be string and value will be string and I'm going to call this chap as payload there go and I'm going to say equal to new hashmap hashmap is a class which takes key value kind of a data that reference is called as payload and I've created an object of hashmap I'm just going to say payload do put put is the method not HTTP we if I have to put something in the hashmap I have to use put method I'm just going to say email because the key is email and value is what you will give me kutam finish okay this is what I've introduced over here test forgot password test I need to test the forgot password you guys know it we know it it belongs to OD service service object service service is equal to new OD service all service. forgot password give me the email address now I'll take the email address which I have this one okay so going to copy this email address paste it over here okay forgot password returns you response store it inside the response variable and I'm going to say system.out.println response. as D string save it run it let's see if it works message if your email exist in a system you will receive the instructions password request for 1024 at my end this is the link is this part clear to everyone what do you understood over here like Baba if there is going to be only one field a field field just email I need to put over there don't go and start creating your page class or sorry pojo class model I can easily handle it off with my hashmap in this kind of a scenario is this part clear is this part clear yep and if You observe carefully I have taken care of login request sign up request forgot password all the three apis I have taken into the odd service class this is how your OD service class looks a here now uh I don't know what exactly this reset password comes into picture how reset password work I I forgot on that part I'll check this part how it works but you really don't need to use like if you understood it's going to be there like how what was the flow of this one I forgot I think the reset password is uh ahhhh now I remember what is this reset password my bad so the thing is uh reset password is this one link so this token which you see token 201125 AE hyen A2 B7 and all if I click on this this token will be given over here and you have to give the new password and confirm password and if you click on reset password it will be updating the password make sense so token will be over here so this is a different flow because then there are lot of things that comes into picture I have to read the inbox inbox token I have to attach it to the payload all those things so I'll keep it in a different lecture okay it will be kept over there on the LMS but this is something which you can say as a challenge in your automation framework that link was going over here and there and then you had to uh take the token expiry of the token and all those things okay also one more important thinga if the reset password link has been sent you cannot again say reset password make sense so if I go over here to my test and I say run this particular stuff now it is going to fail because link okay it is not going to work you have to use that link first update the password getting the point else a new link is not going to be generated and given is this part clear to everyone so please make sure you remember this particular point because else when you will be testing you'll say link because you you already have a link you solve that link first okay now this is all about the OD service that we had now I want to go to the user Management Service let's say the new requirement is user management fix AP uh I'll go with the get profile first because uh put may obviously we have to change password I don't want to change password at this particular moment so over here API sluser SL profile now what all things are changing over here is the base URI changing sorry base path changing first I was on API o now the base path has become users there's a change in the path yes no there's a change in the path yes next I have to make a get request is the HTTP verb different the answer is yes so I have to make two changes first I have to make the change in the base disservice because get request so since get request is coming into picture I have to make change in the base service and since the base path is changing you have to create a new class now yeah authentication Service make sense to everyone everyone right so what you will do is in your service let's start with the Base Service uh I'll minimize it off and I will be creating a new method which is going to be called as get request in life now get request is the most simplest one why because get request pay so I don't need this I don't need content type get request is going to be directly getting the data so you have to do this is this part clear done I made the change over here is this part clear what I done over here now I need to introduce the new service layer which I'm going to call this as user profile Management Service it is a service this service is going to extend Base Service clear next what I'm going to do I'm going to create a base path private string okay uh base underscore path equal to thing is clear to everyone base user is constant so this is going to become final if something is final it will be static any concerns so far same thing whatever we have seen pure Java nothing fancy over and here we have encountered the first uh or the second API that is get one I want to focus right now so get is going to give me get profile right so I'm going to create a method over here called public void get profile okay and how do I get profile I have to call the get request internally and I have to give the end point clear to everyone done get request returns me what response whoever was asking me authorization token so first I will be creating a class now I want to check get profile request test okay get BR should come thanks I keep on forgetting I'll fix it all but the problem is I keep on forgetting all these things thank you okay so Bas path plus forward SL profile this is something that I put it off over here and uh now what I need to do is I need to go to the get profile request test over here as usual you're going to introduce your test NG okay I'm not putting the description and all you know you have to put it off I'm just going to say get profile info Test Now how do I get the get profile info understand this part either back back sorry okay in order to get the profile information first thing the user needs to do is login into the application then I have to go to profile option profile information yes or no so are you getting the flow the flow is login into the application from login if the credentials are correct then I can go and use the profile service make sense to everyone there is a flow that comes over here the user authentication user profile service access okay and obviously the reason is authorization token will be coming into picture so over here if I go over here and let's say I try to access this thing let's say I say try it out I click on execute it's not going to work it's going to say unauthorized full authentication Services required so in order to make this API call I need to pass the authorization token token who creates the token for us the Au service so over here my guys even though I want to use the user manage agement service and thing for token is OD service is responsible so I'm going to say OD service OD service equal to new OD service and from this OD service I will be using the login request and technically you will be just passing the payload of ud's credentials udai 1 234 okay and here also udai 1 2 3 4 what does your login method is going to return me what does login method returns me response to is response L observe this response L then I will deserialize it response. as have I created a payload for the login response API models respon respon what does this return me guys response. as login response what it is going to return me log response login response come so I have to just create a login reference over here now this is where your D serialization comes into picture which takes things to the next level okay login response dot have we created gets yes get do you see a method called get token anywhere yep the third method token value so if I run it if my credentials are right I'm able to see the authorization token coming into picture which I need for the user service token copy and I go to this uh user profile service and you see this lock I click over here I give the bearer token over here click on authorize okay let's click close And click on execute now you're going to get the response so over here if I have to pass the authorization token I have to have this header hyphen Edge which means I have to have this header tell me something who is responsible for creating the API request in my framework which class is responsible for that authentication Service user profile service or Base Service who is responsible for creating the API request on getting me the response who can get that stuff for me who can get the stuff for me the base service is responsible perfect base service is responsible so whose job is to set the authorization token for me Base Service so over here I will introduce a new method in my base service class and the job of this method job of this particular method will be to set authorization token for us so I'm going to say it's going to just give me void set o token okay I will be getting the token I like I'll be giving the token and to the request specification dot dot header okay I can pass the header see header the first is I need to give authorization token take this then Bearer word needs to be return okay be space you have to observe carefully be space colon is basically the first key this is the key this is the value so Bearer is the word and then to this Bearer word I need to attach the token I need to attach the token okay now I have introduced this method and the job of this method is to just attach the authentication token for this particular request story because I need to pass the authorization token I have to go to the user profile and whenever you decide K Baba I will be making this get request and all those things you have to make sure that you pass the authorization token over here so I will be giving the token to this method Dam method code token and it is going to internally call the set token method for us so in order to get the profile authorization token will be set and then the request will be made and I will be returning the response back so since I've introduced this change now if I go back to to my test which I have not called it so far I have the token with me all I need to do is I'm going to say user profile Management Service do get me the profile I'm giving you the login request token and it is going to return me the response okay you can use the same variable because because we don't need to use it we are not doing any kind of an updation over there internally so we can use this part and I can just say system.out.print Ln response a are you able to see the data ID is three username is udai email is this first name is rajaj last name is Kumar make sense to everyone make sense to everyone yes no now over here the response which I'm getting back is in Json format maybe for assertions I want to deserialize it so what you're going to do do you're going to create a what a response model so go to this response model you create a class and I'm going to call this class as uh user profile response okay paste it you know what to do crl F control F okay find me a double code replace it with nothing find me a colon replace it with semicolon okay this is a contrl f find me a double code replace it with nothing yeah done this is three okay this is string I don't know it did not change it control F find me a colon replace it with semicolon done done you know you have to create a pojo class out of it I've done this chap now right click Source generate the Constructor using the fields right click Source generate the two two string method let's generate gets and Setters first okay and then all I need to do is instead of doing response. ask pretty string I can just say response. as which class get profile user profile sorry now if you see carefully everything is kind of similar I'm just repeating the same operations again and again confidence it's the same thing I'm doing I'm not doing anything fancy or anything new once you understand system okay I'm just printing the username so if I'm not wrong UD 1 2 3 4 should be printed on my console uh ah Jackson Jackson binding so so over here you have to just make sure that you have a default Constructor done yeah UD 1 2 3 4 is this part clear to everyone what I've done so far yep everyone in the people in the call all good yes no right how did I resolve the last error last error is because of this last time also I had this error if you look carefully it's written cannot construct instance of response profile projo no Creator like default Constructor exist so it's telling me that there is no default Constructor in user profile response so I have to create that Constructor that was the issue okay that's finish how long the token is valid and can we create entry to request token as and when required and pass it to the other request and that's the problem we have solved it with the authentication uh service Tok token okay token I feel is uh it's valid for a long time I believe it's valid for 24 hours or something but the thing is whenever you want you can create it that's as simple as that call token okay 2 for us yeah and one more thing that you can do over here is you can just create a service out of it you can create a utility method called get token or method call okay inside lines call make sense you can create a utility method just call the Au service get authorization token and internally you call this method so whenever you want you call that method okay is this part clear what I've done over here so this is the first API call where I am doing the authentication second one where I am getting the user details now probably we have three or I don't know how many Base Service we have we have post get put uh post get and uh set is there authorization token which is there I'll just take one more for now and then we can stop this one I'll take a very simple one I'm not going to do the delete one account delete so I'll go with the update so over here I can update the uh what update the personal information okay so this is the pojo for that I believe we have that pojo hope so uh no we don't have it but we can quickly create one I'll create it in the Builder format also so that it's going to be a quick revision for that so I'm going to create a class and I'm going to call this particular class as uh profile request pojo okay profile request okay and over here it will be private string clear to everyone next I need to remove these chaps next I need to remove these double codes and all next I need to remove this colon and put semicolon again once you get comfortable with these things now see the like for practice purpose and all you are doing fine great but later on you just give it to GPT and all it's so I'm going to right click go to Constructor paste it off right right click Source generate the Getters and Setters right click Source generate the two string method done do you want to create a builder for this let's create a builder for this last one we'll quickly do the last Builder creation though this particular class does not require a builder creation varable but still if you want you can create it off for practice um what do you mean by Builder design pattern Builder design pattern is going to be accomplished with the of which classes in Java inner classes in Java so what I'm going to do is I'm going to create a inner class what is the special about inner class a class which is there inside another class is called as inner class inner class are which what in nature static in nature so static Builder is this part clear to everyone yes or no fer okay quick quick this is something that we have now whatever the instance variable which are there in the profile request UT or chip finish then what you going to do you are going to create individual methods for now public void first name first name is actually a method which is going to just do the job of the setter for me okay so I'm going to pass the first name to this chap and it is a Setter so this is the code of exactly the setter that you create and what exactly this method needs to return me the current object of the Builder class return this or is return this to what will be the return type of this first name method Builder katam KH finish copy this 2 3 4 take the last name put everywhere last name last name last name last name done next email copy this email email email email next one mobile number take this put it here put it here put it here put it here next one more thing is remaining what is the Builder class ready no we have to create one more method which is called as the build method or whatever you want to call it let's say build and the job of the build method it is going to create the object of outer class so over here I'm just going to say profile request profile request equal to new profile request and just keep everything as it is because the names were given in such a way Baba it is only going to pick up the instance variable and I'm going to say return profile request if I'm returning profile request what will be the return type of this method the reference of parent uh sorry the reference of outer class finish life is good done you have created this Builder class okay I just created it for your practice apart from that there's no need for me to create this chap all right so done now let's create a method over here and I'm going to call this particular method as update profile test that's what we want to do let's go over here let's remove all these things we'll do it from scratch now I want to test uh the update request what type of HTTP verb is this put do I have a put request in my base service base service request no API API for/ user is the path so over here which uh class will be updated over here profile service class okay so I have to make two two changes over there that's the maximum I need to do I will be going to the base service first let's go to the base service and um nothing fancy just copy this uh post request only is put though because in post put okay you generally pass payload okay so that will be there only the end point will change over here to put backy sub same okay now in the user Management Service uh I will create a method now I don't want to call it get profile I'll put call it update profile because it is a put operation so update profile and of course if I want to update the profile now if I log out close even if I want to try out let's say I click on try out and I click on execute because in order to update the profile authorization token needs to be there okay so over here set authentication token will happen into picture you have to pass the token and you have to give me the payload okay object payload or what what was the payload over here we have created uh user profile no I created a payload over here now profile request payLo okay and I'm not going to make a get request it is going to be put uh put request so I'm going to say put request you have to first give the payload then this chat finish finish then go back to your update profile test update profile in order to update the profile first I need to log observe carefully log out once I log in into the application authorization token will be created then I need to go to profile option then I need to click on edit to authorization token is activated it's already there so I can start making the changes over here and the same flow will happen here also first I have to call the Au service equal to equal to new Au service then I'm going to say Au service. login and I can give the payload uh UD 1 23 4 UD 2 3 4 this entire thing returns me what response are you there with me or left by all good response response okay now I'm going to say response do as we will deserialize the response to login response dot class okay now this will return me an object of login response the login response login response and then then we got the authorization token as simple as that user profile service so user profile Management Service user Management Service equal to new user Management Service okay I'll say user management profile service. get me the profile in order to get the profile I need to pass the token to l respon login response. get me the token so it is going to give me the response I can use the same response variable next let's do one more thing let's keep on printing the response also so I'm going to say response. as pretty string for this chat and take this put it over here for better readability this is where my first request will end I will see the response this is where my second request will be made I can see the response and then I will D serialize the response if you wish you can do that part okay I can just say system.out.println sorry response. as user profil response. class okay user profile response I don't know user profile response and uh probably I can just introduce some kind of an assertion assert dot assert equals user profile response do get me the uh first name not enough the first name get me the username and username needs to be udai 1234 right because username you're doing it for login next this part is done this is the second API request which I made now let's go to the third one third one I don't have to create an object because me user profile service access so user profile service is already there token is already set use user profile service do uh update profile okay update the profile I can pass the authorization token in this kind of a scenario login response. getet me uh sorry login response doget token get token and I need to pass profile request payload Builder I I have to create the payload I'm going to say profile request profile request equal to new profile request dot Builder dot whatever you want first name Raja I'll say thisha next dot last name I'll say say but I'm just changing the name of this user okay so these informations are getting updated um email I can just give a different email disha1 [email protected] okay dot what else we have just give Okay so sometimes the suggestions over here by dot mobile number 77777 1 1 2 3 4 5 done and then finally I'm going to call the dot build you created the you created the profile request payload with the help of Builder design pattern take this is attach what you will get return response so just take the same variable put it over here we have not deserialized it so I'm just going to say response that's pretty clear to everyone people in the call okay and if everything works fine should work I don't know okay it works UD 1 2 3 4 password is not updated but everything else is updated so if I just go to account and then say I decide to go to profile okay let's say I update this stuff did not happen let's log out uh close what's same credentials that you damn man okay let's check over here response dot as pretty string no my bad this this is not one this is not the one which is running right click run as test NG test okay yeah this is the uh response from the first one this is the response from the second one or update so these things are getting updated so if I go to the application now okay and I decide to go to profile disha but email mobile number done clear to everyone yes or no everyone people in the call who stayed back so late okay I took a very decent flow over you can keep on continuing you want you can update the password continue password update okay so if you want you want to update password and all those things those things will work so that's the stuff over here guys uh this was a framework which I've created recently so I thought I'll probably give it to you guys so I hope you have understood how and how these things are built okay you can use it in your office project you can use it wherever you want next class next Saturday when I'll be connecting with you guys I for delete what's the confirmation code what's the confirmation code delete I think so I haven't tested the thing is that feature is not there on the UI right now so because I didn't wanted people to delete their account but uh the thing is uh if let's try to see if there's a delete test in front of you okay don't delete this account okay so over here TR off string M I don't want to take a risk over here confirmation code will come on your email and all you you can't really do it from here it like there's an admin and all those things comes into picture so in the admin controller he can control like whose account can be deleted updated and all so that there's going to be a confirmation code that comes okay probably it goes into the email and all so that's the flow over there probably check on that one now uh hope you got the end to end flow guys it is not going to be uploaded uh directly in the self-pace section right now as I've said I'll probably I'll put it over here document I'll put a YouTube link over of that particular video you can watch it directly here itself okay so in the documentation and the it will be there um I'll tell my folks to combine yesterday's and today's lecture together and remove the unnecessary part where there is a delay or a pause or something like that so that you can watch it in one shot make sense better all right so that's something that I'll you'll find it over here itself on this notion page whatever the URL you have you can bookmark it okay so I hope this particular session was useful to you guys man like uh I did change a lot of things in the framework for uh like previously if you're coming from different batch that time the framework was different this time I made a lot of difference over here the only reason is like lot of things comes changes here and there and um I just wanted to make sure like there are people from The New Batch also like they might be aware of basic things so that's the reason I kept it open for folks so that's uh not a good compliment Mano but anyways that's fine so the thing is um this is just the subset okay which I have created it off over here uh probably on the LMS you'll find more because um uh I was working on um uh like when I get time to study I prepare those things these days I don't get time but the thing is um a lot of things can be introduced used in your project like security testing okay uh I wanted to add it in this ecosystem itself in the live sessions it practically won't be possible for me so the thing is this might be the the subset which I wanted to create as of now so that you can showcase it in the interviews and all so just wait till January end or Fe first week or something the O swap will come into picture where you can do the vulnerability testing of the apis it will be there on the LMS okay that I'll probably not be able to take it in the live classes but uh live classes uh like Jan end Feb end whatever it comes into picture for me right now the most important thing is to complete with the uh topic of your objectoriented programming so I just made sure that the things which we are learning right now okay and what you're doing right now you keep on revising those Java Concepts over there so that when those topic comes it's not something that you are getting scared of what exactly it is it's like just a library I have to introduce and it is just going to take care of the vulner vulnerability checks over here database testing generally I don't try to put it over here but it's just an end to end check so again you'll find something in the jdbc and all those things uh jdbc connector when the last topic of java will be there so there is a change in the Java curriculum also I've done it and um uh the last topic I think so was collections or a list and all that I take it off but two basic things that I've added is the jdbc connector and logger logger you don't really need to watch also because if you have done the Tet assignment that's the exactly same thing that I'm I'll be teaching over there so same year also if you want to introduce logger it's it's just a 2 minute task you know you just need to make sure that the log 4G XML file is added you add the respective Library log 4G XML file loger utility copy Pasto okay and then you use it off those things I'll be taking it in the next class that is this next Saturday um that is going to be the day three part okay and in day three we'll just understand the final finishing touch I won't be writing any API test that time okay so you guys can practice It Off by yourself over there um these things will be introduced what will be filters how exactly lock files will be created your xmls and all those things how to run the test NG test in parallel mode but I'll just do it in front of you guys how to do thread save testing meaning if I'll be testing individual apis parallely how I can do it off okay finally I'll end that particular class this particular class on Sunday uh where we will be doing the Final Touch where we will integrate it with the GitHub actions okay so you will have an end to endend framework of API testing just like how you have done it for tet that this particular framework is also getting integrated with your CI tool make sense to everyone I think day three is something that you can do it by yourself okay so please try to do it yourself first because it is going to give you a lot of confidence this is not what I'm doing over here is just like I'm explaining you the code but unless you are writing the code you will not get that confidence huh who as I said it will be uploaded in the combine yesterday's and today's class I'll combine it off yesterday's class I have already uploaded in your respective batches okay oml only in the selfed class it is not there okay a this also I forgot to read this word okay I'll do that part over there that's a WRA okay so I'll end it off over here guys uh thank you so much for your time guys I'll see you guys in the next one okay take care bye-bye I hope you are confident and please start giving interviews the only reason I have to combine the multiple batches and take this topic is so that you feel confident API framework there was this one like student Monica okay she's not there today I guess so thank her not me okay I'll take care guys I'm you're you're great okay yeah like I keep people on mute now so I don't I'm not used to of all these silence okay so that's the thing okay so I hope you got the confidence Monica just build this particular project use the tell it part and I think you're fine with this stuff okay so the various design patterns just to repeat Builder page object service object factory factory terms of in terms of your what uh authorization W part yeah for Phoenix application those things you're done and end to end integration over there okay chali I hope it's clear to you right everyone comfortable with these things now okay by people who joined recently anud niharika shda yes okay actually so practice this part I'll update this particular document probably tomorrow or something so you can use these things over here okay uh as a task as your assignment or something if you want to practice more try to create all swag so I will just suggest like you go for user management only HTTP so you can just do that part confirmation K update how exactly it works over there kyc controller you can do it off there is a mocking which is there like which takes care of UPI transactions and all good luck with that man that's that's a little bit tricky one to handle report can uh report generation okay so this is just a get one it's just going to generate the HTML or sorry the Excel report and PDF report for you guys just a bank statement download all right that's all welcome back to the Channel guys and I hope you guys are doing pretty good so a lot of you guys were saying Please Release the part two of the API automation framework so here it is guys this is the part two of your API automation framework now in the part one guys we saw the first time where we were writing test scripts for your API automation framework with rest is short and particularly we introduced a new design pattern what was the design pattern over there service object model all right now the second thing over here guys we ended up overwriting couple of test for the different components different Services now in this particular lecture we will be speaking about logging how do you log the request and the response and you put it in the log files along with that we will also integrate the framework with GitHub actions so that you have an end to end picture how exactly this test is going to be executed in your CI pipeline now the thing is if you haven't watched the part one okay this particular lecture is going to be a complete bouncer for you guys so I'll advise you guys that if you found this particular video separately on YouTube or somewhere else please make sure you watch the part one okay I'll put the link in the description section or in the comment section of this particular video if you have watched the part one this part two guys is going to be a little bit tricky okay when I was taking taking this particular class for students you know I felt that this particular lecture was a little bit tricky a little bit complicated okay because the concepts which were coming over there was kind of new all right so what I thought is I will put the video where we'll be building the entire framework and all but before that we will just discuss some basic concepts that you should be aware of uh logging and filtering in rest assured is this part clear so we will be just having a theoretical session first for like 10 15 minutes and then you can just watch the part where I am building the scripts okay now let's get started see guys this is the part two of the end to endend API automation framework yes or no now in the part one guys what we did was we created the service layers okay and for these service layers I have written the test yes or no so if I have to talk about the structure of my automation framework let me just draw it for you guys over here guys the framework that we have created is basically a Java Maven based project all right now in this Java Maven based project um if you have seen the maven projects that you create you always have SRC main Java okay you have your SRC uh test Java coming into picture now generally you can keep the components in your SRC mean ja also I don't like that particular stuff so I generally keep it in SRC test Java now in SRC test Java the first component that I created was called do api. base so over here I have created a class which is called as this API base. Java and this particular class which I have created is basically what is an abstraction okay over rest assured okay so whenever you are using any Library whenever you decide you're going to use selenium you're to use APM you're going to use rest short you're going to use your Json utility your gson your Jackson coming into picture or you decide to use logger all right any kind of external third party library that you use it's always better that you create abstraction okay so why we did that is so that when I'll be writing my test scripts it's going to be a pretty simple uh Java concept I'm going to create a class I'm going to create an object and I'm going to access the method as simple as that I don't want to write something like given when then so on and so forth now some of you guys will be thinking that Jan you can just use the rest ass short given when then scripts right so I can just create a test method and inside that particular test method I can just write given right then we going to have the header the base URI okay the body and then I can use the wind script where I can just make the post get put delete request and then I can do the assertions the problem with this particular approach when you actually use all your given when then structure over there if tomorrow I am going to make any change in my base URI if there is going to be a change in the body and all wherever these scripts are going to be used in your test you have to keep on making changes so this is not maintainable okay this is not maintainable to overcome this particular problem we decided we will be using a design pattern okay and that design pattern is pretty simple it's there almost in all the applications of the back end we generally use that it's basically your service object design pattern all right we use a service object design pattern and what we do in the service object design pattern is you would be given a Swagger dog right and on the Swagger dog you will be having let's say a service which is which will be given to you let's say we have been given a service called API uh for/ so o over here is my service okay and in od service I will be having various endpoints let's say I I'm going to have login I'm going to have log out okay I can have create account okay something like that now login log out create account these are what end points these are basically going to be the operations that are going to happen in AU service so what I'm going to do I'm going to create a class called Au service and Au service. Java and this is going to extend API base so in this particular class I will be having um all the methods that are there in API base I can easily access it off now in your au service the login log out create account these methods will be there all right these methods will be there and when I'm going to hit a login request what do you get back response so these methods will always return you the response okay will always return you the response now what happens is because we have an OD service class which has these three methods okay what we can do over here is instead of writing the test scripts given when then what I can do is I have to just create the object of OD service okay and I can just access the method I can pass the credentials and login method is going to return me the response and then I'll be validating the response as simple as that maintenance becomes much more easier okay I see a lot of videos over the um YouTube and over the Internet they generally go with the G uh the given B then but they really don't really focus on how exactly you'll be maintaining the scripts in Long Run Okay so for that particular reason you know like it's it's good to learn from those videos but the problem that comes over here is those scripts are not maintainable in the long run okay you will definitely learn rest assur and all and learning rest assur is not a um you know like a complete um complicated thing it's a very simple thing okay so if you are aware of java if you understand how Java Works learning new libraries is not going to be a very de big thing it's a pretty simple thing actually okay so please make sure guys you understand the various design patterns and how exactly you will be maintaining the scripts in Long Run okay you're not just going to write uh 20 30 test think of a bigger number 400 500 test and if there is going to be any kind of a change which will come into picture let's say there's a change in the endp point there's a change in the header there's a change in the body will your test scripts be affected with that okay will your framework will be able to handle those incoming changes the changes which are happening in the development will you be able to incorporate in your framework right those are the things that you should always focus on is this part clear to everyone perfect so we have the comm. API base and inside this API base I have the API base which is basically an abstraction over rest assur and I will create the respective service classes service classes are going to have the respective endpoints of that particular service and all the methods will return me response is this part clear to everyone perfect quickly make a note of this particular point now of course we have the com. API base the next thing that comes into picture is going to be com. api. test so this is where I'll be writing all my test scripts Prest NG and you will be accessing the Au service classes over there or service classes over there now the next thing that will be there in your framework is going to be something which is going to be called as com. api. model yes what is the purpose of model in your model you're going to have two things request and response what you're going to have request and response what is this request and response you have to attach payload now you have to attach payload you will be getting the response back in Json format then you need to also assert them so what we do we will be creating the Java classes or some of you guys call them pojo classes okay and these pojo classes will be uh created for both both request and response benefit you can easily pass the the data you don't really need to hardcode you don't need to keep the Json somewhere of course you can do that approach also because rest short provides you with different ways of passing the data to your API request right so over here guys um either I can create a pojo or I can just have a hard copy or a hardcoded Json that have kept it somewhere and I can pass it off over there but we have gone with pojo classes okay so you will always create payloads model okay and you will attach these models in your um login request endpoint you'll pass it to that all right so this is something that we have seen in the past class I'm quickly doing a revision for you guys so that you understand how it's done now the next thing that we have done apart from that I'm just looking at these things what we have done over here we have seen OD service bait service SRC test um yeah that's that's the thing that we have seen in the last class okay now let me just rub this particular board quickly now in today's class guys we will be focusing on two things or I would say three things loggers okay the second thing is going to be filters and the third thing is integrating the framework with your GitHub actions sometimes people ask you are integrating with GitHub action is it a different thing from Jenkins suppose I want to integrate with the framework with Jenkin you can do that okay the way I have created this particular framework is such that you if you want to run it with your GitHub actions or you want to run it with gitlab Runner or you want to run it with your Jenkins the steps Remains the Same okay steps will remain the same you your ultimate goal is to always run the test from the terminal so if I'm able to run the test from the terminal then it doesn't matter whether you do it with GitHub actions your jenin okay you want to uh do it with u let's say gitlab Runner it will still remain the same you just need to know the command how this framework is going to be executed okay if you have uh seen the SD Foundation okay we have discussed this particular part in detail okay I'll put the link in the description section you can check that part also now when I'm talking about logger in Java if I have to generate logs which Library comes into picture log 4J okay so when you're looking at log 4J guys what happens is you will need two libraries of log 4J you need log 4J API okay and log 4J core okay you will find these two things from the MAV U repository Maven dependencies you can search it from there but these are the two dependencies that you're supposed to add okay now what are filters this is going to be a very important interview questions for you guys like in interview they can ask like if you say that you know API testing and if you have created the framework with rest is short definitely they can ask what are filters now one word about filters that you should always remember is Filters help you intercept yeah what is this intercepting okay what does intercepting means over here intercept basically means that let's say I have something which is getting started from point A and I have to go to point B if there was no interception happening the the thing would have been going in the straight line okay inter interception basically means is this this thing is going to happen in a straight line but someone came in between did something and now it's going to go from C to B so if I want to you know like make some modification in between things are going to move from A to B only but the point is someone is coming in between and making some modifications okay that is what you call as intercepting that is what you call as in intercepting if you if you have seen any football match and all like someone is trying to pass the ball from one player to another player but in between the opponent player comes into pitcher and then they try to take the ball from there that's called intercept means so over here when you look at filters filters are always meant for intercepting so what is going to happen you always let's say you're making a request you're making a request and rest assur now request is going to be made this request has to reach to the server okay this is my server okay but before the request reaches the server okay I want to make some kind of a modification what do you mean by some kind of a modification modification can be anything I want to capture something from the request okay I want to make some changes in the request all all those things I can do it but for us we want to capture something from the request what do I want to capture I want to capture what is the base URL I want to capture the end point I want to capture the header I want to capture the body so that I can log this thing okay in my log file similarly once I capture this particular stuff I will log it and then I will again continue with the request okay and the same thing happens in the return also when the server processes the request it is going to return the response back the before the response reaches your test for further validations you're going to do the testing over there it is going to go via the filter and what filter is going to do again it is going to capture what request to it has captured now it is going to capture the response it's going to capture the response okay what were the headers then what was the payload or let's say the response payload right response time okay then status code all the things I can capture it off okay now the thing is these things okay when the request is made and I'm getting the response back in in between I'm trying to get those informations that is what you call as intercepting and to do that in intercepting you need filters okay this is the theory that you should be aware of all right now so we will see about loggers and you see about filters one more important thing about is these things are I need to capture it off when when my test is getting started okay when my test is getting completed if my test is failing right and need to capture all those things is there a component in your uh API automation framework or in your automation framework that can help you understand which test got started which test got failed which test got skipped is there a way you can get that information yes you get it with the help of yes I know you know the answer how do you get that information you get it with the help of listeners so we will create the component in such a way that filter and listeners are communicating with each other somewhere on the lane we have to do that part okay yes this is something which is important and once it is done okay our main goal is to run the framework from the terminal and in order to run the framework from the terminal you are going to use a very important plug-in very familiar plug-in you might be heard about it if you're using MN have you heard about this plugin called Maven sh fire plugin okay so what I'm going to do is I will introduce the MAV Shire plugin I'm going to pass the parameters okay and those parameters MAV Shi plugin is going to receive it and it is going to execute my test okay so that my command remains something like this Maven test and then you can do the execution all right this is something that we will be building in today's class so make sure guys you create projects you put it in your resume and during interviews you can tell them that this is the project that I have built okay so that it gives the confidence to the interview that this candidate knows what he has done okay what he's aware of okay this is something that you want to um showcase during the interviews else it's it's going to be a very uh difficult thing you know like in long run you have to learn things by building projects and that's the ultimate thing that we do it in the main course also that we always build projects else it's the same thing you come to the class you see someone on the zoom calls okay he's writing the code or she's writing the that doesn't work all right so please make sure guys you complete this particular stuff and in case of any doubts and queries you know where to reach out to me so without wasting time now let's get started with the part two I hope my screen is visible to everyone everyone is able to see the screen yes no Okay cool so probably uh uh just till tomorrow I'll be taking the API automation framework tomorrow by tomorrow it will be completed so um before I start with today's class um I just want to show you what exactly we want to build for today uh just a moment yeah I've already pushed this particular project this is a SE trade project but something similar we will try to build it uh for um today if you have already saw the tell it assignment you will be yeah is my screen visible to everyone right I hope you guys are able to see the screen perfect okay okay so uh something like this I want to build it off so if I go to my actions you know you will be able to execute your API test on your GitHub actions the second thing over here you'll find an option which is called as the test NG results so whatever is the execution of my test which test is passing which test is failing all those things I will be directly able to see it on my GitHub actions dashboard okay now this becomes very useful for people if you are trying to use any CS tool like Jenkins your GitHub actions your gitlab Runner probably I don't want to see the report I can just go to my GitHub repository and I can just see the actions logs right so whatever will be the build I can just go over there and I can quickly check what is working what is not working of course screenshots is not something that we'll be needing over here but having this kind of a dashboard for your API test is going to be very useful now a couple of days back there was this one student of mine who was uh called this particular uh interview question what are the enhancement that you have made in your framework right so you need to be sure that you just don't say one or two things you really need to have a lot of things in Your Arsenal right you should really talk about like these things like how the dashboard got created how you are integrating it with GitHub actions the various design patterns like I showed you the service design pattern or the service object model that we have seen so far okay how you are writing the test if you have seen the tell it assignment how we try to optimize the test scripts okay how you're avoiding IFL statement conditional statements your Loops your U TR catch your uh you know like iterators and all those things in your test the test is always meant to be kept clean small simple so that it's easy for the uh easy to execute it off isolations of the test that we have done so far so that's something that you know like you really need to be aware of whenever you know like if they ask for the enhancement perspective now the notes for this particular stuff I have already published it off uh I don't how many of you guys have practiced day one and day two whatever things we have done over here are have you Revisited it off is this yes no that's more important can you put it in the chat box everyone because if you have done then day three and day four is going to be pretty simple nothing fancy I'll be teaching uh over here it's just going to be the implementation part which is going to be done so if you are just going to complete till tomorrow or something you're done with the API automation framework okay at least something uh awesome that you can really talk about in interviews not even just in interviews you can really use it in your office projects and all so if I go to day three the document is I think so you have bookmarked this particular Ur right so this is going to be the same stuff I have uh just introduced new sections new a study material over there now if you have already solved the Tet interview question this is going to be a cake walk for you okay so this is just a prerequisite I'm telling you that whatever I'll be doing right now is going to be very much similar to the selenium assignment that I've have solved okay and kept on the LMS so this is just an extension for that okay so in today's class we will understand what are filters in rest assured okay and how you're supposed to use filters um we will also be majorly focusing on generating the logs for the test scripts okay so obviously log 4J will come into picture we have we already are aware of how exactly we are using log 4J or how you're supposed to use log 4J in your framework we have done that part so we will integrate it over there okay and most of the things you'll kind of find it is similar that we have done it in the tell it part okay so that's something that will start doing it over here now over here guys the first thing that I want over here if I just go to my test let me just launch the dashboard uh just me a moment I'll be keeping everyone on uh mute for now okay thank you now going back to your demo API automation framework this is what we were working so far so a just quick revisit what we have built so far so over here we started first by writing test right if you remember we were writing the test with normal rest short Ive still kept this particular script over here if you write this particular script like this okay the problem is of Maintenance so we started to do static import meaning if you look carefully rest assured is a class which already has static methods and static variables so you're not supposed to write rest short. Bas URI and all we when when to introduce given when then structure so we write it given base URI header body post so this is basically what you call as method chaining right and uh this was fine okay it was doing decent job but again it is not something which I can use it for testing of microservices because the problem that comes into picture is isolation is not possible there's a hard level of dependencies on each of these test scripts that we'll be writing so we started proving it off over there we introduced the service object model and what service object model does is you are going to create your respective services so I have created this comm. API base package over here the first thing that I created was this Base Service class this Base Service class is basically your rapper over rest assured now we create wrappers so that we can introduce abstraction so over here what happens is instead of remembering this entire chaining of methods though it's not difficult to remember it off but when you write test it looks a little bit complicated so over here guys what happens is when you create these wrapper methods and all writing of my test scripts is going to be simple the same thing I have done it in the browser utility the same thing you do it in your APM utility you the same thing you do it in logger the same thing you do it in extent report the same thing you do it in Excel so no matter what library you are going to use you have to create some kind of a wrapper over it so that it is going to be much more easier for the folks uh people who are writing test scripts to understand what exactly this method is going to do they don't need to do the hard drilling of fixing and understanding the code so over here we have created this particular rapper and over here we have it's going to take care of creating the request specification you can attach the header you can attach the P like you can make make the post request and we directly returning the response over here okay that's something that we have done and for each of the service layer we have respective class so Au service extends Base Service and whatever is the base path I will be creating over here and each of the method will be the respective end points so if I'm going to hit this end point I'll be get getting the response back so internally the login request calls the post request from the base service okay that's something that we have built over there in the previous classes so no matter how many service layers you are going to have you can go to the Swagger do and you will easily understand so if I go over here let's say if I scroll a little bit up and I go to the Swagger do if looking at the Swagger do I'll come to know okay authentication controller I can see a service section whatever will be the apis over here now these will be the methods account account account number with get user these are all going to be my uh methods inside that they will call Post get and get request so account will be my class make sense to everyone yes or no this is something that we have seen so for each of the controller section you will create the respective classes and these respective classes will have these many methods over there so mock UPI controller is is going to have 1 2 3 4 methods all right so that's something that we have built yeah sorry there was a issue over here now the next thing that comes into picture is the request and the response whenever you are going to have any kind of uh payloads right you will be attaching the uh body to the API request so if I go to the Post request probably I want to attach some kind of a body right so these body my dear friends we need to pass to the request and we can pass it off by creating something which is called as models so I have created request model and response models now for most of you guys what is this model and all thinking simple pojo class variables will be instance variable will be private there will be a Constructor there will be Getters and Setters coming into picture all those things you need to create it all of so this is what the model is going to focus on and I have this login request model now over here guys this is something that we have created variables are private then you're going to have login requests get user response Setter sets two string method coming into picture similarly for the response also we have done something similar this is something that we have okay variables are going to be private there's going to be a Constructor so and and so forth that we have created now if I go to the user profile response this is what we have now the next thing that comes into picture is writing of the test scripts so over here if you look carefully for the sign up request the way I have created this particular request which design pattern is coming into picture over here this is the Builder design pattern so sometimes when interview they will definitely ask what are the different design patterns that you are aware of page object okay don't say pojo say your Singleton coming into picture your Builder coming into picture your factory coming into picture the main reason they ask about various design patterns is because if you're using design patterns correctly these are rules if you're implementing the design patterns correctly it means that you have used objectoriented programming correctly okay what is the advantage of having the Builder design pattern the benefit over here that comes into picture is I can pass the par parameters in any order are you getting the point yes or no everyone yes this is the benefit that you get when you're using Builder design pattern so I don't need to remember the number of parameters that are going to be there okay there is already a class which I have uploaded on the LMS so if you go to the LMS you will find something which is called as the Builder design pattern so it is going to give you a better perspective on how exactly things needs to be created over there all right so the complete uh objectoriented programming okay till abstraction it's abstract classes you will find it over the uh LMS so along with that if you're revisiting Java and all okay along with this you definitely want to check those things out it's it's really going to help you out understand things in a much more deeper level now if I go to the sign up request C this is something that we have created sign up request oh this is the Constructor and over here we have have created a inner class okay and over here we have created this Builder class okay so a class which is going to be inside another class is going to be called as your inner class and inner classes in Java is going to be static in nature okay you can make it static it's not necessary it cannot be non-static but for Builder design pattern we try to make it static now there is one more thing that you can really use it to improve it of in Builder design pattern also you can make or you should make the Constructor as private now the question that comes into picture is what is going to happen when you make the Constructor as private okay this can be an interview question what is going to happen when you make a Constructor as private can I create the object of this particular class yes or no can I create the object of a class which uh has a Constructor as private the answer is yes I can create the object of this particular class but I can only create the object within the class you see build method is creating the sign up requesta object it is calling the Constructor of sign up request within the class what happens when you make the Constructor as private is you take away the privilege of creating the object outside the class I cannot create signup request object now in any other class make sense within the class I will be able to create it are you getting the point over here yes or no are you getting this point yes no are we on the same page everyone okay now because of this this really helps us out because now when I'll be writing any of my test so they have to use the Builder method okay they have to use this Builder Constructor and only then pass it off make sense to everyone you will get the object uh hash code or the instance reference but it has to go via Builder so I cannot write new signup request and start passing the parameter over here which we were able to do it in the previous class now you are not going to do it so please make sure if someone ask you in the interview can the Constructor be private most of the people are going to say yes and in which design pattern most time people say it's going to be single time it is partially true you should also make it uh private in your Builder classes is this part clear to everyone yes or no are we on the same page now right can I go ahead now over here comes the next part that is we want to generate logs okay this is something that we want over here generate the logs in your um automation framework now obviously you will be using the log 4J Library coming into picture so if I go to your palm. XML file okay and let's say if I go to the overview I have already added this particular dependencies if I go to dependencies there is going to be lock 4J API and lock 4J core uh nothing fancy over here you guys can generally just go to this particular document from the day three uh you can add these two dependencies the log 4J API and log 4J core this is something that needs to be added when you are generating or you are going to use the log 4J Library both the dependencies are required core and API is this part clear to everyone so this dependency I have already added it in my framework now we are supposed to use it so over here guys we need something which is called as this log 4J 2. exam file once you have added this particular dependency API and core go to the SRC test resource and introduce a file which is called as log4j2.xml I can delete it and I can recreate it for you guys nothing fancy over here just right click create a new uh file the name of the file is not going to change it's going to be log4j2.xml only tell it assignment same stuff now over here guys what are you going to have if I'm going to I I'll start asking questions because most of you have already done this particular stuff if I'm going to talk about log 4 J2 XML file if I have to configure this thing what is going to be required over here what is required in the log 4J to XML file what setups things are need to be required over here that's the appender nothing else what exactly will be required over here the the structure I'm talking about so the point that is over here is the first thing that you want to talk about a wow file when I'm looking at the structure okay just give me a moment when you're looking at the structure the first thing that you need over here is the configuration and inside the configuration you are going to have appenders and loggers so it's pretty simple okay though you can just copy paste it it's not really a big thing but obviously if you're copying copy and pasting it also you need to know why you creating certain things so just remember you have something which is called as configuration the first thing the no node basically starts from configuration you're supposed to give this particular configuration Sor just give me a moment please don't draw whoever is drawing on the screen okay okay so the first thing that you're going to give is the configuration and you can give a name you can give a status so you can just going to call this as status is going to be let's say as warning okay and this particular configuration is going to have something which is called as appenders okay something called appenders now in your log 4J we technically need two kinds of appenders what how many kinds of appenders two kinds of appenders one is going to be what what what kind of appender first one is going to be console based appender so you see inside appender we have console based appender and the second one that I need is basically the file based appender coming into picture so I'm going to just say console okay and I'll have the configuration of console and the second one is going to be the file based appender which will be there now you'll be thinking what exactly is this appender and all see when my logs are going to be generated where do I want to showcase my logs as simple as that log so my logs I want to show it on the console I want to see it on the execution along with that I want a file to be created which is going to be that is going to be the file based appender log file so the configuration takes care of where this appender needs to be shown is this part clear to everyone so I'm telling that for this framework this particular project I will need two kind of appenders coming into picture the first one is going to be the console based appender and the second one is going to be the file based appender is this part clear to everyone yes or no yep so don't uh you know like whenever you have to explain like in the interview also right answer it in this structure only if I'm going to have a log 4J I need the configuration the configuration is going to have appenders and loggers we'll just focus on appenders for now now rest of the stuff is pretty simple you just give a name to this particular appender I'm just going to call it what is written over here console I'll take the same name for your reference so this going to be console based appender just that's just the name we need over here and the next thing that comes into picture is something called as Target you write system.out.print l so that's what you need to write system underscore out as simple as that okay so I'm just going to say uh Target just write in capital system uncore out okay we'll come to the pattern layout later same I'm going to do it for file also so I'm going to say this is going to be a file based appender so the name I'm going to give file okay so just going to write over your file okay and the next thing that comes into picture is file name so this file log will be created where it is going to be created inside logs forward SL test log file that will be the name of this particular uh log file so I'm just going to say over here as file name the convention is same like your Java camel casing and I'm just going to say log create a log folder inside that logs folder create a file called uh test.log as simple as that is this part clear to everyone so one the logs will be shown on my console second the log 4J is going to create something which is called as this um logs folder which we don't see it anymore over here it's going to create that folder for us inside that test log file will be there is this part clear to everyone yes or no are we on the same page okay next thing but once these logs are generated what needs to be shown log F right that is where pattern layout comes into picture okay so you're going to create something which is called as pattern layout what will be the structure okay how this particular stuff will be shown okay so we'll discuss those things in a moment I'm just going to say pattern layout and this same pattern layout I'll be creating here this pattern layout my dear friends is going to have a pattern okay so this pattern layout you need to create something which is called as a pattern so I'm just going to copy this and I'll explain you one by one line so over here let's say this is going to be a pattern and pattern the first thing I want is the time stamp that is I want to know at what particular time the entire log was created okay that is something that I need so you show it with percentage D okay percentage D this percentage D okay I can configure it if I'm just going to leave it like this okay just give me a moment I can take a better one yeah if I'm going to take this percentage D what is going to happen it's going to go with its own configuration of showing Tim stamp but I want to control in it way I want so I'm telling first show me hours then show me minutes then show me seconds okay and then the remaining seconds so this is how it is going to be shown I can just copy this particular stuff okay and I can keep it over here is this part clear to everyone same I can do it over here also so pattern equal to this so it is now if I run this particular stuff only thing that I will be able to see is the time stamp but I don't need just the time stamp now I need other information also the next thing that is there over here is something called as percentage T so this is basically the thread name which is coming into picture okay which thread is getting executed over there okay so since if if you are going to have something called as let's say parallel execution so which thread it was running it is going to give me the thread name if you are only going to do sequential execution let's say you just want to do an end to end testing in one shot so single thread will be needed that time so only main will be written over there is this part clear so this percentage t means your thread name coming into picture so square bracket the answer is no this is the pattern sareet okay so if I would have left per percentage uh percentage itself percentage T itself then it would have shown me in that format only but if it's going to be in square now square bracket okay so this is something that we are controlling it off so this is going to just give me the thread name okay so I can just attach this chap over here and I can attach this chap over here okay both the places your pattern layout will be exactly the same you're not going to change it anywhere because whatever is generated on the console I want to see it on my file the next thing that comes over here SS microc seconds like you want to go it off over there but I will suggest you don't keep it off if you want SS Tu is fine hours minutes seconds and okay that's the level so next thing is the level whether it is a informational log whether it is a debug log whether it is a warning whether it is an error all those levels will be shown to you so whatever is the level you take it off and you attach it off over here see I'm going to do it over here done okay so over here whether it is a informational log whether it is going to be a debug log whether it is going to be a warning all those things will be shown to me the next thing which comes over here is something which is called as percentage logger if you remember if anyone remembers what exactly percentage logger is going to give me and 36 over here is a length what is the percentage logger signifies over here percent percentage logger basically is going to give me the class name from which class this particular log was getting generated it is going to give me the class name exactly the class name which is going to be there con class me message a okay so percentage logger is going to give me the class name percentage message is going to give me the message that I'm trying to print and percentage n once this entire stuff is going to be printed it is going to go to the next line percentage n signifies print the log and go to the next line is this part clear to everyone yes or no are we on the same page now just to repeat it this is going to give me the Tim stamp this is going to give me the thread name name if it is going to be a single threaded one main will be written this is going to be the level info dbug whatever it is going to give me that stuff this is going to be give me the class name you're going to get the fully qualified class name then this is going to be the message that you're trying to print and percentage n is going to go to the next line clear so this is the pattern this is how I'm telling log 4J Baba I want the output in this format one it is going to print it on the console and the second one it is going to write it in the file is this part clear to everyone yes or no did you create understand this entire structure what I have created so far okay this is not something that people will tell you to write it in the interview and all but you know like they can always ask structure okay so the next thing that comes into picture is up the final thing comes into picture is logger okay so this is something that you really don't want to change change it off percent this is basically hyphen 5 is the padding hyphy is like if you have info debug your warning in words characters so if I want to just make sure that the padding the spacing is correct and all that's the reason percentage five minus 5 is written over there okay so that's the reason even if you remove it off the output will still be there the only thing is spacing okay and once this is done you will introduce the logger skaba you are telling logger then start using it off over here so just copy and paste it off nothing fancy logger the root level is info so I'm telling that capture everything from information level and both the stuff will be shown all the informational message will be printed on the console and it is going to be R uh written on the file clear to everyone this is going to be exactly the same you are not supposed to change anything over over here so from informational message level your console will be shown like the messages will be shown on the console and the file if you're not writing this part it's not going to work okay you just created the appender but logging is not getting started over here so that's something that you have to introduce in the log forg and that's the only thing that you need done finish okay let's close all these things so if you remember we are just focusing on generating the logs so we got this thing into picture now I want to know I want to generate the logs what exactly the information will be there in the logs which test got started which test got failed which test got skipped when the test was executed when the test got finished who is responsible for all these things who is responsible for all these things in your automation framework who can take care of all these things how do I come to know when the test is started when the test is failing when the test is getting skipped listeners listeners will come into picture you have saw the assignment guys come on what assignment you guys are solving over here package so I'm going to create over here a new package which is called as com. api. listeners okay now now the next thing that comes into picture is I'm going to quickly create a class and I'm going to call this particular class as my test listener finish okay this story Remains the Same this particular class is going to implement which interface which interface is going to come over here public class test listener will Implement which interface first I need input from everyone I test listener implements I test listener okay now you see I'm not getting any uh method overriding request and all because we are using a different version over here of test NG and over here they are using something which is called as the default method so the only benefit that you get is whatever the methods you want you can introduce it from here okay so what I want right now is I want the on start method I'm going to copy it paste it off over here okay paste it off over here just going to call this as public okay control shift F previously you are supposed to implement all the methods now you don't need to do all those things okay so I got on start then I Want U on test success one by one you're going to copy whatever the methods you need make it public next just give me a moment then I want on test failure then I want a test which is going to get skipped so on start on test success on test failure on test skipped and finally I don't want on test build within uh a certain timeout I don't want that I just want this on test finish okay so these methods I'm looking for so I'll just add it off over here is this part clear to everyone we have done it a lot of time clear yes no can I go ahead quickly okay now we have to introduce the logs so over here guys if you want to use the log you will use something which is called as logger and log manager okay so if you look carefully test listener Implement side test listener and I have this particular snippet which is there so whenever you're generating a log okay your code is going to look something like this private static final okay I'm using logger okay so I'm going to create a reference of logger and log manager. getet logger so over here you supposed to pass the class name okay so whatever the logs which will be generated over here is going to be from the test listener log that's what we are trying to say over here so just do a control space and over here you see I'm getting logger from lot of different packages in Java you are supposed to use the one which is an interface org. Apache logging log4j you're supposed to use this one and log manage you are going to use this chap from the log 4 J1 be careful don't select anything else okay it's not going to work then done save it now over here we wanted to generate the log so I can just say over here logger doino and I just want some kind of a message to be printed over here okay so the message can be something like uh test Suite started okay copy this and over here this is going to be onfinish method so I'm just going to say complete it save it copy this now over here my dear friends I want to give the test name so we see this it test result variable now we're going to use that only I'm going to copy this I'm going to say result. getet method name and I'm just going to see over here something like this started okay and then I want to probably have the description of this particular stuff okay I'm just going to say get the description finally the test uh this is not finished this is on start this is going to be passed sorry this is Success no okay this is pass and I'm just going to copy this put it over here this is going to be for failure I'm just going to see the test has failed okay and I just say this is going to be skipped something like this now obviously if a test is failing it is not something which is a info right so you can use something let's say if I go over here I can go for a fatle message something like this because just indicating that this is something which is a major problem okay or you can just use the normal error popping up into picture okay so I can just go for error okay and this is just going to be an info that the test got skipped now one method I have missed over here on test success is there I need one more which is on test started this one okay so I'm just going to copy this and I'm going to introduce this also over here and change the method you know like from default to public just copy this line paste it over here copy this put it off over here I'm just going to say test started okay so I don't need the description over here is this part clear to everyone what I've done over here this is how I've generated the logs in the previous classes also clear to everyone nothing fancy to have done over here as such everyone any no rocket science over here just copy paste copy paste keep on changing the things over here now once this is done uh what I want to do is I want to go to the API test and we're going to take a very simple test over here let's say we decide to go for something like login API test 3 itself like something very basic I want like I don't want any fancy things this is the one I want to attach the test listener to this particular test class how do I do that which annotation will come into picture if I want to attach a listener to this particular class what will I use over here which annotation at theate listener and you're going to give com. API listeners. test listener. class okay like if everything works in our favor okay and if I run this particular stuff can you see the logs are getting generated it's a information na log com. API test listener test. started started login test description verify if login API is working right this is the response which I'm getting back okay and if I refresh this particular project I should see a logs folder inside the logs folder I'll see the logs is this part clear to everyone yes or no yes no everyone on the page uh we call yes no are we on the same page guys this is something similar we have done in the past so if this was something that we have done similar in the past the class should end over here right but the class starts now okay the the thing over here guys is if you look carefully what is missing in this log if you look carefully is is the log enough is it solving the entire stuff whatever you were looking for the answer is no if I'm looking at the log shouldn't it be great if I am able to see the payload I'm able to see the end point I'm able to see the response I'm able to see the header right I'm able to see the status code coming into picture getting the point that's something which I want over here that I can rely it on a much more like it it gives you more detailed information as simple as that but how to do that so over here if you look carefully if you look at the login test how do I pass the Header information how do I pass this base URI the body the response status code information test response reest how do I capture it off some way and I can give it to this particular listen now are you getting my problem yes no how can I take the payload from there and I can give it to over here some people will say that you use the result make sense result but result I can only access the information which is about the test I cannot access something which is inside the test method are you getting the problem you can access the information of the test the description the status code the group sorry the description uh the test name the groups that they belong to Priority I can get all those informations when the test started when the test got completed all those information I can get from this at theate test annotation if I decide to use this I test result that's the reason reason I got method name that's the reason I got get description and all but what about these chaps right how do I get right how do I get the information how do I get the status code are you getting the problem over here yes no yes no that's that's the most important thing first thing the problem needs to be understood by everyone what I want and like what I'm not able to do right now okay this is the major problem that we have now to overcome this particular problem the term that is coined is something which is called as interception okay the term that is pointed over here is interception so before I write this particular code write code difficult you thinking like what this diagram I made it and all it's not difficult okay you need to understand something what is the meaning of intercepting see intercepting is basically a software term it basically means catching or interrupting something while it is moving from point A to point B okay similarly when you try to intercept a passing of a football you know like two play players are playing football and someone comes in between and take the football away right it allows you to perform action before letting continue its journey in context of this logging filter code inter uh intercepting means the HTTP request is created by your application before it reaches to the server okay for the further processing before it is going to hit the end point the filter catches it intercepts it and it is going to examine the request modify anything that I want to do decide whether to let go or continue or block it so what we will do over here in this scenario I'll first explain you from here this is going to be my test method inside my test my rest assur code is there okay so when this method is going to be executed Java or rest assured Library will try to make a post request to my server up before it makes the request to the server I will intercept it post request we will intercept it intercept basically means interrupting blocking something for some time or you want to capture something from there or do any kind of a modification okay intercept this interception is going to be done by a special entity in your rest short which is called as filter filter intercept and what exactly it is going to do it is going to intercept your request why it is intercepting your request because in your request you have your header or I'll say you have your base URI you have your header you have your body you have your uh any other information that you're passing over there so I will log these particular information from here so filter is going to help me log the base URI header body while intercepting the request is this part clear to everyone are you getting the point what exactly filter is going to do for us yes no are we on the same page if you look carefully look this particular diagram I have this particular test class this test class is going to make the request now while it is making the request and it is trying to reach to this particular endpoint on my server login filter that is my filter will intercept it it is going to intercept the request it it is going to log the request information the method URI header and payload it is going to be logged over here by the log 4J is this part clear to everyone yes or no is this part clear to everyone how it is going to go similarly once the response is going to come because you have a filter once the response is going to come again it is going to do the same thing response test case P before the the response reaches the test case the filter is again going to intercept it and it is going to capture the information from the response and it is going to log it for us making sense to everyone what exactly it is going to do it is creating a mediator between your test and the server okay the end point that you're making the request to what data is going to go from the test it is going to intercept capture it put it in the log and then send it for further processing reverse also when the response comes loger filter or logging filter is going to take the data filter it off put it in the log file or on the console and then it is going to give for further assertion this is what interception means is this part clear to everyone now how it is going to work okay so the goal over here it's pretty simple interrupt from your test case to your server before the request reaches the server I will try to capture all the information and log it off that's all I want to do nothing fancy because there is no other way there is no other way you will be able to capture any of these things from your test to The Listener so that's where the new comp component of your framework comes into picture which is going to be the filters in interview they can ask the question what are filters in Java or rest is short and you need to answer it from the basis of interception filters helps you intercept the request okay then the interviewer ask is what is the meaning of interception interception basically means that before I start before I make the request if I want to capture any information maybe for logging purpose maybe for reporting purpose I need to intercept it and that's where filters comes into picture so what I'm going to do is here I'll be creating a class which is going to be called as logging filter loging filter I'm going to call it now what to do with this particular class I don't know so what I will do is I'm going to search for something called as an interface which is called as filters okay loging filter implements filter and I have to add this unimplemented method called filter method so in interview if they ask you tell me the different interfaces that you have used in your project don't just rely on test NG interfaces I test listener I retry analyzer now start remembering filter also from rest short clear to everyone should I start writing the code over here yes yes or no now the next thing that comes into picture making the stuff over here is pretty simple it's not very difficult one what it is going to do logging filter it is going to log things for us right so my dear friends since the job is to do the logging you're going to create another logger over here private static okay final logger logger you're going to take it for log 4J I'm going to call this as logger equal to log manager log manager. get logo okay and just give the current class last name that's it finish because we want to log the request now what we are going to do is we are going to create two methods public void log request okay and since you want to log the request you want to take request specification filterable request uh filterable request specification just take this particular stuff put it over here okay what it's going to do I'll tell you moment and then you are going to take the response coming into picture okay I'm going to create something public void log response okay done response huh not this response just the response Now understand what happens over here what we will do is what we're going to do is I'm going to call the log request I'm going to call the log request and I'm going to pass the request specification this request specification consist of all the information about the request base URL header body all those things I will be able to get it over here so filterable request specification is going to give you the information of the request and what I'm going to do I'm going to say logger the logger which I have created do info okay now observe what do you want to log I want to log uh base URI so I can write something called over here as base URI colon and I can say request specification do get me the base URI is this part clear to everyone what I've written over here yes or no so base URI along with the base URI will be printed for you copy this what do I need next header so I can just say request head header okay just change it over here to get me the header okay copy this what do you need body request payload okay get the body what else you need let's say I think so this this is the enough stuff base Ur you're going to get everything whatever is written over here now once you have made the log request right you see this filter context I have written it in the diagram also P log request call then you have to make the request you have to intercept it I have intercepted it so I only have to make sure that it gets continued so over here I have to say CTX okay dot next and over here just pass the request specification and the response specification next is going to return you the response request B because we have intercepted it now we came in between okay it was going without the interception I came in between to capture the information I'm capturing it off should I just stop over here no I want the request to be continued so I'm just is going to make sure the request is made now this is where your request is going to be executed okay next is going to return me the response oops is my voice audible yeah is my voice audible yes okay there was an issue with my it yeah so I'm just going to have the response coming into picture and if You observe carefully I'm logging the response here I'm logging the response so the response which I'm going to get we have to make sure that this is also logged so I'm just going to call log response pass the response okay and over here the same stuff I have the response I'm just going to take these information put it over here I'm going to say response dot get me the status code so I can write over here status code okay I can say response do get me the body okay so I'm just going to get response body okay I can just say dot pretty print then probably I want response header or something I'm just going to say response header okay okay so I'm just going to get response header okay take this cut it and just put it a little bit up something like this okay so now even the response body will be logged whatever the response you're going to get it will be logged in this test log file so if I just scroll down this is how it looks first I'm logging the request okay then you are going to get the response you're going to log the response and finally just return the response because you have to return response back now so just return the response back for further assertion so response return it's going to be taken to the test for assertion okay that's something that you need to write it off done finish look at this piece of code over here for a moment okay so over here why logging filter is created that is more important you have created the logging filter so that you can capture the request payload as well as the response is this part clear to everyone what is filter going to do it is going to do the interception it is going to intercept your request so that it you can log the request information as well as you can log the response information in your logs okay not only just in logs even in your HTML files and all you have to do it this way itself okay so logging filter is going to implement the filter here you are going to create the log okay then you're going to have the filter method coming into picture make sure that you are creating two methods called log request and log response and you I just going to print the log information over here is this part clear to everyone are we on the same page this is very important done now how do I use it into my test scripts okay basically filters are something that you need to set up to the base service so you're going to go to the base service where we are using rest is short you're going to say rest assured dot filter you have to attach a filter over here so you will create the object of logging filter done now this setup needs to be done only once once your program get executed you don't need need to do it again and again I don't want to put it inside the Constructor because if I'm going to do the parallel execution Constructor call but I want this particular execution to happen only once is there a Java entity that can help me execute this code block only once yes or no is there a Java entity is there a Java concept that can execute this code block only once static block right so if you're going to make something in a put something in a static block it will be executed only once all right and it is going to be available for everyone you're done filters are introduced in your project so if everything works correctly the way we are expecting if I click on the play button okay if I go to the test log is this part clear to everyone okay I'm able to see the entire stuff the way we wanted clear this is the payload this is the status code everything whatever you wanted okay this is important okay now we have introduced the final stuff the logging that we wanted over here now we have created a lot of things to be honest this is a this particular framework has a lot of components over there and it's doing a decent job for us the next thing that probably I want is I want to run this particular test from terminal why would I want to run this particular test from terminal what is the benefit that I'll get if you're going to run this particular project from terminal the benefit is benefit is I can easily integrate it with GitHub actions I can easily integrate it with your CI tools the main goal is to never run it from eclipse the main goal is to find a way to run it from the terminal so over there guys I will be using your special plugin which is called as your Maven Shire plugin do you remember the maven Shire plugin yes or no what exactly Maven Shire plugin is going to do so Maven Shire plugin is going to help us run the test okay from the terminal I can control the execution from Maven itself but before that I want to make sure that a test n XML file is created a suit XML file is created over here so you don't really need to byart any of the scripts over here just go to the test take this fail. XML file put it outside because it has the exact structure that we need I'm just going to change the name of the test suit name I'm going to give this as API test Suite okay and uh nothing I don't need this environment information we can remove it okay this is going to be the test name is going to be just like API test we are just executing this particular class done okay so if you're going to have respective you're going to have other classes you can just arrange it over here you know how exactly testing gxml file works all right so this is something that we have created and kept I'm going to save it over here something is missing yeah yes yeah save it was it a difficult thing you you know right how exactly this file gets created right so I'm going to right click over here I'm going to right click rename this particular file and I'm just going to call this as suit. XML file done clear everyone now go to the pom.xml file and over here we will be introducing a plugin in the build section create a build tag inside the build tag you're going to have plugins okay and we will be introducing your Maven sh fire plug-in so scroll down take this Maven sh fire plugin just copy this entire stuff copy paste it off change the path okay save it okay now the thing is I have parameterized it dollar suite. XML file this is what I'm writing over here meaning I have to pass the file name I have to pass the file name from the terminal if you write over here directly site. XML file it is going to run this chap only but I know that there might be a scenario I will have multiple XML files I will create one for regression one for smoke one for sanity okay or one for e2e something like that I can do it off so that time guys I want to pass the file name from the terminal so this is something that we have created okay now now there is one more extra thing that we are supposed to do we are using Java version 11 right we are using Java version 11 so what you do in this scenario is you also add the compiler version that is going to be important so I'm just going to take something called the maven compiler version this is just so that you're telling Maven that your project needs to be compiled against a specific version of java okay so here if I write 1.8 it basically means Java 8 is this part making sense to everyone yes or no perfect can I go ahead Yep this is something mandatory you have to put it off okay don't mug up code you need these things in the setup all right save this particular stuff and you're done the project is ready now if I just minimize this chap right click over here to your project go to show in system Explorer uh just going to say kit bash here and over here how do you execute this project Maven lean test hyph D what was the variable name over here this is the variable name dollar sweet not sweet is the name of the variable name so I'm going to say equal to Sweet because my file name over here is sweet. XML so just hit enter I could have written hyphen X yep exactly the same are you getting the point I did not change anything what we have done in tell it exactly the same I have configured it for you guys is this part clear to everyone how to pass environment from command prompt for that also you can you need to create property files and all those things I've already covered it off in the tell it part so you can really watch that particular stuff it will be much more easier so you have to create property files and even that property files I need to configure it over here that I'll be getting those parameters and from the parameters it is going to go to the XML file it's going to take a little bit time to set up that's the reason I'm telling you to watch it from The Tell it one it will be easier okay but this it's going to be exactly the same like if I'm writing it over here okay if I clean this particular stuff or you know like I just run the stuff I'm passing one parameter called Suite okay that's the name of my file so I can have another parameter called environment and I can give over here QA right so there should be a a way to handle it off on my framework okay that I have already covered it off in the T now this is done okay now it's the time to push this particular project in your GitHub so the first thing I'm going to do is I'm going to convert it into your git repository so I'm going to say share project create the repository finish now over here guys don't jump into committing all these things in one sh right we have created a lot of things and some of these things are not mandatory over here what is not mandatory or what is not something that you want to commit anything that is autogenerated am I generating test out have I written test hyphen output PR is is this particular stuff created by me or is it autogenerated Auto generated so something which is autogenerated you will always ignore next Target folder I have not done anything for this chap so I'm going to right click go to Team ignore you see number of files are getting reduced now then logs we did not create the logs I have written the code but this is autogenerated team ignore and we are done we have created 20 six files okay I'm going to bring all the files into the staging area and I'm going to say this is my base code then I'm going to say commit now we going to go to your git Hub we are going to quickly create a new repository I'm going to call this as demo API automation framework copy this put it here also I'm just going to make it as a public repository create a repository over here uh copy this particular stuff copy the remote repository URL push it done okay so if I close it go back over here refresh it the code is here is this part clear to everyone is this part clear to everyone are we on the same page guys everyone now suppose if this was an interview question will I just stop over here the answer is no you have to make sure that you integrate it with the CI tool also so I'm just going to go with GitHub actions over here I'm going to go to GitHub actions this is a Java based project okay there are lot of uh stuff that I can easily search for the workflow for related to Java or Maven okay but I feel I can easily do the initial setup but if you want you can just search for Java Maven hit enter okay and uh you're going to go with something which is called as Java with mavin and it basically gives you the basic setup things which you require over here for execution we can we'll use this only and I'll modify changes over here I'm going to say Comm at this changes or not right now we'll modify it off first let's remove these things okay and uh the first thing I'm going to give over here is the name I'm going to call this as API testing let's say API test framework next we are going to set up Java 11 this is going to check out the code this step is going to check out your code this step is going to set up Java Java L uh so jdk 11 I've written over here and just change 17 to 11 and over here rest of the stuff is fine this is where you will be writing your command so I'm just going to say execute test and I'll write the command over here Maven clean test hin um D sweet equal to the sweet and just give hyphen X remove these things this is optional is this part clear to everyone just click on Commit changes okay commit It Off and I'll just wait for this particular stuff to get started okay if I go to actions it's getting executed does it look fam C I've executed a test from your ci2 clear the basic setup basic bare minimum setup that I've done over here okay just changed couple of things and it is running okay but if I want to take it little bit further you know if you have a lot of other options coming into picture that is something that we can do now once I have this particular y uh Maven yl file created I want to let's say make few changes over here so that we can set up the crw I want to run the test on a certain time span or uh you know like I want to Archive reports and all those things we will do now so on the poll request the next thing that I want over here is to have something called as a schedule okay and I will have a cron coming into picture so the cron will look the cron format if you remember is um the five star I I want to run the test at 11:30 p.m. IST okay so if I want to run the test 11:30 p.m. IST the scheduler is always going to look at what what time which time is going to be taken into consideration yes which time it takes over here UTC time the time which you always give is going to be the UTC time so you have to make sure that you do UTC to IST converter okay so just give me a moment so just go to Google and search for UT C2 IST converter okay and over here you know you just give let's say I want to run it at 11:30 p.m. so if I my goal is to Lear run it at 11:30 p.m. it should be executed at 6 p.m. that is 180 okay so this particular stuff I'm using it as a reference and over here what I can do is I just need to make just a small change this particular cro okay you are supposed to give the time in 11:30 uh sorry 6:00 p.m. so over here go come back over just change it and I'm just going to say 6 p.m. so 00 18 and I want to run every single day every single month every single day so this first star is going to signify your month then it is going to signify the date then it is going to signify the day okay just bringing my cursor over here so it is going to run every single day at 6: p.m. UTC that is going to become 11:30 p.m. for me is this part clear to everyone yeah is this part clear I can also set up multiple crons based on my requirement I can have one more field like this and just going to search for let's say I want to so run my test let's say around 8:30 a.m. so I have to make it 3:00 a.m. so just make it 3:00 a.m. done now this is going to run at 3 a.m. for me that 3 a.m. is eventually going to be how much 8:30 a.m. for me so before my day start my test will be executed okay the next thing that I want to do is I want to Archive the reports we have done it a lot of time for the upload build artifacts and all so you can just go to this upload build artifacts okay this is the extension or this is the action that you're supposed to use and um it's pretty simple you just give the name upload build artifact then it is going to uses this action copy this okay it's going to use this action the next thing that the indentation is important so just make sure the indentation is proper and over here the width you have to specify with artifact I'm just going to call this as name okay just going to give a little bit space and this is going to be um logs okay and where will I find the logs so you are supposed to give the path okay so over here the default of file path okay and the final thing that I'm supposed to give is the path over here yeah path so it should be path colon we will find the logs in the logs folder so this logs folder folder is already at the root level so just put logs and you're done clear so it is going to Archive the logs for us now I can just commit the changes let's see whether it works the moment you make a change your action is automatically going to be executed okay so if I'm running it again one more time okay so it says upload a build artifact it has done so if I just go back to the framework okay and refresh it here you see the logs file if I download it file got downloaded I can open it this is a test log I will be able to see the logs also is this part clear to everyone are we on the same page people in the call everyone are you on the same page over here okay done no not really in this one I'm not going to use it okay now once uh this is done the next thing that I want is I want to have the extension or I want to use an action which is going to just publish the test reports so you can directly take this particular test report guys uh don't need to worry about anything else there's another act action which is called by dney test hyphen reporter so it is going to look for an XML file but the thing is it only looks for junit reports okay luckily when you use the maven Shire plugin in the test hyphen output folder you find this junit report okay and over here we are interested in reading this test hyphen all these XML files we want to read all these XML files over there okay so so what you can do now is you can just copy this entire plug-in sorry ex action my bad and uh now let's come back over here to actions let's edit it one more time and let's introduce this chap also okay done so over here guys one more important thing even in for your build artifact make sure even if my test is passing or my test is failing you want to make sure that the reports are getting archived or the logs are getting archived so make sure you use if always here also as well as Z also it is going to search for the junit reports okay anything that is going to start with test word you see the name can be different test hyen com. API test account creation forgot password get profile password test so the name can be anything but it should start with the word test with capital that's what I've written over here and one more thing that you want to give over here is the permission so if I come back over up you have to give the permission to read check and U you know like write the issues and all those things so I'm just going to copy this permission just take this part and you introduce it in the after the run on Section okay after the run on you just introduce this Chap and you're done okay okay so what is going to be happening it's it will be able to write all those information on your dashboard so just click on Commit the changes let's save it let's click on details it has published the test result you can see this test NG result section I click over here taada done all right this is something and this is how you're supposed to submit your assignment okay so people who have solved the crisp assignment or you have solved the um Phoenix assignment or if you're doing this assignment also make sure you submit or uh whenever an interview comes into picture they tell you to write API test or they tell you to create an API automation framework you have to do till year and submit it off is this part making sense to everyone this this one is a little bit tricky for sure I mean like because I'm pretty sure you're doing it for the first time okay so I don't expect you guys to know it in one shot like if you look at the previous lecture that has happened it was like we have seen Java Concepts you might be aware of little bit of rest short scripts and all but this really takes it to a little bit bigger level little bit advanced stuff okay but I promise you if you put like two three attempts in doing these things you're done that's the reason I said like you need to be sure that you have solved the Tet assignment people who have solved the T it assignments the only difference over here is of like around 10 15% rest all the stuff was same did I use Shire plug-in over there yes did I integrate it with grub action yes did I use the listener yes did I use the logger yes the only difference that has happened over there is of the filter makes sense to everyone apart from that everything else was same okay that's it not for now bu I have to plan it something on that it will be available on the LMS I don't think I'll be able to take it in the live sessions okay I'll put it off somewhere on the LMS okay so please study from the LMS people who haven't studying it over there uh it should be running over there I don't know which build number is this this build number is three right okay so generally what happens is since it's a free free one right so it should be executing between 11:35 okay or 11:25 they try to you know like give you the 11 not exactly on the 11:30 it will execute I'll get a message in sometime okay that the build was executed at all okay I'll have to wait you can keep a track over here on this one okay it was executed 4 minutes ago that was because of us only but we'll just have to wait okay how to send automation execution reports on email uh when you use GitHub action you can definitely get the access or notifications directly to whoever have the access to the repository okay so if you give the access to the repository they will get the notifications okay so over there it can work but I think there will be some kind of an extension or an action available for that but then again you need to do the setup of MTP you need to give the creds and all so that's will be a different stuff okay but over here if you give the access to the repository it will you will get the notifications any other questions guys I'll give you the permission to unmute for Jenkins as in what you can ask the question like if you want to do the execution in Jenkins the command will be same there's nothing fancy it's going to change over there in Jenkins you will use you will do exactly same okay you're going to create a freestyle project and you have to just use the command which we have used over there that is this command okay just use this command it will work okay this is something that I was just showing you but this is something that you need to use provided you need to have Maven and Java installed on your server jenin server okay only then you will be able to execute it but looking at the current trends which are happening people might migrate or people have already started migrating from your Jenkins to GitHub actions because it takes away the lot of headache of yours you know like to take care of these executions and all you know like the setup okay I can do everything directly on this uh repository level okay the same is with your GitHub gitlab Runner also okay next question guys any other questions so so jatin uh so are you including this payload creation that complex Json or nested Json and all so because uh that that Jason is only simple which one this one we never really created login response we never really passed the pord if you remember if you look at the screen created that pojo classes for that yeah so we did the same for the response right if you go to close all let me just close this that is for the simple uh request um no not really I'll show you this one the response okay this is for the user profile response but if you were having a nesting also you can just keep on continuing it and creating different pojo objects it's still going to work over there okay the goal is to create understand how to create the pojo classes that's it done okay so in this I'm not able to see the sign up request and all I think so it was just for the one level but if you're going to have multiple levels also you just need to create uh the composition layers coming into picture so nothing great changes off over there you give me a complex Json we can easily create it off over there okay and are you covering that how to because in the API testing data is important so how to get a data from the database you need to use the jdpc connectivity that time okay you will find that part on the LMS right now if you go to the Java part right like post the last lectures of java which I'm aware of they will release is going to be on the jdbc okay it's never about see the thing is when you look at a framework perspective you are looking at from that I need to read the data from database or I want to read the data from Excel I want to read the data from different sources I want to generate the data that is from the testing perspective you're looking it for but eventually you're talking something which needs to be a feature in Java or you want to create a functionality in Java over there so when you're looking it from a database reading data from the database is not the problem how you're going to connect to the database how you're going to create the data access objects okay if you're able to create those things quickly then your job is done and then you have to again do the mapping because if I'm going to read the data from the database I need to map it to the pojo class okay yeah and then that pojo class will be passed to the API request make sense yeah that is something that we'll eventually need to do it off okay that stuff I'll probably try to keep it in the LMS itself okay but it will be there for sure yeah if you add if you will add that is useful for me I do it off over there even for the complex seon see like U I don't have any like right now I I don't see any major payloads over here but the thing is if you have a complex Json or you know like something you want to convert it into pojo you can share it off to me I'll create I'll show you how to create it off over there that's not a big because see right now everything was string okay if tomorrow let's say they say that mobile number is going to have multiple mobile numbers like an array would be there so I have to make sure that this becomes a list okay a list will be created over here okay or mobile number is going to have another Json object inside it then again I have to create another Json object out of it okay I think I have discussed on that part but no problem I'll create it again okay thank you any other questions folks okay any other questions I'm still waiting for this particular chap to run but it's still not waiting for some reason okay yeah abishek Akash all clear other folks any doubts okay so we can stop for today this is something uh you need to practice this part okay I can't uh do anything on this part but it will take time make sure you do it off pretty well you you guys have the notes everyone is the notes available with you all yeah yeah make sure you practice It Off from there okay so that's that's wraps it up for us uh one lecture was remaining about the report creation I mean like if I'm able to create the logs obviously reports will be there right you want the extend report to come into uh I want to take the report section tomorrow but it will require you guys to you know have a little bit Clarity on extent report working and all because that time you need to have U you need to understand thread locals and all those things and those things are already covered pretty well in the uh tell it one so that's the reason and you know like I was behind every one of you guys complete the Tet assignment because if you do that part you'll understand the entire ecosystem in a much more better way okay so please make sure you complete that one once it is done then probably I'll think of you know like taking the extent report and all or I'll upload it off directly on the uh like in your classroom recordings and all you'll find it over there ah whoever who was there um Akil the test started to execute right now see so that's something that has happened and um um make sure you practice this much generating report will not be the main thing but uh main issue as such but if you are comfortable um only with the tell it then watch it off else it's going to be a pure bouncer you'll be like just attending the class literally understanding nothing out of it I want to take it off buddy but the thing is key if I take it off then again people will say that it's going to go bouncer so okay so I don't want to do that part you already have the access to the LMS and the first thing that you should do is complete the tell it one I've been telling people to complete it part as soon as possible so that's the reason okay I have already implemented it off it's it's already kept over here at my end if you see somewhere uh like the SRC mean Java yeah the reporting is already created and kept over here now the only thing that comes into picture is if I start introducing all these things okay it's not something that it should go bouncer okay it's like and it's a onetime activity if you want I can give you the code right away you can take it in your chat box and keep it okay but the point is if if lecture needs to happen people need to understand that part else it's going to go little bit bouncer itself I'll do one thing this is the main project right I'll give it to you show in so J it's a covered in this extent manager me this report how to attach this header and authorization and response and all in the report yep okay go good because I know what happen generally happens right is see if you go to the report I'll show that part at least we can discuss about it the show in can you see the output yeah okay so how exactly the response needs to look what will be the response and all those things have kept it off over there when the test is passing and all those things are there this is something that generally you want to have it in the API API reports and all yes okay so you can take this particular framework okay I'll give you this part itself uh show in yeah done I put it in the download section or like attach in the chat guys people can download this one this is the entire framework for the rest is short it has the logger it has um everything the only the structure is a little bit different over there I was just practicing certain things so even if you want to practice at off just remember one thing I have kept these things in SRC main Java n the only difference is my test only the test is there in the p. API test okay SRC main Java has the other things I have the API filter also this is the same filter I created today for you okay and this is the only difference that's it okay nothing fancy as such all right we'll stop over here for today guys uh this I believe uh ends the group session for you guys okay I hope you have understood how exactly this particular stuff is created uh hope you like the session was it useful for you guys I don't know was it useful people who have seen this particular stuff whatever Affiliated so far yes yes yeah okay so I hope you will be able to answer all the interview related questions uh related to your API automation framework so the lecture will be available uh I think so by tomorrow itself and um the next thing over here guys is practice this particular stuff and the second thing that comes over here guys is whether um two assignments if you want to prepare for interviews tell it Carlo and the one which I've covered over here I mean like the better quality I wanted to Pro release it of in this year this month itself but it's not going to happen so I thought why when it's ready I'll just take it in the group session you will be able to answer most of the stuff okay okay that's something that's the reason I created that how to do masking masking uh because yeah it's required we have to mask that authorization part authorization part if you want to mask it off as in you want to hide it off in the reports that's what you're asking uh either hide from testing also our report also yeah masking how to do the mask give me a scenario over here give me me uh they don't want uh that uh username and password and all uh o token they don't want to uh they don't want to see it they don't want to see it in the report right if they don't want to see it in the report that's where you have your filters coming into picture Avid so when I'm setting the extend manager report if you see carefully I'm controlling it everything what exactly the things needs to be there so when you're getting a header right I will just put the values as Hash Hash Hash and then I'm going to continue it off so even if I want to make any changes I have to do it over here okay for the uh reports and as well as for the logs okay the same thing masking okay but I it will be covered I'll put it off in the LMS remember it okay but if I want I'll modify the script and give it to you yeah thank you uh any other questions okay yes guys any other questions so this wraps up your entire API Journey for the entire framework that we wanted to build three scenarios as I remember one is the jdbc connectivity which you want masking reporting I have already shown you any other any other requirement you guys can reach it off to me I'll plan it off like if I can put it in the stuff now before I end because I don't get time to you know usually connect I'm I'm changing few things here and there but I hope you know like I'm able to get that time so uh the thing is uh I have wrapped up as I said for the rest short like for the Java modules most possibly the team will release few important lectures for you guys uh this month itself so if you are starting let's say okay or you want to even prepare for the interviews also something like that just start with the concept of classes and objects okay and I I think it is one of the best stuff you'll find it anywhere because every design pattern because even if you have used the Builder design pattern in your rest ass short I have first showed you in your Java itself how it will be coming into picture Okay so till abstract classes I believe the team has released it off okay we have seen marking the particular class as abstract class your um you know like abstract method coming into picture so those things will be there uh couple of lectures which will be released this week is going to be of interfaces and exception handling okay these two things I have planned for this week okay the future lectures will be your generics Collections and mapping coming into PCT maps maps coming into picture the entire Java module is going to end on the Journey of logger as well as your Java database connectivity that time uh sujit I will be creating a scenario where I will read the data from the database and I will put it into a Java object yeah yeah any other questions so if you wish you I will suggest you guys to study it from you okay if you want to really make sure that your Java fundas and all those things are clear that's something that I've kept it over there yeah any anything else people want to add or say please ask Le or what like people I know it's 12 but all good ride anjum shda snu joining after a long time okay yeah I'll revise you once okay not able to unmute I've given permission do one okay bat all good yeah okay cool guys okay all right guys so we'll probably stop for today now um tomorrow I believe uh we won't be connecting okay I will be ending this particular Journey over here with logs okay but uh the future Journey I'll put it on the LMS okay it will be there the event man extend report as well as as you said masking and all I'll try to create two three rough scenarios and give it to you if you guys have any requirement particularly for your framework for your stuff feel free to put it out over there because what happens is when you try to create a framework okay multiple scenarios database like you want to read data from the database and you want to pass it to the payload right um report generation when I started the class I said the various enhancement that you have done in your framework these are the things that you can easily remember just because it is not happening in your project doesn't mean that you should not be aware of it okay so okay this is something that is there and now I believe um if you have studied if you have studied uh so far with me the entire API automation framework and the conditional apply the tell it framework you are ready for the interviews I mean like just practice it one two more times or start by interview so when January happens you start giving the interviews whether it is going to be good bad ugly we'll we'll see it together okay we'll figure it out how to make it a little bit better over there all right so that's all from my end okay