Thursday, 23 November 2023

Constructor in JAVA for QAE - SDET - SDE ?

 Constructor is a special member function, these are used to initialize the values of objects. When we create an object using the new() keyword atleast one constructor will be executed to assign initial values to that object.

Examplepublic class Example {

	int a;
	public Example () {
		a = 10;
	}
	public static void main (String[] args) {
		Example ob = new Example();
		System.out.println(ob.a); //prints 10
	}
}

Rules for creating a constructor

  • Constructors of a class must have same name as the class in which it is created
  • Constructor in java cannot be abstract, final and static.
  • Constructors don't have a return type.

Types of constructors

There are 2 types of constructors in java

  • Default constructor
  • Parameterized constructor

1. Default constructor

  • It has 0 parameters
  • If we don't create a constructor then the compiler itself creates a default constructor
  • If we create atleast one constructor, then the compiler won't do it for us

Exampleclass Example {

	public Example () {
		System.out.println("constructor created"); // output: constructor created
	}
	public static void main (String[] args){
		Example ob = new Example ();
	}
}

2. Parameterized Constructor

  • It has more than 0 parameters
  • Used to provide different values to different objects

Example class Example {

	int a,b;
	public Example (int x, int y) {
		a = x;
		b = y;
	}
	public void add () {
		System.out.println(a+b);
	}
	public static void main (String[] args){
		Example ob = new Example (2,3); // output: 5
		ob.add();
	}
}

Constructor overloading

If we use more than 1 constructor in a class, then it is said to be constructor overloading.class Example {

	int a,b,c;
	public Example (int x) {
		a = x;
	}
	public Example (int y, int z) {
		b = y;
		c = z;
	}
	public void add () {
		System.out.println(a+b+c);
	}
	public static void main (String[] args){
		Example ob1 = new Example (20,30);
		Example ob2 = new Example (5);
		ob1.add(); 
		ob2.add(); 
	}
}
***
For E2E SDET or Automation Testing trainings along with 1:1 career guidance, mock interviews, pair programming sessions refer demo here: https://lnkd.in/giCxnJJ7
***



📗 1:1 Call on Career Guidance: https://lnkd.in/ddayTwnq

Share the scenarios in which you have used API chaining

#sidpost #apitesting #testautomation #automation #software #api #restassured #sdet #technology #qualityassurance



TOP API TESTING INTERVIEW Q&A




*****
For the Top API Testing Interview Q&A, refer the link : https://lnkd.in/drhqciDd
*****

👉 For 1:1 call in Resume & LinkedIn profile help, reach out to me : https://lnkd.in/ddayTwnq

👉 Learn more about API Status codes with examples:

https://lnkd.in/gqCmrjMW

************************************************


************************************************

Learn (API-Microservice)Testing+ Selenium UI Automation-SDET with Self Paced Videos prepared by FAANG employees and LIVE Doubt Session 

SET TRANING VIDEOS AVAILABLE with Live Doubt Session Check Training Page for Course Content or reach out @whatsapp +91-9619094122. 
This includes classnotes, 500+ interview questions, 3 projects, and a Java Coding question set for product companies along with career guidance from FAANG employees for Automation and SDET.


Course_001API Automation +
UI Automation +
Mobile Testing +
ChatGPT For Test Automation +
Jenkins-GIT-Docker
Course_002API Automation +
UI Automation +
Jenkins-GIT-Docker
Course_003API Automation +
ChatGPT for Test Automation +
Jenkins-GIT
Course_004ChatGPT for Test Automation
Course_005API Automation +
Jenkins-GIT


*******************************************************************
For any doubts or career guidance from me, reach out here: https://topmate.io/sidharth_shukla

********************************************************************

****************************************

 SDET Interview Question and Answers

TestNG Interview questions and answers

Jenkins Interview Questions and Answers

Appium Interview Questions and Answers

Selenium Interview Questions and answers

Java Coding Interview Questions and Answers

GIT Interview Questions and Answers

************************************************

*************************************************




SeleniumWebdriver Automation Testing Interview Questions:

https://automationreinvented.blogspot.com/search/label/SeleniumWebdriver

API Testing Interview Question Set:

https://automationreinvented.blogspot.com/2022/03/top-80-api-testing-interview-questions.html

DevOps Interview Q&A:

https://automationreinvented.blogspot.com/2021/11/top-11-devops-interview-questions-and.html 

Kubernetes Interview Question Set

https://automationreinvented.blogspot.com/search/label/Kubernetes

Docker Interview Question Set

https://automationreinvented.blogspot.com/Docker

Linux Interview question Set

https://automationreinvented.blogspot.com/search/label/Linux

Automation Testing/SDET Framework Design

https://automationreinvented.blogspot.com/search/label/FrameworkDesign

Java Related Interview Question Set

https://automationreinvented.blogspot.com/search/label/Java

GIT Interview Question Set:

https://automationreinvented.blogspot.com/2021/09/top-40-git-interview-questions-and.html

Coding Interview Question Set:

https://automationreinvented.blogspot.com/search/label/Coding%20Questions

Mobile Testing Interview Question Set:

https://automationreinvented.blogspot.com/search/label/Mobile%20Testing

Python Interview Question Set for QAE - SDET - SDE:

https://automationreinvented.blogspot.com/search/label/Python


#APITesting #RestAssured #TestingTips #testautomation #software #api #sdet #automation #restassured #career #technology #qualityassurance


Saturday, 4 November 2023

API Chaining with Rest Assured

 





🎾 What is API Chaining?

API chaining is a technique used in API testing to make multiple API requests in a sequence, where each request's response becomes the basis for the next request. This can be achieved using libraries like Rest Assured in Java. API chaining is often used to test scenarios that involve multiple API endpoints or dependent operations. Below is an example of API chaining using Rest Assured:

🎾 API Chaining Scenario:

Let's assume we have a simple scenario where we want to:
- Create a user.
- Retrieve the created user's details.
- Update the user's information.
- Verify the updated user's details.

🎾 API Chaining using Rest Assured


Here's how you can achieve this using Rest Assured:

public class ApiChainingExample {

private static String baseURL = "https://example.com/api"; // Replace with your API base URL

@Test
public void testApiChaining() {



How to Automate GET-POST-PUT-DELETE with Rest Assured 




🔆🔺 // Step 1: First We create a user, extract the response JSON to get the user's ID.


String createUserResponse =
RestAssured.given()
.contentType(ContentType.JSON)
.body("{ \"name\": \"John\", \"email\": \"john@example.com\" }")
.when()
.post(baseURL + "/users")
.then()
.statusCode(201)
.extract()
.response()
.asString();


🔆🔺 // Step 2: Then We use the extracted user ID to retrieve the user's details.


String userId = RestAssured
.given()
.when()
.get(baseURL + "/users/{userId}", createUserResponse)
.then()
.statusCode(200)
.extract()
.path("id");


🔆🔺 // Step 3: Update the user's information

RestAssured.given()
.contentType(ContentType.JSON)
.body("{ \"name\": \"Updated John\", \"email\": \"updated_john@example.com\" }")
.when()
.put(baseURL + "/users/{userId}", userId)
.then()
.statusCode(200);



🔆🔺 // Step 4: Verify the updated user's details

RestAssured.given()
.when()
.get(baseURL + "/users/{userId}", userId)
.then()
.statusCode(200)
.assertThat()
.body("name", equalTo("Updated John"))
.body("email", equalTo("updated_john@example.com"));
}
}

This is a basic example of API chaining using Rest Assured. In real-world scenarios, API chaining can involve more complex operations and data handling.

***
For E2E SDET or Automation Testing trainings along with 1:1 career guidance, mock interviews, pair programming sessions refer demo here: https://lnkd.in/giCxnJJ7
***



📗 1:1 Call on Career Guidance: https://lnkd.in/ddayTwnq

Share the scenarios in which you have used API chaining

#sidpost #apitesting #testautomation #automation #software #api #restassured #sdet #technology #qualityassurance



TOP API TESTING INTERVIEW Q&A




*****
For the Top API Testing Interview Q&A, refer the link : https://lnkd.in/drhqciDd
*****

👉 For 1:1 call in Resume & LinkedIn profile help, reach out to me : https://lnkd.in/ddayTwnq

👉 Learn more about API Status codes with examples:

https://lnkd.in/gqCmrjMW

************************************************


************************************************

Learn (API-Microservice)Testing+ Selenium UI Automation-SDET with Self Paced Videos prepared by FAANG employees and LIVE Doubt Session 

SET TRANING VIDEOS AVAILABLE with Live Doubt Session Check Training Page for Course Content or reach out @whatsapp +91-9619094122. 
This includes classnotes, 500+ interview questions, 3 projects, and a Java Coding question set for product companies along with career guidance from FAANG employees for Automation and SDET.


Course_001API Automation +
UI Automation +
Mobile Testing +
ChatGPT For Test Automation +
Jenkins-GIT-Docker
Course_002API Automation +
UI Automation +
Jenkins-GIT-Docker
Course_003API Automation +
ChatGPT for Test Automation +
Jenkins-GIT
Course_004ChatGPT for Test Automation
Course_005API Automation +
Jenkins-GIT


*******************************************************************
For any doubts or career guidance from me, reach out here: https://topmate.io/sidharth_shukla

********************************************************************

****************************************

 SDET Interview Question and Answers

TestNG Interview questions and answers

Jenkins Interview Questions and Answers

Appium Interview Questions and Answers

Selenium Interview Questions and answers

Java Coding Interview Questions and Answers

GIT Interview Questions and Answers

************************************************

*************************************************




SeleniumWebdriver Automation Testing Interview Questions:

https://automationreinvented.blogspot.com/search/label/SeleniumWebdriver

API Testing Interview Question Set:

https://automationreinvented.blogspot.com/2022/03/top-80-api-testing-interview-questions.html

DevOps Interview Q&A:

https://automationreinvented.blogspot.com/2021/11/top-11-devops-interview-questions-and.html 

Kubernetes Interview Question Set

https://automationreinvented.blogspot.com/search/label/Kubernetes

Docker Interview Question Set

https://automationreinvented.blogspot.com/Docker

Linux Interview question Set

https://automationreinvented.blogspot.com/search/label/Linux

Automation Testing/SDET Framework Design

https://automationreinvented.blogspot.com/search/label/FrameworkDesign

Java Related Interview Question Set

https://automationreinvented.blogspot.com/search/label/Java

GIT Interview Question Set:

https://automationreinvented.blogspot.com/2021/09/top-40-git-interview-questions-and.html

Coding Interview Question Set:

https://automationreinvented.blogspot.com/search/label/Coding%20Questions

Mobile Testing Interview Question Set:

https://automationreinvented.blogspot.com/search/label/Mobile%20Testing

Python Interview Question Set for QAE - SDET - SDE:

https://automationreinvented.blogspot.com/search/label/Python


#APITesting #RestAssured #TestingTips #testautomation #software #api #sdet #automation #restassured #career #technology #qualityassurance


All Time Popular Posts

Most Featured Post

Introduction to Web Testing with Playwright

  Introduction to Web Testing with Playwright 📌  Telegram Group:  https://t.me/+FTf_NPb--GQ2ODhl 📌  YouTube channel:  https://lnkd.in/gGUG...