xxxxxxxxxx
given() . --> RequestSpecification
.header accept() contentType()
.queryParam
.pathParam
.body
.log
.auth..
when() --->> RequestSender
.get() ------>> Response Object
.post()
.put()
.delete()
then() -----> ValidatableResponse
This is where assertion happen
.statusCode
.header accept() contentType()
.body( matchers goes here)
.log
xxxxxxxxxx
public class Student {
private String name;
private int age;
private String address;
public Student setName(String name) {
this.name = name;
return this; // Return the object itself
}
public Student setAge(int age) {
this.age = age;
return this; // Return the object itself
}
public Student setAddress(String address) {
this.address = address;
return this; // Return the object itself
}
public void displayInfo() {
System.out.println("Name: " + name);
System.out.println("Age: " + age);
System.out.println("Address: " + address);
}
public static void main(String[] args) {
Student student = new Student()
.setName("John")
.setAge(20)
.setAddress("123 Main St");
student.displayInfo();
}
}
xxxxxxxxxx
class Arithmetic {
constructor() {
this.value = 0;
}
sum(args) {
this.value = args.reduce((sum, current) => sum + current, 0);
return this;
}
add(value) {
this.value = this.value + value;
return this;
}
subtract(value) {
this.value = this.value - value;
return this;
}
average(args) {
this.value = args.length
? (this.sum(args).value) / args.length
: undefined;
return this;
}
}
a = new Arithmetic()
a.sum(1, 3, 6) // => { value: 10 }
.subtract(3) // => { value: 7 }
.add(4) // => { value: 11 }
.value // => 11
// Console Output
// 11
xxxxxxxxxx
const user = new Twita("Adeleye", true);
user.login().setOnlineStatus().logout().setOfflineStatus();
xxxxxxxxxx
String methods can be combined in a process called method chaining.
Given word = 'JavaScript';, word.toUpperCase() returns JAVASCRIPT.
What would word.slice(4).toUpperCase() return?