Skip to content

Commit 3db1fa4

Browse files
updated dependencies and formatted code (#16)
* updated dependencies and formatted code * updated javajdk version to 17 in maven.yml
1 parent 01e5f97 commit 3db1fa4

File tree

12 files changed

+119
-118
lines changed

12 files changed

+119
-118
lines changed

.github/workflows/maven.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ jobs:
2727

2828
steps:
2929
- uses: actions/checkout@v3
30-
- name: Set up JDK 11
30+
- name: Set up JDK 17
3131
uses: actions/setup-java@v3
3232
with:
33-
java-version: '11'
33+
java-version: '17'
3434
distribution: 'temurin'
3535
cache: maven
3636

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@
99
/.idea/
1010
/allure-results/
1111
/allure-report/
12-
/.allure/
12+
/.allure/
13+
/.DS_Store
14+
/*.iml

pom.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@
1212

1313
<properties>
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15-
<playwright-version>1.31.0</playwright-version>
16-
<testng-version>7.7.1</testng-version>
15+
<playwright-version>1.37.0</playwright-version>
16+
<testng-version>7.8.0</testng-version>
1717
<hamcrest-all-version>1.3</hamcrest-all-version>
1818
<json-simple-version>1.1.1</json-simple-version>
19-
<lombok-version>1.18.26</lombok-version>
20-
<datafaker-version>1.8.0</datafaker-version>
21-
<maven-compiler-plugin-version>3.10.1</maven-compiler-plugin-version>
22-
<maven-surefire-plugin-version>3.0.0-M7</maven-surefire-plugin-version>
23-
<java-release-version>11</java-release-version>
24-
<org-json-verion>20230227</org-json-verion>
19+
<lombok-version>1.18.28</lombok-version>
20+
<datafaker-version>2.0.1</datafaker-version>
21+
<org-json-verion>20230618</org-json-verion>
22+
<maven-compiler-plugin-version>3.11.0</maven-compiler-plugin-version>
23+
<maven-surefire-plugin-version>3.1.0</maven-surefire-plugin-version>
24+
<java-release-version>17</java-release-version>
25+
<maven-enforcer-version>3.4.0</maven-enforcer-version>
2526
<suite-xml>test-suite/testng.xml</suite-xml>
2627
</properties>
2728
<dependencies>
@@ -88,7 +89,7 @@
8889
<plugin>
8990
<groupId>org.apache.maven.plugins</groupId>
9091
<artifactId>maven-enforcer-plugin</artifactId>
91-
<version>3.1.0</version>
92+
<version>${maven-enforcer-version}</version>
9293
<executions>
9394
<execution>
9495
<id>enforce-maven</id>
@@ -108,5 +109,4 @@
108109
</plugins>
109110
</pluginManagement>
110111
</build>
111-
112112
</project>
Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package io.github.mfaisalkhatri.api.manager;
22

3-
import java.util.Map;
4-
53
import com.microsoft.playwright.APIRequest;
64
import com.microsoft.playwright.APIRequestContext;
75
import com.microsoft.playwright.APIResponse;
86
import com.microsoft.playwright.Playwright;
97
import com.microsoft.playwright.options.RequestOptions;
108

9+
import java.util.Map;
10+
1111
/**
1212
* @author Faisal Khatri
1313
* @since 2/28/2023
@@ -18,63 +18,63 @@ public class RequestManager {
1818
private APIRequestContext apiRequestContext;
1919

2020
public void createPlaywright() {
21-
playwright = Playwright.create();
21+
this.playwright = Playwright.create();
2222

2323
}
2424

25-
public void setApiRequestContext(String baseUrl, Map<String, String> headers) {
26-
apiRequestContext = playwright.request()
25+
public void setApiRequestContext(final String baseUrl, final Map<String, String> headers) {
26+
this.apiRequestContext = this.playwright.request()
2727
.newContext(new APIRequest.NewContextOptions().setBaseURL(baseUrl)
2828
.setExtraHTTPHeaders(headers));
2929
}
3030

31-
public APIResponse getRequest(String endpoint) {
32-
return apiRequestContext.get(endpoint);
31+
public APIResponse getRequest(final String endpoint) {
32+
return this.apiRequestContext.get(endpoint);
3333
}
3434

35-
public APIResponse getRequest(String endpoint, RequestOptions options) {
36-
return apiRequestContext.get(endpoint, options);
35+
public APIResponse getRequest(final String endpoint, final RequestOptions options) {
36+
return this.apiRequestContext.get(endpoint, options);
3737
}
3838

39-
public APIResponse postRequest(String endpoint) {
40-
return apiRequestContext.post(endpoint);
39+
public APIResponse postRequest(final String endpoint) {
40+
return this.apiRequestContext.post(endpoint);
4141
}
4242

43-
public APIResponse postRequest(String endpoint, RequestOptions options) {
44-
return apiRequestContext.post(endpoint, options);
43+
public APIResponse postRequest(final String endpoint, final RequestOptions options) {
44+
return this.apiRequestContext.post(endpoint, options);
4545
}
4646

47-
public APIResponse putRequest(String endpoint) {
48-
return apiRequestContext.put(endpoint);
47+
public APIResponse putRequest(final String endpoint) {
48+
return this.apiRequestContext.put(endpoint);
4949
}
5050

51-
public APIResponse putRequest(String endpoint, RequestOptions options) {
52-
return apiRequestContext.put(endpoint, options);
51+
public APIResponse putRequest(final String endpoint, final RequestOptions options) {
52+
return this.apiRequestContext.put(endpoint, options);
5353
}
5454

55-
public APIResponse patchRequest(String endpoint) {
56-
return apiRequestContext.patch(endpoint);
55+
public APIResponse patchRequest(final String endpoint) {
56+
return this.apiRequestContext.patch(endpoint);
5757
}
5858

59-
public APIResponse patchRequest(String endpoint, RequestOptions options) {
60-
return apiRequestContext.patch(endpoint, options);
59+
public APIResponse patchRequest(final String endpoint, final RequestOptions options) {
60+
return this.apiRequestContext.patch(endpoint, options);
6161

6262
}
6363

64-
public APIResponse deleteRequest(String endpoint) {
65-
return apiRequestContext.delete(endpoint);
64+
public APIResponse deleteRequest(final String endpoint) {
65+
return this.apiRequestContext.delete(endpoint);
6666
}
6767

68-
public APIResponse deleteRequest(String endpoint, RequestOptions options) {
69-
return apiRequestContext.delete(endpoint, options);
68+
public APIResponse deleteRequest(final String endpoint, final RequestOptions options) {
69+
return this.apiRequestContext.delete(endpoint, options);
7070
}
7171

7272
public void disposeAPIRequestContext() {
73-
apiRequestContext.dispose();
73+
this.apiRequestContext.dispose();
7474
}
7575

7676
public void closePlaywright() {
77-
playwright.close();
77+
this.playwright.close();
7878
}
7979

8080
}

src/test/java/io/github/mfaisalkhatri/api/reqres/data/EmployeeData.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import lombok.Builder;
44
import lombok.Getter;
5-
import lombok.Setter;
65

76
/**
87
* @author Faisal Khatri

src/test/java/io/github/mfaisalkhatri/api/reqres/data/EmployeeDataBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
public class EmployeeDataBuilder {
1010

1111
public static EmployeeData getEmployeeData() {
12-
Faker faker = new Faker();
12+
final Faker faker = new Faker();
1313
return EmployeeData.builder()
1414
.name(faker.name()
1515
.firstName())

src/test/java/io/github/mfaisalkhatri/api/reqres/tests/ApiTests.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
package io.github.mfaisalkhatri.api.reqres.tests;
22

3-
import static io.github.mfaisalkhatri.api.reqres.data.EmployeeDataBuilder.getEmployeeData;
4-
import static org.testng.Assert.assertEquals;
5-
import static org.testng.Assert.assertNotNull;
6-
73
import com.microsoft.playwright.APIResponse;
84
import com.microsoft.playwright.options.RequestOptions;
95
import io.github.mfaisalkhatri.api.reqres.data.EmployeeData;
106
import org.json.JSONObject;
117
import org.testng.annotations.Test;
128

9+
import static io.github.mfaisalkhatri.api.reqres.data.EmployeeDataBuilder.getEmployeeData;
10+
import static org.testng.Assert.assertEquals;
11+
import static org.testng.Assert.assertNotNull;
12+
1313
/**
1414
* @author Faisal Khatri
1515
* @since 2/28/2023
1616
**/
1717
public class ApiTests extends BaseTest {
1818
@Test
1919
public void testGetAPI() {
20-
APIResponse response = manager.getRequest("/api/users/4");
20+
final APIResponse response = this.manager.getRequest("/api/users/4");
2121
assertEquals(response.status(), 200);
2222

23-
JSONObject jsonObject = new JSONObject(response.text());
24-
JSONObject dataObject = jsonObject.getJSONObject("data");
23+
final JSONObject jsonObject = new JSONObject(response.text());
24+
final JSONObject dataObject = jsonObject.getJSONObject("data");
2525

2626
assertEquals(dataObject.get("email")
2727
.toString(), "[email protected]");
@@ -31,47 +31,47 @@ public void testGetAPI() {
3131

3232
@Test
3333
public void testPostAPI() {
34-
EmployeeData employeeData = getEmployeeData();
35-
APIResponse response = manager.postRequest("/api/users", RequestOptions.create()
34+
final EmployeeData employeeData = getEmployeeData();
35+
final APIResponse response = this.manager.postRequest("/api/users", RequestOptions.create()
3636
.setData(employeeData));
3737
assertEquals(response.status(), 201);
3838

39-
JSONObject jsonObject = new JSONObject(response.text());
39+
final JSONObject jsonObject = new JSONObject(response.text());
4040
assertNotNull(jsonObject.get("id"));
4141
assertEquals(jsonObject.get("name"), employeeData.getName());
4242
assertEquals(jsonObject.get("job"), employeeData.getJob());
4343
}
4444

4545
@Test
4646
public void testPutAPI() {
47-
EmployeeData employeeData = getEmployeeData();
48-
APIResponse response = manager.putRequest("/api/users/2", RequestOptions.create()
47+
final EmployeeData employeeData = getEmployeeData();
48+
final APIResponse response = this.manager.putRequest("/api/users/2", RequestOptions.create()
4949
.setData(employeeData));
5050
assertEquals(response.status(), 200);
5151

52-
JSONObject jsonObject = new JSONObject(response.text());
52+
final JSONObject jsonObject = new JSONObject(response.text());
5353
assertNotNull(jsonObject.get("updatedAt"));
5454
assertEquals(jsonObject.get("name"), employeeData.getName());
5555
assertEquals(jsonObject.get("job"), employeeData.getJob());
5656
}
5757

5858
@Test
5959
public void testPatchAPI() {
60-
EmployeeData employeeData = getEmployeeData();
61-
APIResponse response = manager.patchRequest("/api/users/2", RequestOptions.create()
60+
final EmployeeData employeeData = getEmployeeData();
61+
final APIResponse response = this.manager.patchRequest("/api/users/2", RequestOptions.create()
6262
.setData(employeeData));
6363
assertEquals(response.status(), 200);
6464

65-
JSONObject jsonObject = new JSONObject(response.text());
65+
final JSONObject jsonObject = new JSONObject(response.text());
6666
assertNotNull(jsonObject.get("updatedAt"));
6767
assertEquals(jsonObject.get("name"), employeeData.getName());
6868
assertEquals(jsonObject.get("job"), employeeData.getJob());
6969
}
7070

7171
@Test
7272
public void testDeleteAPI() {
73-
EmployeeData employeeData = getEmployeeData();
74-
APIResponse response = manager.deleteRequest("/api/users/2", RequestOptions.create()
73+
final EmployeeData employeeData = getEmployeeData();
74+
final APIResponse response = this.manager.deleteRequest("/api/users/2", RequestOptions.create()
7575
.setData(employeeData));
7676
assertEquals(response.status(), 204);
7777
}
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package io.github.mfaisalkhatri.api.reqres.tests;
22

3-
import java.util.HashMap;
4-
import java.util.Map;
5-
63
import io.github.mfaisalkhatri.api.manager.RequestManager;
74
import org.testng.annotations.AfterClass;
85
import org.testng.annotations.BeforeClass;
96

7+
import java.util.HashMap;
8+
import java.util.Map;
9+
1010
/**
1111
* @author Faisal Khatri
1212
* @since 2/28/2023
@@ -17,17 +17,17 @@ public class BaseTest {
1717

1818
@BeforeClass
1919
public void setup() {
20-
manager = new RequestManager();
21-
manager.createPlaywright();
22-
String baseUrl = "https://reqres.in";
23-
Map<String, String> headers = new HashMap<>();
20+
this.manager = new RequestManager();
21+
this.manager.createPlaywright();
22+
final String baseUrl = "https://reqres.in";
23+
final Map<String, String> headers = new HashMap<>();
2424
headers.put("content-type", "application/json");
25-
manager.setApiRequestContext(baseUrl, headers);
25+
this.manager.setApiRequestContext(baseUrl, headers);
2626
}
2727

2828
@AfterClass
2929
public void tearDown() {
30-
manager.disposeAPIRequestContext();
31-
manager.closePlaywright();
30+
this.manager.disposeAPIRequestContext();
31+
this.manager.closePlaywright();
3232
}
3333
}

src/test/java/io/github/mfaisalkhatri/api/restfulbooker/data/BookingDataBuilder.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
package io.github.mfaisalkhatri.api.restfulbooker.data;
22

3+
import net.datafaker.Faker;
4+
35
import java.text.SimpleDateFormat;
46
import java.util.concurrent.TimeUnit;
57

6-
import net.datafaker.Faker;
7-
88
/**
99
* @author Faisal Khatri
1010
* @since 2/28/2023
1111
**/
12-
public class BookingDataBuilder {
12+
public final class BookingDataBuilder {
1313

1414
private static final Faker FAKER = new Faker();
1515

1616
public static BookingData getBookingData() {
17-
SimpleDateFormat formatter = new SimpleDateFormat("YYYY-MM-dd");
17+
final SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
1818
return BookingData.builder()
1919
.firstname(FAKER.name()
2020
.firstName())

src/test/java/io/github/mfaisalkhatri/api/restfulbooker/data/TokenBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @author Faisal Khatri
55
* @since 2/28/2023
66
**/
7-
public class TokenBuilder {
7+
public final class TokenBuilder {
88

99
public static Tokencreds getToken() {
1010
return Tokencreds.builder()

0 commit comments

Comments
 (0)