commit 2c888d68bf5c762c0b68d2119f44382cf7b3a056 Author: dadgam3er Date: Thu Oct 17 09:21:19 2024 -0400 fix: 1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..36cdbc1 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..7267597 --- /dev/null +++ b/pom.xml @@ -0,0 +1,147 @@ + + 4.0.0 + + zacksolutions + RestAssuredAutomation + 1.0-SNAPSHOT + jar + + RestAssuredAutomation + http://maven.apache.org + + + + com.fasterxml.jackson.core + jackson-databind + 2.18.0 + + + + io.github.bonigarcia + webdrivermanager + 5.9.2 + + + com.aventstack + extentreports + 5.1.2 + + + + org.testng + testng + 7.10.2 + compile + + + + org.seleniumhq.selenium + selenium-java + 4.25.0 + + + + org.apache.poi + poi + 5.3.0 + + + + org.apache.poi + poi-ooxml + 5.3.0 + + + + org.apache.poi + poi-scratchpad + 5.3.0 + + + + org.apache.poi + poi-ooxml-schemas + 4.1.2 + + + + org.apache.logging.log4j + log4j-core + 2.24.0 + + + + io.cucumber + cucumber-java + 7.19.0 + + + + io.cucumber + cucumber-testng + 7.19.0 + + + io.cucumber + cucumber-java + 7.14.1 + + + + io.rest-assured + rest-assured + 5.5.0 + test + + + + io.rest-assured + json-path + 5.5.0 + test + + + + io.rest-assured + json-schema-validator + 5.5.0 + + + + org.json + json + 20240303 + + + + + com.github.scribejava + scribejava-apis + 8.3.3 + runtime + + + + com.google.code.gson + gson + 2.11.0 + + + + io.rest-assured + xml-path + 5.5.0 + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M5 + + + + diff --git a/src/main/java/zacksolutions/App.java b/src/main/java/zacksolutions/App.java new file mode 100644 index 0000000..a0566a9 --- /dev/null +++ b/src/main/java/zacksolutions/App.java @@ -0,0 +1,13 @@ +package zacksolutions; + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + } +} diff --git a/src/test/java/api/endpoints/Routes.java b/src/test/java/api/endpoints/Routes.java new file mode 100644 index 0000000..e44f12f --- /dev/null +++ b/src/test/java/api/endpoints/Routes.java @@ -0,0 +1,9 @@ +package api.endpoints; + +public class Routes { + public static String BASE_URL = "https://petstore.swagger.io/v2/"; + public static String POST_URL = BASE_URL + "user/"; + public static String GET_URL = BASE_URL + "user/{username}"; + public static String UPDATE_URL = BASE_URL + "user/{username}"; + public static String DELETE_URL = BASE_URL + "user/{username}"; +} diff --git a/src/test/java/api/endpoints/UserEndpoints.java b/src/test/java/api/endpoints/UserEndpoints.java new file mode 100644 index 0000000..8d5d999 --- /dev/null +++ b/src/test/java/api/endpoints/UserEndpoints.java @@ -0,0 +1,46 @@ +package api.endpoints; + +import api.payload.User; +import io.restassured.http.ContentType; +import io.restassured.response.Response; + +import static io.restassured.RestAssured.given; + +public class UserEndpoints { + public static Response createUser(User payload){ + Response response = given() + .contentType(ContentType.JSON) + .accept(ContentType.JSON) + .body(payload) + .when() + .post(Routes.POST_URL); + return response; + } + + public static Response readUser(String userName){ + Response response = given() + .pathParam("username", userName) + .when() + .get(Routes.GET_URL); + return response; + } + + public static Response updateUser(String userName, User payload){ + Response response = given() + .contentType(ContentType.JSON) + .accept(ContentType.JSON) + .pathParam("usermame", userName) + .body(payload) + .when() + .put(Routes.UPDATE_URL); + return response; + } + + public static Response deleteUser(String userName){ + Response response = given() + .pathParam("username", userName) + .when() + .delete(Routes.DELETE_URL); + return response; + } +} diff --git a/src/test/java/api/payload/User.java b/src/test/java/api/payload/User.java new file mode 100644 index 0000000..47a8bad --- /dev/null +++ b/src/test/java/api/payload/User.java @@ -0,0 +1,76 @@ +package api.payload; + +public class User { + int id; + String username; + String firstname; + String lastname; + String email; + String password; + String phone; + int userStatus = 0; + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public int getUserStatus() { + return userStatus; + } + + public void setUserStatus(int userStatus) { + this.userStatus = userStatus; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } +} diff --git a/src/test/java/api/test/UserTest.java b/src/test/java/api/test/UserTest.java new file mode 100644 index 0000000..6daa259 --- /dev/null +++ b/src/test/java/api/test/UserTest.java @@ -0,0 +1,39 @@ +package api.test; + +import api.endpoints.UserEndpoints; +import api.payload.User; +import io.restassured.response.Response; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class UserTest { + + User userPayload; + @BeforeClass + public void setupData(){ + userPayload = new User(); + userPayload.setId(10); + userPayload.setUsername("snowman"); + userPayload.setFirstname("Desmond"); + userPayload.setLastname("Hume"); + userPayload.setEmail("desmondh@gamil.com"); + userPayload.setPassword("4815162342"); + userPayload.setPhone("79460893"); + } + + @Test(priority = 1) + public void testPostUser(){ + Response response = UserEndpoints.createUser(userPayload); + response.then().log().all(); + + Assert.assertEquals(response.getStatusCode(), 200); + } + + @Test(priority = 2) + public void testGetUser(){ + Response response = UserEndpoints.readUser(this.userPayload.getUsername()); + response.then() + .statusCode(200).log().all(); + } +} diff --git a/src/test/resources/routes.properties b/src/test/resources/routes.properties new file mode 100644 index 0000000..e69de29 diff --git a/testng.xml b/testng.xml new file mode 100644 index 0000000..da82c5b --- /dev/null +++ b/testng.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file