fix: 1
This commit is contained in:
commit
2c888d68bf
38
.gitignore
vendored
Normal file
38
.gitignore
vendored
Normal file
@ -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
|
||||
3
.idea/.gitignore
vendored
Normal file
3
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
7
.idea/encodings.xml
Normal file
7
.idea/encodings.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
14
.idea/misc.xml
Normal file
14
.idea/misc.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="openjdk-23" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
147
pom.xml
Normal file
147
pom.xml
Normal file
@ -0,0 +1,147 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>zacksolutions</groupId>
|
||||
<artifactId>RestAssuredAutomation</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>RestAssuredAutomation</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.18.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager -->
|
||||
<dependency>
|
||||
<groupId>io.github.bonigarcia</groupId>
|
||||
<artifactId>webdrivermanager</artifactId>
|
||||
<version>5.9.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aventstack</groupId>
|
||||
<artifactId>extentreports</artifactId>
|
||||
<version>5.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
<version>7.10.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
|
||||
<dependency>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>selenium-java</artifactId>
|
||||
<version>4.25.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>5.3.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>5.3.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-scratchpad -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-scratchpad</artifactId>
|
||||
<version>5.3.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml-schemas -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml-schemas</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.24.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java -->
|
||||
<dependency>
|
||||
<groupId>io.cucumber</groupId>
|
||||
<artifactId>cucumber-java</artifactId>
|
||||
<version>7.19.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-testng -->
|
||||
<dependency>
|
||||
<groupId>io.cucumber</groupId>
|
||||
<artifactId>cucumber-testng</artifactId>
|
||||
<version>7.19.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.cucumber</groupId>
|
||||
<artifactId>cucumber-java</artifactId>
|
||||
<version>7.14.1</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured -->
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>rest-assured</artifactId>
|
||||
<version>5.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/io.rest-assured/json-path -->
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>json-path</artifactId>
|
||||
<version>5.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/io.rest-assured/json-schema-validator -->
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>json-schema-validator</artifactId>
|
||||
<version>5.5.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.json/json -->
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20240303</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.github.scribejava/scribejava-apis -->
|
||||
<dependency>
|
||||
<groupId>com.github.scribejava</groupId>
|
||||
<artifactId>scribejava-apis</artifactId>
|
||||
<version>8.3.3</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.11.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/io.rest-assured/xml-path -->
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>xml-path</artifactId>
|
||||
<version>5.5.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- Surefire Plugin to run tests -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0-M5</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
13
src/main/java/zacksolutions/App.java
Normal file
13
src/main/java/zacksolutions/App.java
Normal file
@ -0,0 +1,13 @@
|
||||
package zacksolutions;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
*
|
||||
*/
|
||||
public class App
|
||||
{
|
||||
public static void main( String[] args )
|
||||
{
|
||||
System.out.println( "Hello World!" );
|
||||
}
|
||||
}
|
||||
9
src/test/java/api/endpoints/Routes.java
Normal file
9
src/test/java/api/endpoints/Routes.java
Normal file
@ -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}";
|
||||
}
|
||||
46
src/test/java/api/endpoints/UserEndpoints.java
Normal file
46
src/test/java/api/endpoints/UserEndpoints.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
76
src/test/java/api/payload/User.java
Normal file
76
src/test/java/api/payload/User.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
39
src/test/java/api/test/UserTest.java
Normal file
39
src/test/java/api/test/UserTest.java
Normal file
@ -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();
|
||||
}
|
||||
}
|
||||
0
src/test/resources/routes.properties
Normal file
0
src/test/resources/routes.properties
Normal file
2
testng.xml
Normal file
2
testng.xml
Normal file
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"><suite name="All Test Suite"><test verbose="2" preserve-order="true" name="/home/ilyes/SeleniumPractice/RestAssuredAutomation/src/test/java/api/test/UserTest.java"><classes><class name="api.test.UserTest"><methods><include name="testPostUser"/><include name="testGetUser"/></methods></class></classes></test></suite>
|
||||
Loading…
Reference in New Issue
Block a user