-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseApiTest.java
More file actions
43 lines (39 loc) · 1.75 KB
/
BaseApiTest.java
File metadata and controls
43 lines (39 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package com.learning.api.tests.base;
import com.learning.api.framework.client.RestfulBookerClient;
import com.learning.api.framework.config.ConfigReader;
import com.learning.api.framework.config.FrameworkConfig;
import com.learning.api.framework.http.RequestSpecFactory;
import com.learning.api.framework.service.BookingService;
import io.restassured.specification.RequestSpecification;
import org.testng.annotations.BeforeClass;
/**
* Base class for framework-style API tests.
*
* <p>Learning modules kept setup inside each test class. Module 11 introduces a
* base class so framework tests can share config and request specifications
* without duplicating setup in every test.</p>
*/
public abstract class BaseApiTest {
protected FrameworkConfig config;
protected RequestSpecification restfulBookerSpec;
protected RestfulBookerClient restfulBookerClient;
protected BookingService bookingService;
@BeforeClass
public void loadFrameworkConfiguration() {
config = ConfigReader.load();
restfulBookerSpec = RequestSpecFactory.restfulBooker(config);
/*
* Module 12 adds the API client after Module 11 created the reusable
* request specification. Every framework-style Restful Booker test now
* receives the same client object and can focus on test intent instead
* of rebuilding endpoint paths and HTTP method calls.
*/
restfulBookerClient = new RestfulBookerClient(restfulBookerSpec);
/*
* The service sits one level above the client. It gives tests
* booking-focused method names while still returning Rest Assured
* Response objects for learner-visible assertions.
*/
bookingService = new BookingService(restfulBookerClient);
}
}