added tests API for /api/user
This commit is contained in:
parent
77c036f7df
commit
6ddef79444
11 changed files with 461 additions and 0 deletions
73
src/test/java/endpoints/UserEndpoint.java
Normal file
73
src/test/java/endpoints/UserEndpoint.java
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
package endpoints;
|
||||
|
||||
import helpers.PropertyProvider;
|
||||
import io.qameta.allure.Step;
|
||||
import io.restassured.response.Response;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
import pojo.UserRequest;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
|
||||
public class UserEndpoint {
|
||||
private static final String ENDPOINT = PropertyProvider.getProperty("endpoint.user");
|
||||
|
||||
@Step("Создание запроса о информации пользователя")
|
||||
public static UserRequest addUser() {
|
||||
return UserRequest.builder()
|
||||
.id(PropertyProvider.getProperty("test.id"))
|
||||
.username(PropertyProvider.getProperty("test.username"))
|
||||
.firstName(PropertyProvider.getProperty("test.firstname"))
|
||||
.lastName(PropertyProvider.getProperty("test.lastname"))
|
||||
.email(PropertyProvider.getProperty("test.email"))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Step("Добавить информацию о пользователе и вернуть его ID")
|
||||
public static Response addUserId(RequestSpecification spec, UserRequest userRequest) {
|
||||
return given(spec)
|
||||
.body(userRequest)
|
||||
.when()
|
||||
.post(ENDPOINT)
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().response();
|
||||
}
|
||||
|
||||
@Step("Получить информацию о текущем пользователе")
|
||||
public static Response getUser(RequestSpecification spec) {
|
||||
return given(spec)
|
||||
.when()
|
||||
.get(ENDPOINT);
|
||||
}
|
||||
|
||||
@Step("Получить информацию о пользователе по ID: {userId}")
|
||||
public static Response getUserById(RequestSpecification spec, String userId) {
|
||||
return given(spec)
|
||||
.pathParam("id", userId)
|
||||
.when()
|
||||
.get(ENDPOINT + "/{id}");
|
||||
}
|
||||
|
||||
@Step("Обновить информацию о пользователе: {user}")
|
||||
public static Response updateUser(RequestSpecification spec, UserRequest userRequest) {
|
||||
return given(spec)
|
||||
.body(userRequest)
|
||||
.when()
|
||||
.put(ENDPOINT);
|
||||
}
|
||||
|
||||
@Step("Удалить текущего пользователя")
|
||||
public static Response deleteUser(RequestSpecification spec) {
|
||||
return given(spec)
|
||||
.when()
|
||||
.delete(ENDPOINT);
|
||||
}
|
||||
|
||||
@Step("Удалить пользователя по ID: {userId}")
|
||||
public static Response deleteUserById(RequestSpecification spec, String userId) {
|
||||
return given(spec)
|
||||
.pathParam("id", userId)
|
||||
.when()
|
||||
.delete(ENDPOINT + "/{id}");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue