├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .idea ├── .gitignore ├── encodings.xml ├── misc.xml ├── sonarlint-state.xml ├── sonarlint.xml ├── sonarlint │ └── issuestore │ │ └── index.pb ├── uiDesigner.xml └── vcs.xml ├── LICENSE ├── README.md ├── pom.xml ├── src └── test │ ├── java │ ├── Runner.java │ ├── factories │ │ ├── CarDataFactory.java │ │ ├── LoginDataFactory.java │ │ ├── ProductDataFactory.java │ │ └── UserDataFactory.java │ ├── pojo │ │ ├── CarPojo.java │ │ ├── CreateUsersPojo.java │ │ ├── LoginPojo.java │ │ ├── ProductCarPojo.java │ │ └── ProductPojo.java │ ├── tests │ │ ├── car │ │ │ ├── CancelCarTest.java │ │ │ ├── ConcludeCarTest.java │ │ │ ├── CreateCarTest.java │ │ │ └── ListCarTest.java │ │ ├── login │ │ │ └── LoginTest.java │ │ ├── product │ │ │ ├── CreateProductTest.java │ │ │ ├── DeleteProductTest.java │ │ │ ├── ListProductTest.java │ │ │ └── UpdateProductTest.java │ │ └── users │ │ │ ├── CreateUserTest.java │ │ │ ├── DeleteUserTest.java │ │ │ ├── ListUserTest.java │ │ │ └── UpdateUserTest.java │ └── utils │ │ ├── BaseUrlUtil.java │ │ ├── LoginUtil.java │ │ ├── ProductUtil.java │ │ └── UserUtil.java │ └── resources │ └── schema │ ├── car-schema.json │ ├── login-schema.json │ ├── product-schema.json │ └── user-schema.json └── target ├── maven-status └── maven-compiler-plugin │ └── testCompile │ └── default-testCompile │ ├── createdFiles.lst │ └── inputFiles.lst ├── surefire-reports ├── Runner.txt └── TEST-Runner.xml └── test-classes ├── Runner.class ├── factories ├── CarDataFactory.class ├── LoginDataFactory.class ├── ProductDataFactory.class └── UserDataFactory.class ├── pojo ├── CarPojo.class ├── CreateUsersPojo.class ├── LoginPojo.class ├── ProductCarPojo.class └── ProductPojo.class ├── schema ├── car-schema.json ├── login-schema.json ├── product-schema.json └── user-schema.json ├── tests ├── car │ ├── CancelCarTest.class │ ├── ConcludeCarTest.class │ ├── CreateCarTest.class │ └── ListCarTest.class ├── login │ └── LoginTest.class ├── product │ ├── CreateProductTest.class │ ├── DeleteProductTest.class │ ├── ListProductTest.class │ └── UpdateProductTest.class └── users │ ├── CreateUserTest.class │ ├── DeleteUserTest.class │ ├── ListUserTest.class │ └── UpdateUserTest.class └── utils ├── BaseUrlUtil.class ├── LoginUtil.class ├── ProductUtil.class └── UserUtil.class /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: maven 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | schedule: 9 | - cron: '35 16 * * 2' 10 | 11 | jobs: 12 | ci: 13 | 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - uses: actions/checkout@v2 18 | - name: Set up JDK 11 19 | uses: actions/setup-java@v2 20 | with: 21 | java-version: '11' 22 | distribution: 'adopt' 23 | cache: maven 24 | - name: Build with Maven 25 | run: mvn -Dtest=Runner test 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # User-specific stuff 2 | .idea/**/workspace.xml 3 | .idea/**/tasks.xml 4 | .idea/**/usage.statistics.xml 5 | .idea/**/dictionaries 6 | */target/* 7 | .idea/**/shelf 8 | .idea/**/gradle.xml 9 | .idea/**/libraries 10 | 11 | auto-import. 12 | .idea/artifacts 13 | .idea/compiler.xml 14 | .idea/jarRepositories.xml 15 | .idea/modules.xml 16 | .idea/*.iml 17 | .idea/modules 18 | *.iml 19 | *.ipr 20 | out/ 21 | *.log 22 | 23 | # Package Files # 24 | *.jar 25 | *.war 26 | *.nar 27 | *.ear 28 | *.zip 29 | *.tar.gz 30 | *.rar -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.idea/sonarlint-state.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1632533549838 5 | 6 | -------------------------------------------------------------------------------- /.idea/sonarlint.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 15 | 19 | -------------------------------------------------------------------------------- /.idea/sonarlint/issuestore/index.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/.idea/sonarlint/issuestore/index.pb -------------------------------------------------------------------------------- /.idea/uiDesigner.xml: -------------------------------------------------------------------------------- 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 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Misael Reis 4 | 5 | A permissão é concedida, gratuitamente, a qualquer pessoa que obtenha uma cópia 6 | deste software e arquivos de documentação associados (o "Software"), para lidar 7 | no Software sem restrição, incluindo, sem limitação, os direitos 8 | para usar, copiar, modificar, mesclar, publicar, distribuir, sublicenciar e / ou vender 9 | cópias do Software, e para permitir que as pessoas a quem o Software é 10 | fornecido para fazê-lo, sujeito às seguintes condições: 11 | 12 | O aviso de direitos autorais acima e este aviso de permissão devem ser incluídos em todos 13 | cópias ou partes substanciais do Software. 14 | 15 | O SOFTWARE É FORNECIDO "COMO ESTÁ", SEM GARANTIA DE QUALQUER TIPO, EXPRESSA OU 16 | IMPLÍCITA, INCLUINDO, MAS NÃO SE LIMITANDO ÀS GARANTIAS DE COMERCIALIZAÇÃO, 17 | ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA E NÃO VIOLAÇÃO. EM NENHUMA HIPÓTESE O 18 | AUTORES OU TITULARES DE DIREITOS AUTORAIS SÃO RESPONSÁVEIS POR QUALQUER RECLAMAÇÃO, DANOS OU OUTROS 19 | RESPONSABILIDADE, SEJA EM AÇÃO DE CONTRATO, DELITO OU DE OUTRA FORMA, DECORRENTE DE, 20 | FORA DE OU EM CONEXÃO COM O SOFTWARE OU O USO OU OUTRAS NEGOCIAÇÕES NO 21 | PROGRAMAS. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Apresentação ![GitHub Workflow Status](https://img.shields.io/github/workflow/status/Misaelreis/test-api-serverest/maven) [![Badge ServeRest](https://img.shields.io/badge/API-ServeRest-green)](https://github.com/ServeRest/ServeRest/) 2 | 3 | - Automação de testes baseado na Api [Serverest](https://serverest.dev/#/) 4 | - Testes de contrato baseado no [post](https://medium.com/assertqualityassurance/testando-seu-contrato-com-o-restassured-f0e974fb9bcb) 5 | 6 | --- 7 | ## Pré-requisitos 8 | 9 | - [JDK 8+](https://www.oracle.com/java/technologies/javase-downloads.html) 10 | - [IntelliJ](https://www.jetbrains.com/idea/download/) 11 | --- 12 | 13 | ## Instalação & Execução 14 | - No terminal execute o comando mvn install 15 | - Em seguida o comando mvn clean test 16 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.example 8 | automacao-serverest-api 9 | 1.0-SNAPSHOT 10 | 11 | 12 | 13 | 14 | org.apache.maven.plugins 15 | maven-surefire-report-plugin 16 | 3.0.0-M7 17 | 18 | 19 | 20 | 21 | 22 | 23 | io.rest-assured 24 | rest-assured 25 | 5.2.0 26 | 27 | 28 | 29 | com.google.code.gson 30 | gson 31 | 2.9.0 32 | 33 | 34 | 35 | junit 36 | junit 37 | 4.13.2 38 | 39 | 40 | 41 | com.github.javafaker 42 | javafaker 43 | 1.0.2 44 | 45 | 46 | 47 | io.rest-assured 48 | json-schema-validator 49 | 5.2.0 50 | 51 | 52 | 53 | org.projectlombok 54 | lombok 55 | 1.18.24 56 | 57 | 58 | 59 | 60 | 1.8 61 | 1.8 62 | UTF-8 63 | UTF-8 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /src/test/java/Runner.java: -------------------------------------------------------------------------------- 1 | import org.junit.runner.RunWith; 2 | import org.junit.runners.Suite; 3 | import tests.car.*; 4 | import tests.login.*; 5 | import tests.product.*; 6 | import tests.users.*; 7 | 8 | @RunWith(Suite.class) 9 | @Suite.SuiteClasses({ 10 | CancelCarTest.class, 11 | ConcludeCarTest.class, 12 | CreateCarTest.class, 13 | ListCarTest.class, 14 | LoginTest.class, 15 | CreateProductTest.class, 16 | DeleteProductTest.class, 17 | ListProductTest.class, 18 | UpdateProductTest.class, 19 | CreateUserTest.class, 20 | DeleteUserTest.class, 21 | ListUserTest.class, 22 | UpdateUserTest.class, 23 | }) 24 | public class Runner { 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/factories/CarDataFactory.java: -------------------------------------------------------------------------------- 1 | package factories; 2 | 3 | import pojo.CarPojo; 4 | 5 | public class CarDataFactory { 6 | 7 | public CarPojo car(){ 8 | CarPojo car = new CarPojo(); 9 | return car; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/test/java/factories/LoginDataFactory.java: -------------------------------------------------------------------------------- 1 | package factories; 2 | 3 | import pojo.LoginPojo; 4 | 5 | public class LoginDataFactory { 6 | 7 | public static LoginPojo loginSuccess(){ 8 | LoginPojo login = new LoginPojo(); 9 | login.setEmail("misael@qa.com.br"); 10 | login.setPassword("teste"); 11 | return login; 12 | } 13 | 14 | public static LoginPojo loginWithoutEmail(){ 15 | LoginPojo login = new LoginPojo(); 16 | login.setPassword("teste"); 17 | return login; 18 | } 19 | 20 | public static LoginPojo loginWithoutPassword(){ 21 | LoginPojo login = new LoginPojo(); 22 | login.setEmail("misael@qa.com.br"); 23 | return login; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/factories/ProductDataFactory.java: -------------------------------------------------------------------------------- 1 | package factories; 2 | 3 | import com.github.javafaker.Faker; 4 | import pojo.ProductPojo; 5 | 6 | public class ProductDataFactory { 7 | Faker faker = new Faker(); 8 | 9 | public ProductPojo product(){ 10 | ProductPojo product = new ProductPojo(); 11 | product.setNome(faker.name().name()); 12 | product.setDescricao(faker.app().version()); 13 | product.setPreco(100); 14 | product.setQuantidade(3); 15 | return product; 16 | } 17 | 18 | public ProductPojo productWithoutName(){ 19 | ProductPojo product = new ProductPojo(); 20 | product.setDescricao(faker.app().version()); 21 | product.setPreco(100); 22 | product.setQuantidade(3); 23 | return product; 24 | } 25 | 26 | public ProductPojo productWithoutDescription(){ 27 | ProductPojo product = new ProductPojo(); 28 | product.setNome(faker.app().name()); 29 | product.setPreco(100); 30 | product.setQuantidade(3); 31 | return product; 32 | } 33 | 34 | public ProductPojo productWithoutPrice(){ 35 | ProductPojo product = new ProductPojo(); 36 | product.setNome(faker.app().name()); 37 | product.setDescricao(faker.app().version()); 38 | product.setQuantidade(3); 39 | return product; 40 | } 41 | 42 | public ProductPojo productWithoutQuantity(){ 43 | ProductPojo product = new ProductPojo(); 44 | product.setNome(faker.app().name()); 45 | product.setDescricao(faker.app().version()); 46 | product.setPreco(100); 47 | return product; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/factories/UserDataFactory.java: -------------------------------------------------------------------------------- 1 | package factories; 2 | 3 | import com.github.javafaker.Faker; 4 | import pojo.CreateUsersPojo; 5 | 6 | public class UserDataFactory { 7 | Faker faker = new Faker(); 8 | 9 | public CreateUsersPojo userAdm(){ 10 | CreateUsersPojo user = new CreateUsersPojo(); 11 | user.setAdministrador("true"); 12 | user.setNome(faker.name().fullName()); 13 | user.setEmail(faker.internet().emailAddress()); 14 | user.setPassword("teste"); 15 | return user; 16 | } 17 | 18 | public CreateUsersPojo userWithoutTypeAdm(){ 19 | CreateUsersPojo user = new CreateUsersPojo(); 20 | user.setNome(faker.name().fullName()); 21 | user.setEmail(faker.internet().emailAddress()); 22 | user.setPassword("teste"); 23 | return user; 24 | } 25 | 26 | public CreateUsersPojo userWithoutName(){ 27 | CreateUsersPojo user = new CreateUsersPojo(); 28 | user.setAdministrador("true"); 29 | user.setEmail(faker.internet().emailAddress()); 30 | user.setPassword("teste"); 31 | return user; 32 | } 33 | 34 | public CreateUsersPojo userWithoutPassword(){ 35 | CreateUsersPojo user = new CreateUsersPojo(); 36 | user.setNome(faker.name().fullName()); 37 | user.setAdministrador("true"); 38 | user.setEmail(faker.internet().emailAddress()); 39 | return user; 40 | } 41 | 42 | public CreateUsersPojo userWithoutEmail(){ 43 | CreateUsersPojo user = new CreateUsersPojo(); 44 | user.setNome(faker.name().fullName()); 45 | user.setAdministrador("true"); 46 | user.setPassword("teste"); 47 | return user; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/pojo/CarPojo.java: -------------------------------------------------------------------------------- 1 | package pojo; 2 | 3 | import java.util.ArrayList; 4 | import lombok.Data; 5 | 6 | @Data 7 | public class CarPojo { 8 | 9 | private ArrayList produtos = new ArrayList(); 10 | 11 | public void addProducts(ProductCarPojo produtos){ 12 | this.produtos.add(produtos); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/java/pojo/CreateUsersPojo.java: -------------------------------------------------------------------------------- 1 | package pojo; 2 | import lombok.Data; 3 | 4 | @Data 5 | public class CreateUsersPojo extends LoginPojo { 6 | private String nome; 7 | private String administrador; 8 | } 9 | -------------------------------------------------------------------------------- /src/test/java/pojo/LoginPojo.java: -------------------------------------------------------------------------------- 1 | package pojo; 2 | import lombok.Data; 3 | 4 | @Data 5 | public class LoginPojo { 6 | private String email; 7 | private String password; 8 | } 9 | -------------------------------------------------------------------------------- /src/test/java/pojo/ProductCarPojo.java: -------------------------------------------------------------------------------- 1 | package pojo; 2 | import lombok.Data; 3 | 4 | @Data 5 | public class ProductCarPojo { 6 | private String idProduto; 7 | private Integer quantidade; 8 | 9 | public ProductCarPojo(String idProduto, Integer quantidade){ 10 | this.idProduto = idProduto; 11 | this.quantidade = quantidade; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/test/java/pojo/ProductPojo.java: -------------------------------------------------------------------------------- 1 | package pojo; 2 | import lombok.Data; 3 | 4 | @Data 5 | public class ProductPojo { 6 | private String nome; 7 | private String descricao; 8 | private Integer preco; 9 | private Integer quantidade; 10 | } 11 | -------------------------------------------------------------------------------- /src/test/java/tests/car/CancelCarTest.java: -------------------------------------------------------------------------------- 1 | package tests.car; 2 | 3 | import factories.CarDataFactory; 4 | import factories.ProductDataFactory; 5 | import io.restassured.http.ContentType; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | import pojo.CarPojo; 9 | import pojo.ProductCarPojo; 10 | import pojo.ProductPojo; 11 | import utils.LoginUtil; 12 | 13 | import static io.restassured.RestAssured.given; 14 | import static org.hamcrest.Matchers.equalTo; 15 | import static org.hamcrest.Matchers.notNullValue; 16 | import static utils.BaseUrlUtil.baseUrlCar; 17 | import static utils.BaseUrlUtil.baseUrlProduct; 18 | 19 | public class CancelCarTest { 20 | 21 | public String tokenId; 22 | public String productId; 23 | 24 | @Before 25 | public void createUsersAndLogin(){ 26 | tokenId = new LoginUtil().loginAdmFix(); 27 | ProductPojo product = new ProductDataFactory().product(); 28 | productId = given() 29 | .contentType(ContentType.JSON) 30 | .headers("Authorization", tokenId) 31 | .body(product) 32 | .when() 33 | .post(baseUrlProduct) 34 | .then() 35 | .statusCode(201) 36 | .body("message", equalTo("Cadastro realizado com sucesso")) 37 | .body("_id", notNullValue()) 38 | .extract().path("_id"); 39 | } 40 | 41 | @Test 42 | public void testCancelCarWithoutToken(){ 43 | given() 44 | .contentType(ContentType.JSON) 45 | .delete(baseUrlCar.concat("cancelar-compra")) 46 | .then() 47 | .statusCode(401) 48 | .body("message", equalTo("Token de acesso ausente, inválido, expirado ou usuário do token não existe mais")); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/test/java/tests/car/ConcludeCarTest.java: -------------------------------------------------------------------------------- 1 | package tests.car; 2 | 3 | import factories.CarDataFactory; 4 | import factories.ProductDataFactory; 5 | import io.restassured.http.ContentType; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | import pojo.CarPojo; 9 | import pojo.ProductCarPojo; 10 | import pojo.ProductPojo; 11 | import utils.LoginUtil; 12 | 13 | import static io.restassured.RestAssured.given; 14 | import static org.hamcrest.Matchers.equalTo; 15 | import static org.hamcrest.Matchers.notNullValue; 16 | import static utils.BaseUrlUtil.baseUrlCar; 17 | import static utils.BaseUrlUtil.baseUrlProduct; 18 | 19 | public class ConcludeCarTest { 20 | 21 | public String tokenId; 22 | public String productId; 23 | 24 | @Before 25 | public void createUsersAndLogin(){ 26 | tokenId = new LoginUtil().loginAdmFix(); 27 | ProductPojo product = new ProductDataFactory().product(); 28 | productId = given() 29 | .contentType(ContentType.JSON) 30 | .headers("Authorization", tokenId) 31 | .body(product) 32 | .when() 33 | .post(baseUrlProduct) 34 | .then() 35 | .statusCode(201) 36 | .body("message", equalTo("Cadastro realizado com sucesso")) 37 | .body("_id", notNullValue()) 38 | .extract().path("_id"); 39 | } 40 | 41 | @Test 42 | public void testConcludeCarWithoutToken(){ 43 | given() 44 | .contentType(ContentType.JSON) 45 | .delete(baseUrlCar.concat("concluir-compra")) 46 | .then() 47 | .statusCode(401) 48 | .body("message", equalTo("Token de acesso ausente, inválido, expirado ou usuário do token não existe mais")); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/test/java/tests/car/CreateCarTest.java: -------------------------------------------------------------------------------- 1 | package tests.car; 2 | 3 | import factories.CarDataFactory; 4 | import factories.ProductDataFactory; 5 | import io.restassured.http.ContentType; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | import pojo.CarPojo; 9 | import pojo.ProductCarPojo; 10 | import pojo.ProductPojo; 11 | import utils.LoginUtil; 12 | 13 | import static io.restassured.RestAssured.given; 14 | import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath; 15 | import static org.hamcrest.Matchers.equalTo; 16 | import static org.hamcrest.Matchers.notNullValue; 17 | import static utils.BaseUrlUtil.baseUrlCar; 18 | import static utils.BaseUrlUtil.baseUrlProduct; 19 | 20 | public class CreateCarTest { 21 | 22 | public String tokenId; 23 | public String productId; 24 | 25 | @Before 26 | public void createProductAndLogin(){ 27 | tokenId = new LoginUtil().loginAdmFix(); 28 | ProductPojo product = new ProductDataFactory().product(); 29 | productId = given() 30 | .contentType(ContentType.JSON) 31 | .headers("Authorization", tokenId) 32 | .body(product) 33 | .when() 34 | .post(baseUrlProduct) 35 | .then() 36 | .statusCode(201) 37 | .body("message", equalTo("Cadastro realizado com sucesso")) 38 | .body("_id", notNullValue()) 39 | .extract().path("_id"); 40 | } 41 | 42 | @Test 43 | public void testCreateCarWithoutToken(){ 44 | CarPojo car = new CarDataFactory().car(); 45 | car.addProducts((new ProductCarPojo(productId,1))); 46 | given() 47 | .contentType(ContentType.JSON) 48 | .body(car) 49 | .when() 50 | .post(baseUrlCar) 51 | .then() 52 | .statusCode(401) 53 | .body("message", equalTo("Token de acesso ausente, inválido, expirado ou usuário do token não existe mais")); 54 | } 55 | 56 | @Test 57 | public void testCreateCarFieldRequired(){ 58 | CarPojo car = new CarDataFactory().car(); 59 | car.addProducts((new ProductCarPojo(productId,1))); 60 | given() 61 | .headers("Authorization", tokenId) 62 | .body(car) 63 | .when() 64 | .post(baseUrlCar) 65 | .then() 66 | .statusCode(400) 67 | .body("produtos", equalTo("produtos é obrigatório")); 68 | } 69 | 70 | @Test 71 | public void testCreateCarWithoutProducts(){ 72 | CarPojo car = new CarDataFactory().car(); 73 | car.addProducts((new ProductCarPojo("1",1))); 74 | given() 75 | .headers("Authorization", tokenId) 76 | .body(car) 77 | .when() 78 | .post(baseUrlCar) 79 | .then() 80 | .statusCode(400) 81 | .body("produtos", equalTo("produtos é obrigatório")); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/test/java/tests/car/ListCarTest.java: -------------------------------------------------------------------------------- 1 | package tests.car; 2 | 3 | import factories.CarDataFactory; 4 | import factories.ProductDataFactory; 5 | import io.restassured.http.ContentType; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | import pojo.CarPojo; 9 | import pojo.ProductCarPojo; 10 | import pojo.ProductPojo; 11 | import utils.LoginUtil; 12 | 13 | import static io.restassured.RestAssured.given; 14 | import static org.hamcrest.Matchers.equalTo; 15 | import static org.hamcrest.Matchers.notNullValue; 16 | import static utils.BaseUrlUtil.baseUrlCar; 17 | import static utils.BaseUrlUtil.baseUrlProduct; 18 | 19 | public class ListCarTest { 20 | 21 | public String tokenId; 22 | public String productId; 23 | public String carId; 24 | 25 | @Before 26 | public void createProductAndLogin(){ 27 | tokenId = new LoginUtil().loginAdmFix(); 28 | ProductPojo product = new ProductDataFactory().product(); 29 | productId = given() 30 | .contentType(ContentType.JSON) 31 | .headers("Authorization", tokenId) 32 | .body(product) 33 | .when() 34 | .post(baseUrlProduct) 35 | .then() 36 | .statusCode(201) 37 | .body("message", equalTo("Cadastro realizado com sucesso")) 38 | .body("_id", notNullValue()) 39 | .extract().path("_id"); 40 | } 41 | 42 | @Test 43 | public void testListCars(){ 44 | given() 45 | .contentType(ContentType.JSON) 46 | .when() 47 | .get(baseUrlCar) 48 | .then() 49 | .statusCode(200); 50 | } 51 | 52 | @Test 53 | public void testListCarIncorrectParams(){ 54 | given() 55 | .contentType(ContentType.JSON) 56 | .queryParam("id", 1) 57 | .when() 58 | .get(baseUrlCar) 59 | .then() 60 | .statusCode(400) 61 | .body("id", equalTo("id não é permitido")); 62 | } 63 | 64 | @Test 65 | public void testListCarTypeParamsIncorrect(){ 66 | given() 67 | .contentType(ContentType.JSON) 68 | .queryParam("precoTotal", "1") 69 | .queryParam("_id", 1) 70 | .queryParam("quantidadeTotal", "1") 71 | .queryParam("idUsuario",1) 72 | .when() 73 | .get(baseUrlCar) 74 | .then() 75 | .statusCode(200) 76 | .body("quantidade", equalTo(0)); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/test/java/tests/login/LoginTest.java: -------------------------------------------------------------------------------- 1 | package tests.login; 2 | 3 | import factories.LoginDataFactory; 4 | import io.restassured.http.ContentType; 5 | import org.junit.Test; 6 | import pojo.LoginPojo; 7 | import utils.UserUtil; 8 | 9 | import static io.restassured.RestAssured.given; 10 | import static org.hamcrest.Matchers.equalTo; 11 | import static org.hamcrest.Matchers.notNullValue; 12 | import static utils.BaseUrlUtil.baseUrlLogin; 13 | import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath; 14 | 15 | public class LoginTest { 16 | 17 | @Test 18 | public void testLoginContract(){ 19 | UserUtil user = new UserUtil().createUserAdm(); 20 | LoginPojo login = LoginDataFactory.loginSuccess(); 21 | given() 22 | .contentType(ContentType.JSON) 23 | .body(login) 24 | .when() 25 | .post(baseUrlLogin) 26 | .then() 27 | .statusCode(200) 28 | .body(matchesJsonSchemaInClasspath("schema/login-schema.json")); 29 | } 30 | 31 | @Test 32 | public void tesLoginSuccess(){ 33 | UserUtil user = new UserUtil().createUserAdm(); 34 | LoginPojo login = LoginDataFactory.loginSuccess(); 35 | given() 36 | .contentType(ContentType.JSON) 37 | .body(login) 38 | .when() 39 | .post(baseUrlLogin) 40 | .then() 41 | .statusCode(200) 42 | .body("authorization", notNullValue()) 43 | .body("message", equalTo("Login realizado com sucesso")); 44 | } 45 | 46 | @Test 47 | public void testLoginWithoutEmail(){ 48 | LoginPojo login = LoginDataFactory.loginWithoutEmail(); 49 | given() 50 | .contentType(ContentType.JSON) 51 | .body(login) 52 | .when() 53 | .post(baseUrlLogin) 54 | .then() 55 | .statusCode(400) 56 | .body("email", equalTo("email deve ser uma string")); 57 | } 58 | 59 | @Test 60 | public void testLoginWithoutPassword(){ 61 | LoginPojo login = LoginDataFactory.loginWithoutPassword(); 62 | given() 63 | .contentType(ContentType.JSON) 64 | .body(login) 65 | .when() 66 | .post(baseUrlLogin) 67 | .then() 68 | .statusCode(400) 69 | .body("password", equalTo("password deve ser uma string")); 70 | } 71 | 72 | @Test 73 | public void testLoginEmailEmpty(){ 74 | LoginPojo login = LoginDataFactory.loginSuccess(); 75 | login.setEmail(""); 76 | given() 77 | .contentType(ContentType.JSON) 78 | .body(login) 79 | .when() 80 | .post(baseUrlLogin) 81 | .then() 82 | .statusCode(400) 83 | .body("email", equalTo("email não pode ficar em branco")); 84 | } 85 | 86 | @Test 87 | public void testLoginPasswordEmpty(){ 88 | LoginPojo login = LoginDataFactory.loginSuccess(); 89 | login.setPassword(""); 90 | given() 91 | .contentType(ContentType.JSON) 92 | .body(login) 93 | .when() 94 | .post(baseUrlLogin) 95 | .then() 96 | .statusCode(400) 97 | .body("password", equalTo("password não pode ficar em branco")); 98 | } 99 | 100 | @Test 101 | public void testLoginEmailNull(){ 102 | LoginPojo login = LoginDataFactory.loginSuccess(); 103 | login.setEmail(null); 104 | given() 105 | .contentType(ContentType.JSON) 106 | .body(login) 107 | .when() 108 | .post(baseUrlLogin) 109 | .then() 110 | .statusCode(400) 111 | .body("email", equalTo("email deve ser uma string")); 112 | } 113 | 114 | @Test 115 | public void testLoginPasswordNull(){ 116 | LoginPojo login = LoginDataFactory.loginSuccess(); 117 | login.setPassword(null); 118 | given() 119 | .contentType(ContentType.JSON) 120 | .body(login) 121 | .when() 122 | .post(baseUrlLogin) 123 | .then() 124 | .statusCode(400) 125 | .body("password", equalTo("password deve ser uma string")); 126 | } 127 | 128 | @Test 129 | public void testLoginEmailIncorrect(){ 130 | LoginPojo login = LoginDataFactory.loginSuccess(); 131 | login.setEmail("teste.com.br"); 132 | given() 133 | .contentType(ContentType.JSON) 134 | .body(login) 135 | .when() 136 | .post(baseUrlLogin) 137 | .then() 138 | .statusCode(400) 139 | .body("email", equalTo("email deve ser um email válido")); 140 | } 141 | 142 | @Test 143 | public void testLoginEmailNoRegistered(){ 144 | LoginPojo login = LoginDataFactory.loginSuccess(); 145 | login.setEmail("misael@email.com.br"); 146 | given() 147 | .contentType(ContentType.JSON) 148 | .body(login) 149 | .when() 150 | .post(baseUrlLogin) 151 | .then() 152 | .statusCode(401) 153 | .body("message", equalTo("Email e/ou senha inválidos")); 154 | } 155 | 156 | @Test 157 | public void testLoginPasswordIncorrect(){ 158 | LoginPojo login = LoginDataFactory.loginSuccess(); 159 | login.setPassword("123"); 160 | given() 161 | .contentType(ContentType.JSON) 162 | .body(login) 163 | .when() 164 | .post(baseUrlLogin) 165 | .then() 166 | .statusCode(401) 167 | .body("message", equalTo("Email e/ou senha inválidos")); 168 | } 169 | 170 | @Test 171 | public void testLoginFieldsRequired(){ 172 | LoginPojo login = LoginDataFactory.loginSuccess(); 173 | given() 174 | .body(login) 175 | .when() 176 | .post(baseUrlLogin) 177 | .then() 178 | .statusCode(400) 179 | .body("password", equalTo("password é obrigatório")) 180 | .body("email", equalTo("email é obrigatório")); 181 | } 182 | } 183 | -------------------------------------------------------------------------------- /src/test/java/tests/product/CreateProductTest.java: -------------------------------------------------------------------------------- 1 | package tests.product; 2 | 3 | import factories.ProductDataFactory; 4 | import io.restassured.http.ContentType; 5 | import org.junit.Before; 6 | import org.junit.Test; 7 | import pojo.ProductPojo; 8 | import utils.LoginUtil; 9 | 10 | import static io.restassured.RestAssured.given; 11 | import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath; 12 | import static org.hamcrest.Matchers.equalTo; 13 | import static org.hamcrest.Matchers.notNullValue; 14 | import static utils.BaseUrlUtil.baseUrlProduct; 15 | 16 | public class CreateProductTest { 17 | 18 | public String tokenIdAdm; 19 | public String tokenIdUser; 20 | 21 | @Before 22 | public void setToken(){ 23 | tokenIdAdm = new LoginUtil().loginAdmFix(); 24 | tokenIdUser = new LoginUtil().loginUserFix(); 25 | } 26 | 27 | @Test 28 | public void testProductContract(){ 29 | ProductPojo product = new ProductDataFactory().product(); 30 | given() 31 | .contentType(ContentType.JSON) 32 | .headers("Authorization", tokenIdAdm) 33 | .body(product) 34 | .when() 35 | .post(baseUrlProduct) 36 | .then() 37 | .statusCode(201) 38 | .body(matchesJsonSchemaInClasspath("schema/product-schema.json")); 39 | } 40 | 41 | @Test 42 | public void testCreateProduct(){ 43 | ProductPojo product = new ProductDataFactory().product(); 44 | given() 45 | .contentType(ContentType.JSON) 46 | .headers("Authorization", tokenIdAdm) 47 | .body(product) 48 | .when() 49 | .post(baseUrlProduct) 50 | .then() 51 | .statusCode(201) 52 | .body("message", equalTo("Cadastro realizado com sucesso")) 53 | .body("_id", notNullValue()); 54 | } 55 | 56 | @Test 57 | public void testCreateProductIdUser(){ 58 | ProductPojo product = new ProductDataFactory().product(); 59 | given() 60 | .contentType(ContentType.JSON) 61 | .headers("Authorization", tokenIdUser) 62 | .body(product) 63 | .when() 64 | .post(baseUrlProduct) 65 | .then() 66 | .statusCode(403) 67 | .body("message", equalTo("Rota exclusiva para administradores")); 68 | } 69 | 70 | @Test 71 | public void testCreateProductNameExistent(){ 72 | ProductPojo product = new ProductDataFactory().product(); 73 | product.setNome("produto existente"); 74 | given() 75 | .contentType(ContentType.JSON) 76 | .headers("Authorization", tokenIdAdm) 77 | .body(product) 78 | .when() 79 | .post(baseUrlProduct); 80 | 81 | given() 82 | .contentType(ContentType.JSON) 83 | .headers("Authorization", tokenIdAdm) 84 | .body(product) 85 | .when() 86 | .post(baseUrlProduct) 87 | .then() 88 | .statusCode(400) 89 | .body("message", equalTo("Já existe produto com esse nome")); 90 | } 91 | 92 | @Test 93 | public void testCreateProductWithoutToken(){ 94 | ProductPojo product = new ProductDataFactory().product(); 95 | given() 96 | .contentType(ContentType.JSON) 97 | .body(product) 98 | .when() 99 | .post(baseUrlProduct) 100 | .then() 101 | .statusCode(401) 102 | .body("message", equalTo("Token de acesso ausente, inválido, expirado ou usuário do token não existe mais")); 103 | } 104 | 105 | @Test 106 | public void testCreateProductWithoutName(){ 107 | ProductPojo product = new ProductDataFactory().productWithoutName(); 108 | given() 109 | .contentType(ContentType.JSON) 110 | .headers("Authorization", tokenIdAdm) 111 | .body(product) 112 | .when() 113 | .post(baseUrlProduct) 114 | .then() 115 | .statusCode(400) 116 | .body("nome", equalTo("nome deve ser uma string")); 117 | } 118 | 119 | @Test 120 | public void testCreateProductNameNull(){ 121 | ProductPojo product = new ProductDataFactory().product(); 122 | product.setNome(null); 123 | given() 124 | .contentType(ContentType.JSON) 125 | .headers("Authorization", tokenIdAdm) 126 | .body(product) 127 | .when() 128 | .post(baseUrlProduct) 129 | .then() 130 | .statusCode(400) 131 | .body("nome", equalTo("nome deve ser uma string")); 132 | } 133 | 134 | @Test 135 | public void testCreateProductWithoutPrice(){ 136 | ProductPojo product = new ProductDataFactory().productWithoutPrice(); 137 | given() 138 | .contentType(ContentType.JSON) 139 | .headers("Authorization", tokenIdAdm) 140 | .body(product) 141 | .when() 142 | .post(baseUrlProduct) 143 | .then() 144 | .statusCode(400) 145 | .body("preco", equalTo("preco deve ser um número")); 146 | } 147 | 148 | @Test 149 | public void testCreateProductPriceNull(){ 150 | ProductPojo product = new ProductDataFactory().product(); 151 | product.setPreco(null); 152 | given() 153 | .contentType(ContentType.JSON) 154 | .headers("Authorization", tokenIdAdm) 155 | .body(product) 156 | .when() 157 | .post(baseUrlProduct) 158 | .then() 159 | .statusCode(400) 160 | .body("preco", equalTo("preco deve ser um número")); 161 | } 162 | 163 | @Test 164 | public void testCreateProductWithoutQuantity(){ 165 | ProductPojo product = new ProductDataFactory().productWithoutQuantity(); 166 | given() 167 | .contentType(ContentType.JSON) 168 | .headers("Authorization", tokenIdAdm) 169 | .body(product) 170 | .when() 171 | .post(baseUrlProduct) 172 | .then() 173 | .statusCode(400) 174 | .body("quantidade", equalTo("quantidade deve ser um número")); 175 | } 176 | 177 | @Test 178 | public void testCreateProductQuantityNull(){ 179 | ProductPojo product = new ProductDataFactory().product(); 180 | product.setQuantidade(null); 181 | given() 182 | .contentType(ContentType.JSON) 183 | .headers("Authorization", tokenIdAdm) 184 | .body(product) 185 | .when() 186 | .post(baseUrlProduct) 187 | .then() 188 | .statusCode(400) 189 | .body("quantidade", equalTo("quantidade deve ser um número")); 190 | } 191 | 192 | @Test 193 | public void testCreateProductWithoutDescription(){ 194 | ProductPojo product = new ProductDataFactory().productWithoutDescription(); 195 | given() 196 | .contentType(ContentType.JSON) 197 | .headers("Authorization", tokenIdAdm) 198 | .body(product) 199 | .when() 200 | .post(baseUrlProduct) 201 | .then() 202 | .statusCode(400) 203 | .body("descricao", equalTo("descricao deve ser uma string")); 204 | } 205 | 206 | @Test 207 | public void testCreateProductDescriptionNull(){ 208 | ProductPojo product = new ProductDataFactory().product(); 209 | product.setDescricao(null); 210 | given() 211 | .contentType(ContentType.JSON) 212 | .headers("Authorization", tokenIdAdm) 213 | .body(product) 214 | .when() 215 | .post(baseUrlProduct) 216 | .then() 217 | .statusCode(400) 218 | .body("descricao", equalTo("descricao deve ser uma string")); 219 | } 220 | 221 | @Test 222 | public void testCreateProductFieldRequire(){ 223 | ProductPojo product = new ProductDataFactory().product(); 224 | given() 225 | .headers("Authorization", tokenIdAdm) 226 | .body(product) 227 | .when() 228 | .post(baseUrlProduct) 229 | .then() 230 | .statusCode(400) 231 | .body("nome", equalTo("nome é obrigatório")) 232 | .body("preco", equalTo("preco é obrigatório")) 233 | .body("descricao", equalTo("descricao é obrigatório")) 234 | .body("quantidade", equalTo("quantidade é obrigatório")); 235 | } 236 | } 237 | -------------------------------------------------------------------------------- /src/test/java/tests/product/DeleteProductTest.java: -------------------------------------------------------------------------------- 1 | package tests.product; 2 | 3 | import factories.CarDataFactory; 4 | import factories.ProductDataFactory; 5 | import io.restassured.http.ContentType; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | import pojo.CarPojo; 9 | import pojo.ProductCarPojo; 10 | import pojo.ProductPojo; 11 | import utils.LoginUtil; 12 | 13 | import static io.restassured.RestAssured.given; 14 | import static org.hamcrest.Matchers.equalTo; 15 | import static org.hamcrest.Matchers.notNullValue; 16 | import static utils.BaseUrlUtil.baseUrlCar; 17 | import static utils.BaseUrlUtil.baseUrlProduct; 18 | 19 | public class DeleteProductTest { 20 | 21 | 22 | public String tokenId; 23 | public String tokenIdUser; 24 | public String productId; 25 | public String carTokenId; 26 | 27 | @Before 28 | public void createUsersAndLogin(){ 29 | tokenId = new LoginUtil().loginAdmFix(); 30 | tokenIdUser = new LoginUtil().loginUserFix(); 31 | } 32 | 33 | @Test 34 | public void testDeleteProduct(){ 35 | ProductPojo product = new ProductDataFactory().product(); 36 | productId = given() 37 | .contentType(ContentType.JSON) 38 | .headers("Authorization", tokenId) 39 | .body(product) 40 | .when() 41 | .post(baseUrlProduct) 42 | .then() 43 | .statusCode(201) 44 | .body("message", equalTo("Cadastro realizado com sucesso")) 45 | .body("_id", notNullValue()) 46 | .extract().path("_id"); 47 | given() 48 | .contentType(ContentType.JSON) 49 | .headers("Authorization", tokenId) 50 | .body(product) 51 | .when() 52 | .delete(baseUrlProduct.concat(productId)) 53 | .then() 54 | .statusCode(200) 55 | .body("message", equalTo("Registro excluído com sucesso")); 56 | } 57 | 58 | @Test 59 | public void testDeleteProductAbsent(){ 60 | ProductPojo product = new ProductDataFactory().product(); 61 | given() 62 | .contentType(ContentType.JSON) 63 | .headers("Authorization", tokenId) 64 | .body(product) 65 | .when() 66 | .delete(baseUrlProduct.concat("productId")) 67 | .then() 68 | .statusCode(200) 69 | .body("message", equalTo("Nenhum registro excluído")); 70 | } 71 | 72 | @Test 73 | public void testDeleteProductTokenUser(){ 74 | ProductPojo product = new ProductDataFactory().product(); 75 | productId = given() 76 | .contentType(ContentType.JSON) 77 | .headers("Authorization", tokenId) 78 | .body(product) 79 | .when() 80 | .post(baseUrlProduct) 81 | .then() 82 | .statusCode(201) 83 | .body("message", equalTo("Cadastro realizado com sucesso")) 84 | .body("_id", notNullValue()) 85 | .extract().path("_id"); 86 | 87 | given() 88 | .contentType(ContentType.JSON) 89 | .headers("Authorization", tokenIdUser) 90 | .body(product) 91 | .when() 92 | .delete(baseUrlProduct.concat(productId)) 93 | .then() 94 | .statusCode(403) 95 | .body("message", equalTo("Rota exclusiva para administradores")); 96 | } 97 | 98 | @Test 99 | public void testDeleteProductWithoutToken(){ 100 | ProductPojo product = new ProductDataFactory().product(); 101 | productId = given() 102 | .contentType(ContentType.JSON) 103 | .headers("Authorization", tokenId) 104 | .body(product) 105 | .when() 106 | .post(baseUrlProduct) 107 | .then() 108 | .statusCode(201) 109 | .body("message", equalTo("Cadastro realizado com sucesso")) 110 | .body("_id", notNullValue()) 111 | .extract().path("_id"); 112 | 113 | given() 114 | .contentType(ContentType.JSON) 115 | .headers("Authorization", "tokenIdUser") 116 | .body(product) 117 | .when() 118 | .delete(baseUrlProduct.concat(productId)) 119 | .then() 120 | .statusCode(401) 121 | .body("message", equalTo("Token de acesso ausente, inválido, expirado ou usuário do token não existe mais")); 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /src/test/java/tests/product/ListProductTest.java: -------------------------------------------------------------------------------- 1 | package tests.product; 2 | 3 | import factories.ProductDataFactory; 4 | import io.restassured.http.ContentType; 5 | import org.junit.Test; 6 | import pojo.ProductPojo; 7 | import utils.LoginUtil; 8 | 9 | import static io.restassured.RestAssured.given; 10 | import static org.hamcrest.Matchers.*; 11 | import static utils.BaseUrlUtil.baseUrlProduct; 12 | 13 | public class ListProductTest { 14 | 15 | public String tokenId; 16 | public String productId; 17 | 18 | @Test 19 | public void testListProducts(){ 20 | given() 21 | .contentType(ContentType.JSON) 22 | .when() 23 | .get(baseUrlProduct) 24 | .then() 25 | .statusCode(200) 26 | .body("produtos._id[0]", notNullValue()); 27 | } 28 | 29 | @Test 30 | public void testListProductsForId(){ 31 | tokenId = new LoginUtil().loginAdmFix(); 32 | ProductPojo product = new ProductDataFactory().product(); 33 | productId = given() 34 | .contentType(ContentType.JSON) 35 | .headers("Authorization", tokenId) 36 | .body(product) 37 | .when() 38 | .post(baseUrlProduct) 39 | .then() 40 | .statusCode(201) 41 | .body("message", equalTo("Cadastro realizado com sucesso")) 42 | .body("_id", notNullValue()) 43 | .extract().path("_id"); 44 | given() 45 | .contentType(ContentType.JSON) 46 | .when() 47 | .get(baseUrlProduct.concat(productId)) 48 | .then() 49 | .statusCode(200) 50 | .body("_id[0]", notNullValue()); 51 | } 52 | 53 | @Test 54 | public void testListProductsParams(){ 55 | given() 56 | .contentType(ContentType.JSON) 57 | .queryParam("preco", 100) 58 | .queryParam("quantidade", 3) 59 | .when() 60 | .get(baseUrlProduct) 61 | .then() 62 | .statusCode(200) 63 | .body("produtos.preco[0]", equalTo(100)); 64 | } 65 | 66 | @Test 67 | public void testListProductsParamsIncorrect(){ 68 | given() 69 | .contentType(ContentType.JSON) 70 | .queryParam("Preco", 100) 71 | .queryParam("Quantidade", 3) 72 | .when() 73 | .get(baseUrlProduct) 74 | .then() 75 | .statusCode(400) 76 | .body("Preco", equalTo("Preco não é permitido")) 77 | .body("Quantidade", equalTo("Quantidade não é permitido")); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/test/java/tests/product/UpdateProductTest.java: -------------------------------------------------------------------------------- 1 | package tests.product; 2 | 3 | import factories.ProductDataFactory; 4 | import io.restassured.http.ContentType; 5 | import org.junit.Before; 6 | import org.junit.Test; 7 | import pojo.ProductPojo; 8 | import utils.LoginUtil; 9 | import utils.ProductUtil; 10 | 11 | import static io.restassured.RestAssured.given; 12 | import static org.hamcrest.Matchers.equalTo; 13 | import static org.hamcrest.Matchers.notNullValue; 14 | import static utils.BaseUrlUtil.baseUrlProduct; 15 | 16 | public class UpdateProductTest { 17 | 18 | public String tokenAdm; 19 | public String tokenUser; 20 | public String productId; 21 | 22 | @Before 23 | public void createProductAndToken(){ 24 | tokenAdm = new LoginUtil().loginAdmFix(); 25 | ProductPojo product = new ProductDataFactory().product(); 26 | productId = given() 27 | .contentType(ContentType.JSON) 28 | .headers("Authorization", tokenAdm) 29 | .body(product) 30 | .when() 31 | .post(baseUrlProduct) 32 | .then() 33 | .statusCode(201) 34 | .body("message", equalTo("Cadastro realizado com sucesso")) 35 | .body("_id", notNullValue()) 36 | .extract().path("_id"); 37 | } 38 | 39 | @Test 40 | public void testUpdateProduct(){ 41 | ProductPojo product = new ProductDataFactory().product(); 42 | given() 43 | .contentType(ContentType.JSON) 44 | .headers("Authorization", tokenAdm) 45 | .body(product) 46 | .when() 47 | .put(baseUrlProduct.concat(productId)) 48 | .then() 49 | .statusCode(200) 50 | .body("message", equalTo("Registro alterado com sucesso")); 51 | } 52 | 53 | @Test 54 | public void testUpdateProductNameExistent(){ 55 | ProductPojo product = new ProductDataFactory().product(); 56 | ProductUtil prod = new ProductUtil().createProduct(); 57 | product.setNome("Nome cadastrado"); 58 | given() 59 | .contentType(ContentType.JSON) 60 | .headers("Authorization", tokenAdm) 61 | .body(product) 62 | .when() 63 | .put(baseUrlProduct.concat(productId)) 64 | .then() 65 | .statusCode(400) 66 | .body("message", equalTo("Já existe produto com esse nome")); 67 | } 68 | 69 | @Test 70 | public void testUpdateProductWithoutName(){ 71 | ProductPojo productSn = new ProductDataFactory().productWithoutName(); 72 | given() 73 | .contentType(ContentType.JSON) 74 | .headers("Authorization", tokenAdm) 75 | .body(productSn) 76 | .when() 77 | .put(baseUrlProduct.concat(productId)) 78 | .then() 79 | .statusCode(400) 80 | .body("nome", equalTo("nome deve ser uma string")); 81 | } 82 | 83 | @Test 84 | public void testUpdateProductNameNull(){ 85 | ProductPojo productSn = new ProductDataFactory().product(); 86 | productSn.setNome(null); 87 | given() 88 | .contentType(ContentType.JSON) 89 | .headers("Authorization", tokenAdm) 90 | .body(productSn) 91 | .when() 92 | .put(baseUrlProduct.concat(productId)) 93 | .then() 94 | .statusCode(400) 95 | .body("nome", equalTo("nome deve ser uma string")); 96 | } 97 | 98 | @Test 99 | public void testUpdateProductWithoutDescription(){ 100 | ProductPojo productSn = new ProductDataFactory().productWithoutDescription(); 101 | given() 102 | .contentType(ContentType.JSON) 103 | .headers("Authorization", tokenAdm) 104 | .body(productSn) 105 | .when() 106 | .put(baseUrlProduct.concat(productId)) 107 | .then() 108 | .statusCode(400) 109 | .body("descricao", equalTo("descricao deve ser uma string")); 110 | } 111 | 112 | @Test 113 | public void testUpdateProductDescriptionNull(){ 114 | ProductPojo productSn = new ProductDataFactory().product(); 115 | productSn.setDescricao(null); 116 | given() 117 | .contentType(ContentType.JSON) 118 | .headers("Authorization", tokenAdm) 119 | .body(productSn) 120 | .when() 121 | .put(baseUrlProduct.concat(productId)) 122 | .then() 123 | .statusCode(400) 124 | .body("descricao", equalTo("descricao deve ser uma string")); 125 | } 126 | 127 | @Test 128 | public void testUpdateProductWithoutPrice(){ 129 | ProductPojo productSn = new ProductDataFactory().productWithoutPrice(); 130 | given() 131 | .contentType(ContentType.JSON) 132 | .headers("Authorization", tokenAdm) 133 | .body(productSn) 134 | .when() 135 | .put(baseUrlProduct.concat(productId)) 136 | .then() 137 | .statusCode(400) 138 | .body("preco", equalTo("preco deve ser um número")); 139 | } 140 | 141 | @Test 142 | public void testUpdateProductPriceNull(){ 143 | ProductPojo productSn = new ProductDataFactory().product(); 144 | productSn.setPreco(null); 145 | given() 146 | .contentType(ContentType.JSON) 147 | .headers("Authorization", tokenAdm) 148 | .body(productSn) 149 | .when() 150 | .put(baseUrlProduct.concat(productId)) 151 | .then() 152 | .statusCode(400) 153 | .body("preco", equalTo("preco deve ser um número")); 154 | } 155 | 156 | @Test 157 | public void testUpdateProductWithoutQuantity(){ 158 | ProductPojo productSn = new ProductDataFactory().productWithoutQuantity(); 159 | given() 160 | .contentType(ContentType.JSON) 161 | .headers("Authorization", tokenAdm) 162 | .body(productSn) 163 | .when() 164 | .put(baseUrlProduct.concat(productId)) 165 | .then() 166 | .statusCode(400) 167 | .body("quantidade", equalTo("quantidade deve ser um número")); 168 | } 169 | 170 | @Test 171 | public void testUpdateProductQuantityNull(){ 172 | ProductPojo productSn = new ProductDataFactory().product(); 173 | productSn.setQuantidade(null); 174 | given() 175 | .contentType(ContentType.JSON) 176 | .headers("Authorization", tokenAdm) 177 | .body(productSn) 178 | .when() 179 | .put(baseUrlProduct.concat(productId)) 180 | .then() 181 | .statusCode(400) 182 | .body("quantidade", equalTo("quantidade deve ser um número")); 183 | } 184 | 185 | @Test 186 | public void testUpdateProductIdUser(){ 187 | tokenUser = new LoginUtil().loginUserFix(); 188 | ProductPojo product = new ProductDataFactory().product(); 189 | given() 190 | .contentType(ContentType.JSON) 191 | .headers("Authorization", tokenUser) 192 | .body(product) 193 | .when() 194 | .put(baseUrlProduct.concat(productId)) 195 | .then() 196 | .statusCode(403) 197 | .body("message", equalTo("Rota exclusiva para administradores")); 198 | } 199 | 200 | @Test 201 | public void testUpdateProductWithoutToken(){ 202 | ProductPojo product = new ProductDataFactory().product(); 203 | given() 204 | .contentType(ContentType.JSON) 205 | .headers("Authorization", "tokenIdUser") 206 | .body(product) 207 | .when() 208 | .put(baseUrlProduct.concat(productId)) 209 | .then() 210 | .statusCode(401) 211 | .body("message", equalTo("Token de acesso ausente, inválido, expirado ou usuário do token não existe mais")); 212 | } 213 | 214 | @Test 215 | public void testUpdateProductIdIncorrect(){ 216 | ProductPojo product = new ProductDataFactory().product(); 217 | given() 218 | .contentType(ContentType.JSON) 219 | .headers("Authorization", tokenAdm) 220 | .body(product) 221 | .when() 222 | .put(baseUrlProduct.concat("productId")) 223 | .then() 224 | .statusCode(201) 225 | .body("message", equalTo("Cadastro realizado com sucesso")); 226 | } 227 | 228 | @Test 229 | public void testUpdateProductFieldsRequire(){ 230 | ProductPojo product = new ProductDataFactory().product(); 231 | given() 232 | .headers("Authorization", tokenAdm) 233 | .body(product) 234 | .when() 235 | .put(baseUrlProduct.concat(productId)) 236 | .then() 237 | .statusCode(400) 238 | .body("nome", equalTo("nome é obrigatório")) 239 | .body("preco", equalTo("preco é obrigatório")) 240 | .body("descricao", equalTo("descricao é obrigatório")) 241 | .body("quantidade", equalTo("quantidade é obrigatório")); 242 | } 243 | } 244 | -------------------------------------------------------------------------------- /src/test/java/tests/users/CreateUserTest.java: -------------------------------------------------------------------------------- 1 | package tests.users; 2 | 3 | import factories.UserDataFactory; 4 | import io.restassured.http.ContentType; 5 | import org.junit.Test; 6 | import pojo.CreateUsersPojo; 7 | import utils.UserUtil; 8 | 9 | import static io.restassured.RestAssured.given; 10 | import static org.hamcrest.Matchers.equalTo; 11 | import static org.hamcrest.Matchers.notNullValue; 12 | import static utils.BaseUrlUtil.baseUrlUser; 13 | import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath; 14 | 15 | public class CreateUserTest { 16 | 17 | @Test 18 | public void testUserContract(){ 19 | CreateUsersPojo user = new UserDataFactory().userAdm(); 20 | given() 21 | .contentType(ContentType.JSON) 22 | .body(user) 23 | .when() 24 | .post(baseUrlUser) 25 | .then() 26 | .statusCode(201) 27 | .body(matchesJsonSchemaInClasspath("schema/user-schema.json")); 28 | } 29 | 30 | @Test 31 | public void testCreateAdmUser(){ 32 | CreateUsersPojo user = new UserDataFactory().userAdm(); 33 | given() 34 | .contentType(ContentType.JSON) 35 | .body(user) 36 | .when() 37 | .post(baseUrlUser) 38 | .then() 39 | .statusCode(201) 40 | .body("message", equalTo("Cadastro realizado com sucesso")) 41 | .body("_id", notNullValue()); 42 | } 43 | 44 | @Test 45 | public void testCreateUser(){ 46 | CreateUsersPojo user = new UserDataFactory().userAdm(); 47 | user.setAdministrador("false"); 48 | given() 49 | .contentType(ContentType.JSON) 50 | .body(user) 51 | .when() 52 | .post(baseUrlUser) 53 | .then() 54 | .statusCode(201) 55 | .body("message", equalTo("Cadastro realizado com sucesso")) 56 | .body("_id", notNullValue()); 57 | } 58 | 59 | @Test 60 | public void testCreateUserAdmWithoutType(){ 61 | CreateUsersPojo user = new UserDataFactory().userWithoutTypeAdm(); 62 | given() 63 | .contentType(ContentType.JSON) 64 | .body(user) 65 | .when() 66 | .post(baseUrlUser) 67 | .then() 68 | .statusCode(400) 69 | .body("administrador", equalTo("administrador deve ser 'true' ou 'false'")); 70 | } 71 | 72 | @Test 73 | public void testCreateUserTypeAdmNull(){ 74 | CreateUsersPojo user = new UserDataFactory().userAdm(); 75 | user.setAdministrador(null); 76 | given() 77 | .contentType(ContentType.JSON) 78 | .body(user) 79 | .when() 80 | .post(baseUrlUser) 81 | .then() 82 | .statusCode(400) 83 | .body("administrador", equalTo("administrador deve ser 'true' ou 'false'")); 84 | } 85 | 86 | @Test 87 | public void testCreateUserTypeAdmIncorrect(){ 88 | CreateUsersPojo user = new UserDataFactory().userAdm(); 89 | user.setAdministrador("ok"); 90 | given() 91 | .contentType(ContentType.JSON) 92 | .body(user) 93 | .when() 94 | .post(baseUrlUser) 95 | .then() 96 | .statusCode(400) 97 | .body("administrador", equalTo("administrador deve ser 'true' ou 'false'")); 98 | } 99 | 100 | @Test 101 | public void testCreateUserWithoutName(){ 102 | CreateUsersPojo user = new UserDataFactory().userWithoutName(); 103 | given() 104 | .contentType(ContentType.JSON) 105 | .body(user) 106 | .when() 107 | .post(baseUrlUser) 108 | .then() 109 | .statusCode(400) 110 | .body("nome", equalTo("nome deve ser uma string")); 111 | } 112 | 113 | @Test 114 | public void testCreateUserNameNull(){ 115 | CreateUsersPojo user = new UserDataFactory().userAdm(); 116 | user.setNome(null); 117 | given() 118 | .contentType(ContentType.JSON) 119 | .body(user) 120 | .when() 121 | .post(baseUrlUser) 122 | .then() 123 | .statusCode(400) 124 | .body("nome", equalTo("nome deve ser uma string")); 125 | } 126 | 127 | @Test 128 | public void testCreateUserNameEmpty(){ 129 | CreateUsersPojo user = new UserDataFactory().userAdm(); 130 | user.setNome(""); 131 | given() 132 | .contentType(ContentType.JSON) 133 | .body(user) 134 | .when() 135 | .post(baseUrlUser) 136 | .then() 137 | .statusCode(400) 138 | .body("nome", equalTo("nome não pode ficar em branco")); 139 | } 140 | 141 | @Test 142 | public void testCreateUserWithoutEmail(){ 143 | CreateUsersPojo user = new UserDataFactory().userWithoutEmail(); 144 | given() 145 | .contentType(ContentType.JSON) 146 | .body(user) 147 | .when() 148 | .post(baseUrlUser) 149 | .then() 150 | .statusCode(400) 151 | .body("email", equalTo("email deve ser uma string")); 152 | } 153 | 154 | @Test 155 | public void testCreateUserEmailIncorrect(){ 156 | CreateUsersPojo user = new UserDataFactory().userAdm(); 157 | user.setEmail("2"); 158 | given() 159 | .contentType(ContentType.JSON) 160 | .body(user) 161 | .when() 162 | .post(baseUrlUser) 163 | .then() 164 | .statusCode(400) 165 | .body("email", equalTo("email deve ser um email válido")); 166 | } 167 | 168 | @Test 169 | public void testCreateUserEmailExistent(){ 170 | UserUtil userAdm = new UserUtil().createUserAdm(); 171 | CreateUsersPojo user = new UserDataFactory().userAdm(); 172 | user.setEmail("misael@qa.com.br"); 173 | given() 174 | .contentType(ContentType.JSON) 175 | .body(user) 176 | .when() 177 | .post(baseUrlUser) 178 | .then() 179 | .statusCode(400) 180 | .body("message", equalTo("Este email já está sendo usado")); 181 | } 182 | 183 | @Test 184 | public void testCreateUserEmailEmpty(){ 185 | CreateUsersPojo user = new UserDataFactory().userAdm(); 186 | user.setEmail(""); 187 | given() 188 | .contentType(ContentType.JSON) 189 | .body(user) 190 | .when() 191 | .post(baseUrlUser) 192 | .then() 193 | .statusCode(400) 194 | .body("email", equalTo("email não pode ficar em branco")); 195 | } 196 | 197 | @Test 198 | public void testCreateUserWithoutPassword(){ 199 | CreateUsersPojo user = new UserDataFactory().userWithoutPassword(); 200 | given() 201 | .contentType(ContentType.JSON) 202 | .body(user) 203 | .when() 204 | .post(baseUrlUser) 205 | .then() 206 | .statusCode(400) 207 | .body("password", equalTo("password deve ser uma string")); 208 | } 209 | 210 | @Test 211 | public void testCreateUserPasswordNull(){ 212 | CreateUsersPojo user = new UserDataFactory().userAdm(); 213 | user.setPassword(null); 214 | given() 215 | .contentType(ContentType.JSON) 216 | .body(user) 217 | .when() 218 | .post(baseUrlUser) 219 | .then() 220 | .statusCode(400) 221 | .body("password", equalTo("password deve ser uma string")); 222 | } 223 | 224 | @Test 225 | public void testCreateUserPasswordEmpty(){ 226 | CreateUsersPojo user = new UserDataFactory().userAdm(); 227 | user.setPassword(""); 228 | given() 229 | .contentType(ContentType.JSON) 230 | .body(user) 231 | .when() 232 | .post(baseUrlUser) 233 | .then() 234 | .statusCode(400) 235 | .body("password", equalTo("password não pode ficar em branco")); 236 | } 237 | 238 | @Test 239 | public void testCreateUserFieldsRequired(){ 240 | CreateUsersPojo user = new UserDataFactory().userAdm(); 241 | given() 242 | .body(user) 243 | .when() 244 | .post(baseUrlUser) 245 | .then() 246 | .statusCode(400) 247 | .body("nome", equalTo("nome é obrigatório")) 248 | .body("email", equalTo("email é obrigatório")) 249 | .body("password", equalTo("password é obrigatório")) 250 | .body("administrador", equalTo("administrador é obrigatório")); 251 | 252 | } 253 | } 254 | -------------------------------------------------------------------------------- /src/test/java/tests/users/DeleteUserTest.java: -------------------------------------------------------------------------------- 1 | package tests.users; 2 | 3 | import factories.CarDataFactory; 4 | import factories.ProductDataFactory; 5 | import factories.UserDataFactory; 6 | import io.restassured.http.ContentType; 7 | import org.junit.Before; 8 | import org.junit.Test; 9 | import pojo.CarPojo; 10 | import pojo.CreateUsersPojo; 11 | import pojo.ProductCarPojo; 12 | import pojo.ProductPojo; 13 | import utils.LoginUtil; 14 | import utils.UserUtil; 15 | 16 | import static io.restassured.RestAssured.given; 17 | import static org.hamcrest.Matchers.equalTo; 18 | import static org.hamcrest.Matchers.notNullValue; 19 | import static utils.BaseUrlUtil.*; 20 | 21 | public class DeleteUserTest { 22 | 23 | public String ID; 24 | public String tokenId; 25 | public String idUser; 26 | public String productId; 27 | 28 | @Before 29 | public void createUsersAndLogin(){ 30 | CreateUsersPojo user = new UserDataFactory().userAdm(); 31 | UserUtil us = new UserUtil().userCar(); 32 | 33 | idUser = given() 34 | .contentType(ContentType.JSON) 35 | .queryParam("email","misael@carro.com.br") 36 | .when() 37 | .get(baseUrlUser) 38 | .then() 39 | .statusCode(200) 40 | .extract().path("usuarios[0]._id"); 41 | 42 | tokenId = new LoginUtil().loginUserCar(); 43 | } 44 | 45 | 46 | @Test 47 | public void testDeleteUser(){ 48 | CreateUsersPojo user = new UserDataFactory().userAdm(); 49 | ID = given() 50 | .contentType(ContentType.JSON) 51 | .body(user) 52 | .when() 53 | .post(baseUrlUser) 54 | .then() 55 | .statusCode(201) 56 | .extract().path("_id"); 57 | 58 | given() 59 | .contentType(ContentType.JSON) 60 | .when() 61 | .delete(baseUrlUser.concat(ID)) 62 | .then() 63 | .statusCode(200) 64 | .body("message", equalTo("Registro excluído com sucesso")); 65 | } 66 | 67 | @Test 68 | public void testDeleteUserIdIncorrect(){ 69 | given() 70 | .contentType(ContentType.JSON) 71 | .when() 72 | .delete(baseUrlUser.concat("ID")) 73 | .then() 74 | .statusCode(200) 75 | .body("message", equalTo("Nenhum registro excluído")); 76 | } 77 | 78 | @Test 79 | public void testDeleteUserWithCar(){ 80 | ProductPojo product = new ProductDataFactory().product(); 81 | productId = given() 82 | .contentType(ContentType.JSON) 83 | .headers("Authorization", tokenId) 84 | .body(product) 85 | .when() 86 | .post(baseUrlProduct) 87 | .then() 88 | .statusCode(201) 89 | .body("message", equalTo("Cadastro realizado com sucesso")) 90 | .body("_id", notNullValue()) 91 | .extract().path("_id"); 92 | 93 | CarPojo car = new CarDataFactory().car(); 94 | car.addProducts((new ProductCarPojo(productId,1))); 95 | given() 96 | .contentType(ContentType.JSON) 97 | .headers("Authorization", tokenId) 98 | .body(car) 99 | .when() 100 | .post(baseUrlCar) 101 | .then(); 102 | 103 | given() 104 | .contentType(ContentType.JSON) 105 | .headers("Authorization", tokenId) 106 | .body(product) 107 | .when() 108 | .delete(baseUrlUser.concat(idUser)) 109 | .then() 110 | .statusCode(400) 111 | .body("message", equalTo("Não é permitido excluir usuário com carrinho cadastrado")); 112 | 113 | given() 114 | .contentType(ContentType.JSON) 115 | .headers("Authorization", tokenId) 116 | .delete(baseUrlCar.concat("concluir-compra")) 117 | .then() 118 | .statusCode(200); 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /src/test/java/tests/users/ListUserTest.java: -------------------------------------------------------------------------------- 1 | package tests.users; 2 | 3 | import io.restassured.http.ContentType; 4 | import org.junit.Test; 5 | import utils.UserUtil; 6 | 7 | import static io.restassured.RestAssured.given; 8 | import static org.hamcrest.Matchers.equalTo; 9 | import static org.hamcrest.Matchers.notNullValue; 10 | import static utils.BaseUrlUtil.baseUrlUser; 11 | 12 | public class ListUserTest { 13 | 14 | public String id; 15 | 16 | @Test 17 | public void testListUsersAllParams(){ 18 | id = new UserUtil().createUserId(); 19 | given() 20 | .contentType(ContentType.JSON) 21 | .queryParam("_id", id) 22 | .queryParam("password", "teste") 23 | .queryParam("administrador", "true") 24 | .when() 25 | .get(baseUrlUser) 26 | .then() 27 | .statusCode(200) 28 | .body("usuarios.password[0]", equalTo("teste")) 29 | .body("usuarios.administrador[0]", equalTo("true")) 30 | .body("usuarios._id[0]", equalTo(id)); 31 | } 32 | 33 | @Test 34 | public void testListUserWithoutParams(){ 35 | given() 36 | .contentType(ContentType.JSON) 37 | .when() 38 | .get(baseUrlUser) 39 | .then() 40 | .statusCode(200) 41 | .body("usuarios.nome[0]", notNullValue()) 42 | .body("usuarios.nome[1]", notNullValue()); 43 | } 44 | 45 | @Test 46 | public void testListUserTypeParamsIncorrect(){ 47 | given() 48 | .contentType(ContentType.JSON) 49 | .queryParam("_id", 1.0f) 50 | .queryParam("nome", 1) 51 | .queryParam("email", 1) 52 | .queryParam("password", 1) 53 | .queryParam("administrador", 1) 54 | .when() 55 | .get(baseUrlUser) 56 | .then() 57 | .statusCode(400) 58 | .body("email", equalTo("email deve ser uma string")) 59 | .body("administrador", equalTo("administrador deve ser 'true' ou 'false'")); 60 | } 61 | 62 | @Test 63 | public void testListUserParamsIncorrect(){ 64 | given() 65 | .contentType(ContentType.JSON) 66 | .queryParam("id", 1.0f) 67 | .when() 68 | .get(baseUrlUser) 69 | .then() 70 | .statusCode(400) 71 | .body("id", equalTo("id não é permitido")); 72 | } 73 | 74 | @Test 75 | public void testListUserForId(){ 76 | id = new UserUtil().createUserId(); 77 | given() 78 | .contentType(ContentType.JSON) 79 | .when() 80 | .get(baseUrlUser.concat(id)) 81 | .then() 82 | .statusCode(200) 83 | .body("_id", equalTo(id)); 84 | } 85 | 86 | @Test 87 | public void testListUserIdIncorrect(){ 88 | given() 89 | .contentType(ContentType.JSON) 90 | .when() 91 | .get(baseUrlUser.concat("id")) 92 | .then() 93 | .statusCode(400) 94 | .body("message", equalTo("Usuário não encontrado")); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/test/java/tests/users/UpdateUserTest.java: -------------------------------------------------------------------------------- 1 | package tests.users; 2 | 3 | import factories.UserDataFactory; 4 | import io.restassured.http.ContentType; 5 | import org.junit.Before; 6 | import org.junit.Test; 7 | import pojo.CreateUsersPojo; 8 | import utils.UserUtil; 9 | 10 | import static io.restassured.RestAssured.given; 11 | import static org.hamcrest.Matchers.equalTo; 12 | import static org.hamcrest.Matchers.notNullValue; 13 | import static utils.BaseUrlUtil.baseUrlUser; 14 | 15 | public class UpdateUserTest { 16 | public String id; 17 | 18 | @Before 19 | public void createUser() { 20 | id = new UserUtil().createUserId(); 21 | } 22 | 23 | @Test 24 | public void testUpdateUserAdm(){ 25 | CreateUsersPojo user = new UserDataFactory().userAdm(); 26 | given() 27 | .contentType(ContentType.JSON) 28 | .body(user) 29 | .when() 30 | .put(baseUrlUser.concat(id)) 31 | .then() 32 | .statusCode(200) 33 | .body("message", equalTo("Registro alterado com sucesso")); 34 | } 35 | 36 | @Test 37 | public void testUpdateUser(){ 38 | CreateUsersPojo user = new UserDataFactory().userAdm(); 39 | user.setAdministrador("false"); 40 | given() 41 | .contentType(ContentType.JSON) 42 | .body(user) 43 | .when() 44 | .put(baseUrlUser.concat(id)) 45 | .then() 46 | .statusCode(200) 47 | .body("message", equalTo("Registro alterado com sucesso")); 48 | } 49 | 50 | @Test 51 | public void testUpdateUserIncorrectId(){ 52 | CreateUsersPojo user = new UserDataFactory().userAdm(); 53 | user.setAdministrador("false"); 54 | given() 55 | .contentType(ContentType.JSON) 56 | .body(user) 57 | .when() 58 | .put(baseUrlUser.concat("id")) 59 | .then() 60 | .statusCode(201) 61 | .body("_id", notNullValue()) 62 | .body("message", equalTo("Cadastro realizado com sucesso")); 63 | } 64 | 65 | @Test 66 | public void testUpdateUserWithoutTypeAdm(){ 67 | CreateUsersPojo user = new UserDataFactory().userWithoutTypeAdm(); 68 | given() 69 | .contentType(ContentType.JSON) 70 | .body(user) 71 | .when() 72 | .put(baseUrlUser.concat(id)) 73 | .then() 74 | .statusCode(400) 75 | .body("administrador", equalTo("administrador deve ser 'true' ou 'false'")); 76 | } 77 | 78 | @Test 79 | public void testUpdateUserTypeAdmNull(){ 80 | CreateUsersPojo user = new UserDataFactory().userAdm(); 81 | user.setAdministrador(null); 82 | given() 83 | .contentType(ContentType.JSON) 84 | .body(user) 85 | .when() 86 | .put(baseUrlUser.concat(id)) 87 | .then() 88 | .statusCode(400) 89 | .body("administrador", equalTo("administrador deve ser 'true' ou 'false'")); 90 | } 91 | 92 | @Test 93 | public void testUpdateUserTypeAdmIncorrect(){ 94 | CreateUsersPojo user = new UserDataFactory().userAdm(); 95 | user.setAdministrador("ok"); 96 | given() 97 | .contentType(ContentType.JSON) 98 | .body(user) 99 | .when() 100 | .put(baseUrlUser.concat(id)) 101 | .then() 102 | .statusCode(400) 103 | .body("administrador", equalTo("administrador deve ser 'true' ou 'false'")); 104 | } 105 | 106 | @Test 107 | public void testUpdateUserWithoutName(){ 108 | CreateUsersPojo user = new UserDataFactory().userWithoutName(); 109 | given() 110 | .contentType(ContentType.JSON) 111 | .body(user) 112 | .when() 113 | .put(baseUrlUser.concat(id)) 114 | .then() 115 | .statusCode(400) 116 | .body("nome", equalTo("nome deve ser uma string")); 117 | } 118 | 119 | @Test 120 | public void testUpdateUserNameNull(){ 121 | CreateUsersPojo user = new UserDataFactory().userAdm(); 122 | user.setNome(null); 123 | given() 124 | .contentType(ContentType.JSON) 125 | .body(user) 126 | .when() 127 | .put(baseUrlUser.concat(id)) 128 | .then() 129 | .statusCode(400) 130 | .body("nome", equalTo("nome deve ser uma string")); 131 | } 132 | 133 | @Test 134 | public void testUpdateUserNameEmpty(){ 135 | CreateUsersPojo user = new UserDataFactory().userAdm(); 136 | user.setNome(""); 137 | given() 138 | .contentType(ContentType.JSON) 139 | .body(user) 140 | .when() 141 | .put(baseUrlUser.concat(id)) 142 | .then() 143 | .statusCode(400) 144 | .body("nome", equalTo("nome não pode ficar em branco")); 145 | } 146 | 147 | @Test 148 | public void testUpdateUserWithoutEmail(){ 149 | CreateUsersPojo user = new UserDataFactory().userWithoutEmail(); 150 | given() 151 | .contentType(ContentType.JSON) 152 | .body(user) 153 | .when() 154 | .put(baseUrlUser.concat(id)) 155 | .then() 156 | .statusCode(400) 157 | .body("email", equalTo("email deve ser uma string")); 158 | } 159 | 160 | @Test 161 | public void testUpdateUserEmailIncorrect(){ 162 | CreateUsersPojo user = new UserDataFactory().userAdm(); 163 | user.setEmail("2"); 164 | given() 165 | .contentType(ContentType.JSON) 166 | .body(user) 167 | .when() 168 | .put(baseUrlUser.concat(id)) 169 | .then() 170 | .statusCode(400) 171 | .body("email", equalTo("email deve ser um email válido")); 172 | } 173 | 174 | @Test 175 | public void testUpdateUserEmailExistent(){ 176 | CreateUsersPojo user = new UserDataFactory().userAdm(); 177 | user.setEmail("batatinhafrita@123.com.br"); 178 | given() 179 | .contentType(ContentType.JSON) 180 | .body(user) 181 | .when() 182 | .post(baseUrlUser); 183 | given() 184 | .contentType(ContentType.JSON) 185 | .body(user) 186 | .when() 187 | .put(baseUrlUser.concat(id)) 188 | .then() 189 | .statusCode(400) 190 | .body("message", equalTo("Este email já está sendo usado")); 191 | } 192 | 193 | @Test 194 | public void testUpdateUserEmptyEmail(){ 195 | CreateUsersPojo user = new UserDataFactory().userAdm(); 196 | user.setEmail(""); 197 | given() 198 | .contentType(ContentType.JSON) 199 | .body(user) 200 | .when() 201 | .put(baseUrlUser.concat(id)) 202 | .then() 203 | .statusCode(400) 204 | .body("email", equalTo("email não pode ficar em branco")); 205 | } 206 | 207 | @Test 208 | public void testUpdateUserWithoutPassword(){ 209 | CreateUsersPojo user = new UserDataFactory().userWithoutPassword(); 210 | given() 211 | .contentType(ContentType.JSON) 212 | .body(user) 213 | .when() 214 | .put(baseUrlUser.concat(id)) 215 | .then() 216 | .statusCode(400) 217 | .body("password", equalTo("password deve ser uma string")); 218 | } 219 | 220 | @Test 221 | public void testUpdateUserPasswordNull(){ 222 | CreateUsersPojo user = new UserDataFactory().userAdm(); 223 | user.setPassword(null); 224 | given() 225 | .contentType(ContentType.JSON) 226 | .body(user) 227 | .when() 228 | .put(baseUrlUser.concat(id)) 229 | .then() 230 | .statusCode(400) 231 | .body("password", equalTo("password deve ser uma string")); 232 | } 233 | 234 | @Test 235 | public void testUpdateUserPasswordEmpty(){ 236 | CreateUsersPojo user = new UserDataFactory().userAdm(); 237 | user.setPassword(""); 238 | given() 239 | .contentType(ContentType.JSON) 240 | .body(user) 241 | .when() 242 | .put(baseUrlUser.concat(id)) 243 | .then() 244 | .statusCode(400) 245 | .body("password", equalTo("password não pode ficar em branco")); 246 | } 247 | 248 | @Test 249 | public void testUpdateUserFieldsRequired(){ 250 | CreateUsersPojo user = new UserDataFactory().userAdm(); 251 | given() 252 | .body(user) 253 | .when() 254 | .put(baseUrlUser.concat(id)) 255 | .then() 256 | .statusCode(400) 257 | .body("nome", equalTo("nome é obrigatório")) 258 | .body("email", equalTo("email é obrigatório")) 259 | .body("password", equalTo("password é obrigatório")) 260 | .body("administrador", equalTo("administrador é obrigatório")); 261 | } 262 | } 263 | -------------------------------------------------------------------------------- /src/test/java/utils/BaseUrlUtil.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | public class BaseUrlUtil { 4 | public static String baseUrlLogin = "https://serverest.dev/login"; 5 | public static String baseUrlUser = "https://serverest.dev/usuarios/"; 6 | public static String baseUrlProduct = "https://serverest.dev/produtos/"; 7 | public static String baseUrlCar = "https://serverest.dev/carrinhos/"; 8 | } 9 | -------------------------------------------------------------------------------- /src/test/java/utils/LoginUtil.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | import factories.LoginDataFactory; 4 | import io.restassured.http.ContentType; 5 | import pojo.LoginPojo; 6 | 7 | import static io.restassured.RestAssured.given; 8 | import static org.hamcrest.Matchers.equalTo; 9 | import static org.hamcrest.Matchers.notNullValue; 10 | import static utils.BaseUrlUtil.baseUrlLogin; 11 | 12 | public class LoginUtil { 13 | 14 | String tokenIdAdm; 15 | String tokenIdUser; 16 | 17 | public String loginAdmFix(){ 18 | UserUtil user = new UserUtil().createUserAdm(); 19 | LoginPojo login = LoginDataFactory.loginSuccess(); 20 | tokenIdAdm = given() 21 | .contentType(ContentType.JSON) 22 | .body(login) 23 | .when() 24 | .post(baseUrlLogin) 25 | .then() 26 | .statusCode(200) 27 | .body("authorization", notNullValue()) 28 | .body("message", equalTo("Login realizado com sucesso")) 29 | .extract().path("authorization"); 30 | return tokenIdAdm; 31 | } 32 | 33 | public String loginUserFix(){ 34 | UserUtil user = new UserUtil().createUser(); 35 | LoginPojo login = LoginDataFactory.loginSuccess(); 36 | login.setEmail("misael@email.com"); 37 | tokenIdUser = given() 38 | .contentType(ContentType.JSON) 39 | .body(login) 40 | .when() 41 | .post(baseUrlLogin) 42 | .then() 43 | .statusCode(200) 44 | .body("authorization", notNullValue()) 45 | .body("message", equalTo("Login realizado com sucesso")) 46 | .extract().path("authorization"); 47 | return tokenIdUser; 48 | } 49 | 50 | public String loginUserCar(){ 51 | UserUtil user = new UserUtil().userCar(); 52 | LoginPojo login = LoginDataFactory.loginSuccess(); 53 | login.setEmail("misael@carro.com.br"); 54 | tokenIdUser = given() 55 | .contentType(ContentType.JSON) 56 | .body(login) 57 | .when() 58 | .post(baseUrlLogin) 59 | .then() 60 | .statusCode(200) 61 | .body("authorization", notNullValue()) 62 | .body("message", equalTo("Login realizado com sucesso")) 63 | .extract().path("authorization"); 64 | return tokenIdUser; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/test/java/utils/ProductUtil.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | import factories.ProductDataFactory; 4 | import io.restassured.http.ContentType; 5 | import pojo.ProductPojo; 6 | 7 | import static io.restassured.RestAssured.given; 8 | import static utils.BaseUrlUtil.baseUrlProduct; 9 | 10 | public class ProductUtil { 11 | public String tokenAdm; 12 | 13 | public ProductUtil createProduct(){ 14 | tokenAdm = new LoginUtil().loginAdmFix(); 15 | ProductPojo product = new ProductDataFactory().product(); 16 | product.setNome("Nome cadastrado"); 17 | given() 18 | .contentType(ContentType.JSON) 19 | .headers("Authorization", tokenAdm) 20 | .body(product) 21 | .when() 22 | .post(baseUrlProduct) 23 | .then(); 24 | return null; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/utils/UserUtil.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | import factories.UserDataFactory; 4 | import io.restassured.http.ContentType; 5 | import pojo.CreateUsersPojo; 6 | 7 | import static io.restassured.RestAssured.given; 8 | import static utils.BaseUrlUtil.baseUrlUser; 9 | 10 | public class UserUtil { 11 | 12 | public String id; 13 | 14 | public UserUtil createUserAdm(){ 15 | CreateUsersPojo user = new UserDataFactory().userAdm(); 16 | user.setNome("Misael Reis"); 17 | user.setEmail("misael@qa.com.br"); 18 | given() 19 | .contentType(ContentType.JSON) 20 | .body(user) 21 | .when() 22 | .post(baseUrlUser) 23 | .then(); 24 | return null; 25 | } 26 | 27 | public UserUtil createUserAdmCar(){ 28 | CreateUsersPojo user = new UserDataFactory().userAdm(); 29 | user.setNome("Misael Reis"); 30 | user.setEmail("misael@test.com"); 31 | given() 32 | .contentType(ContentType.JSON) 33 | .body(user) 34 | .when() 35 | .post(baseUrlUser) 36 | .then(); 37 | return null; 38 | } 39 | 40 | public UserUtil createUser(){ 41 | CreateUsersPojo user = new UserDataFactory().userAdm(); 42 | user.setNome("Misael Usuario"); 43 | user.setEmail("misael@email.com"); 44 | user.setAdministrador("false"); 45 | given() 46 | .contentType(ContentType.JSON) 47 | .body(user) 48 | .when() 49 | .post(baseUrlUser) 50 | .then(); 51 | return null; 52 | } 53 | 54 | public String createUserId(){ 55 | CreateUsersPojo user = new UserDataFactory().userAdm(); 56 | id = given() 57 | .contentType(ContentType.JSON) 58 | .body(user) 59 | .when() 60 | .post(baseUrlUser) 61 | .then() 62 | .extract().path("_id"); 63 | return id; 64 | } 65 | 66 | public UserUtil userCar() { 67 | CreateUsersPojo user = new UserDataFactory().userAdm(); 68 | user.setNome("Misael carro"); 69 | user.setEmail("misael@carro.com.br"); 70 | given() 71 | .contentType(ContentType.JSON) 72 | .body(user) 73 | .when() 74 | .post(baseUrlUser) 75 | .then(); 76 | return null; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/test/resources/schema/car-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#", 3 | "type": "object", 4 | "properties": { 5 | "message": { 6 | "type": "string" 7 | }, 8 | "_id": { 9 | "type": "string" 10 | } 11 | }, 12 | "required": [ 13 | "message", 14 | "_id" 15 | ] 16 | } -------------------------------------------------------------------------------- /src/test/resources/schema/login-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#", 3 | "type": "object", 4 | "properties": { 5 | "message": { 6 | "type": "string" 7 | }, 8 | "authorization": { 9 | "type": "string" 10 | } 11 | }, 12 | "required": [ 13 | "message", 14 | "authorization" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /src/test/resources/schema/product-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#", 3 | "type": "object", 4 | "properties": { 5 | "message": { 6 | "type": "string" 7 | }, 8 | "_id": { 9 | "type": "string" 10 | } 11 | }, 12 | "required": [ 13 | "message", 14 | "_id" 15 | ] 16 | } -------------------------------------------------------------------------------- /src/test/resources/schema/user-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#", 3 | "type": "object", 4 | "properties": { 5 | "message": { 6 | "type": "string" 7 | }, 8 | "_id": { 9 | "type": "string" 10 | } 11 | }, 12 | "required": [ 13 | "message", 14 | "_id" 15 | ] 16 | } -------------------------------------------------------------------------------- /target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst: -------------------------------------------------------------------------------- 1 | tests\login\LoginTest.class 2 | utils\BaseUrlUtil.class 3 | tests\product\CreateProductTest.class 4 | tests\product\UpdateProductTest.class 5 | tests\users\CreateUserTest.class 6 | tests\users\UpdateUserTest.class 7 | pojo\CreateUsersPojo.class 8 | tests\car\CancelCarTest.class 9 | tests\users\ListUserTest.class 10 | tests\car\ListCarTest.class 11 | factories\LoginDataFactory.class 12 | utils\LoginUtil.class 13 | tests\product\DeleteProductTest.class 14 | utils\ProductUtil.class 15 | pojo\ProductPojo.class 16 | utils\UserUtil.class 17 | tests\car\ConcludeCarTest.class 18 | factories\UserDataFactory.class 19 | pojo\ProductCarPojo.class 20 | tests\car\CreateCarTest.class 21 | factories\CarDataFactory.class 22 | pojo\CarPojo.class 23 | tests\users\DeleteUserTest.class 24 | pojo\LoginPojo.class 25 | factories\ProductDataFactory.class 26 | Runner.class 27 | tests\product\ListProductTest.class 28 | -------------------------------------------------------------------------------- /target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst: -------------------------------------------------------------------------------- 1 | C:\Users\zaela\Documents\Estudos\automacao-back\test-api-serverest\src\test\java\tests\users\UpdateUserTest.java 2 | C:\Users\zaela\Documents\Estudos\automacao-back\test-api-serverest\src\test\java\tests\login\LoginTest.java 3 | C:\Users\zaela\Documents\Estudos\automacao-back\test-api-serverest\src\test\java\pojo\ProductCarPojo.java 4 | C:\Users\zaela\Documents\Estudos\automacao-back\test-api-serverest\src\test\java\Runner.java 5 | C:\Users\zaela\Documents\Estudos\automacao-back\test-api-serverest\src\test\java\factories\ProductDataFactory.java 6 | C:\Users\zaela\Documents\Estudos\automacao-back\test-api-serverest\src\test\java\pojo\LoginPojo.java 7 | C:\Users\zaela\Documents\Estudos\automacao-back\test-api-serverest\src\test\java\tests\product\ListProductTest.java 8 | C:\Users\zaela\Documents\Estudos\automacao-back\test-api-serverest\src\test\java\tests\product\DeleteProductTest.java 9 | C:\Users\zaela\Documents\Estudos\automacao-back\test-api-serverest\src\test\java\tests\car\CancelCarTest.java 10 | C:\Users\zaela\Documents\Estudos\automacao-back\test-api-serverest\src\test\java\utils\BaseUrlUtil.java 11 | C:\Users\zaela\Documents\Estudos\automacao-back\test-api-serverest\src\test\java\utils\UserUtil.java 12 | C:\Users\zaela\Documents\Estudos\automacao-back\test-api-serverest\src\test\java\pojo\CarPojo.java 13 | C:\Users\zaela\Documents\Estudos\automacao-back\test-api-serverest\src\test\java\tests\product\UpdateProductTest.java 14 | C:\Users\zaela\Documents\Estudos\automacao-back\test-api-serverest\src\test\java\tests\product\CreateProductTest.java 15 | C:\Users\zaela\Documents\Estudos\automacao-back\test-api-serverest\src\test\java\pojo\CreateUsersPojo.java 16 | C:\Users\zaela\Documents\Estudos\automacao-back\test-api-serverest\src\test\java\tests\users\CreateUserTest.java 17 | C:\Users\zaela\Documents\Estudos\automacao-back\test-api-serverest\src\test\java\tests\users\DeleteUserTest.java 18 | C:\Users\zaela\Documents\Estudos\automacao-back\test-api-serverest\src\test\java\tests\users\ListUserTest.java 19 | C:\Users\zaela\Documents\Estudos\automacao-back\test-api-serverest\src\test\java\pojo\ProductPojo.java 20 | C:\Users\zaela\Documents\Estudos\automacao-back\test-api-serverest\src\test\java\tests\car\ListCarTest.java 21 | C:\Users\zaela\Documents\Estudos\automacao-back\test-api-serverest\src\test\java\utils\LoginUtil.java 22 | C:\Users\zaela\Documents\Estudos\automacao-back\test-api-serverest\src\test\java\utils\ProductUtil.java 23 | C:\Users\zaela\Documents\Estudos\automacao-back\test-api-serverest\src\test\java\factories\LoginDataFactory.java 24 | C:\Users\zaela\Documents\Estudos\automacao-back\test-api-serverest\src\test\java\factories\CarDataFactory.java 25 | C:\Users\zaela\Documents\Estudos\automacao-back\test-api-serverest\src\test\java\factories\UserDataFactory.java 26 | C:\Users\zaela\Documents\Estudos\automacao-back\test-api-serverest\src\test\java\tests\car\ConcludeCarTest.java 27 | C:\Users\zaela\Documents\Estudos\automacao-back\test-api-serverest\src\test\java\tests\car\CreateCarTest.java 28 | -------------------------------------------------------------------------------- /target/surefire-reports/Runner.txt: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | Test set: Runner 3 | ------------------------------------------------------------------------------- 4 | Tests run: 109, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 199.43 sec 5 | -------------------------------------------------------------------------------- /target/surefire-reports/TEST-Runner.xml: -------------------------------------------------------------------------------- 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 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | -------------------------------------------------------------------------------- /target/test-classes/Runner.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/target/test-classes/Runner.class -------------------------------------------------------------------------------- /target/test-classes/factories/CarDataFactory.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/target/test-classes/factories/CarDataFactory.class -------------------------------------------------------------------------------- /target/test-classes/factories/LoginDataFactory.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/target/test-classes/factories/LoginDataFactory.class -------------------------------------------------------------------------------- /target/test-classes/factories/ProductDataFactory.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/target/test-classes/factories/ProductDataFactory.class -------------------------------------------------------------------------------- /target/test-classes/factories/UserDataFactory.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/target/test-classes/factories/UserDataFactory.class -------------------------------------------------------------------------------- /target/test-classes/pojo/CarPojo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/target/test-classes/pojo/CarPojo.class -------------------------------------------------------------------------------- /target/test-classes/pojo/CreateUsersPojo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/target/test-classes/pojo/CreateUsersPojo.class -------------------------------------------------------------------------------- /target/test-classes/pojo/LoginPojo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/target/test-classes/pojo/LoginPojo.class -------------------------------------------------------------------------------- /target/test-classes/pojo/ProductCarPojo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/target/test-classes/pojo/ProductCarPojo.class -------------------------------------------------------------------------------- /target/test-classes/pojo/ProductPojo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/target/test-classes/pojo/ProductPojo.class -------------------------------------------------------------------------------- /target/test-classes/schema/car-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#", 3 | "type": "object", 4 | "properties": { 5 | "message": { 6 | "type": "string" 7 | }, 8 | "_id": { 9 | "type": "string" 10 | } 11 | }, 12 | "required": [ 13 | "message", 14 | "_id" 15 | ] 16 | } -------------------------------------------------------------------------------- /target/test-classes/schema/login-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#", 3 | "type": "object", 4 | "properties": { 5 | "message": { 6 | "type": "string" 7 | }, 8 | "authorization": { 9 | "type": "string" 10 | } 11 | }, 12 | "required": [ 13 | "message", 14 | "authorization" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /target/test-classes/schema/product-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#", 3 | "type": "object", 4 | "properties": { 5 | "message": { 6 | "type": "string" 7 | }, 8 | "_id": { 9 | "type": "string" 10 | } 11 | }, 12 | "required": [ 13 | "message", 14 | "_id" 15 | ] 16 | } -------------------------------------------------------------------------------- /target/test-classes/schema/user-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#", 3 | "type": "object", 4 | "properties": { 5 | "message": { 6 | "type": "string" 7 | }, 8 | "_id": { 9 | "type": "string" 10 | } 11 | }, 12 | "required": [ 13 | "message", 14 | "_id" 15 | ] 16 | } -------------------------------------------------------------------------------- /target/test-classes/tests/car/CancelCarTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/target/test-classes/tests/car/CancelCarTest.class -------------------------------------------------------------------------------- /target/test-classes/tests/car/ConcludeCarTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/target/test-classes/tests/car/ConcludeCarTest.class -------------------------------------------------------------------------------- /target/test-classes/tests/car/CreateCarTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/target/test-classes/tests/car/CreateCarTest.class -------------------------------------------------------------------------------- /target/test-classes/tests/car/ListCarTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/target/test-classes/tests/car/ListCarTest.class -------------------------------------------------------------------------------- /target/test-classes/tests/login/LoginTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/target/test-classes/tests/login/LoginTest.class -------------------------------------------------------------------------------- /target/test-classes/tests/product/CreateProductTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/target/test-classes/tests/product/CreateProductTest.class -------------------------------------------------------------------------------- /target/test-classes/tests/product/DeleteProductTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/target/test-classes/tests/product/DeleteProductTest.class -------------------------------------------------------------------------------- /target/test-classes/tests/product/ListProductTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/target/test-classes/tests/product/ListProductTest.class -------------------------------------------------------------------------------- /target/test-classes/tests/product/UpdateProductTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/target/test-classes/tests/product/UpdateProductTest.class -------------------------------------------------------------------------------- /target/test-classes/tests/users/CreateUserTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/target/test-classes/tests/users/CreateUserTest.class -------------------------------------------------------------------------------- /target/test-classes/tests/users/DeleteUserTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/target/test-classes/tests/users/DeleteUserTest.class -------------------------------------------------------------------------------- /target/test-classes/tests/users/ListUserTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/target/test-classes/tests/users/ListUserTest.class -------------------------------------------------------------------------------- /target/test-classes/tests/users/UpdateUserTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/target/test-classes/tests/users/UpdateUserTest.class -------------------------------------------------------------------------------- /target/test-classes/utils/BaseUrlUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/target/test-classes/utils/BaseUrlUtil.class -------------------------------------------------------------------------------- /target/test-classes/utils/LoginUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/target/test-classes/utils/LoginUtil.class -------------------------------------------------------------------------------- /target/test-classes/utils/ProductUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/target/test-classes/utils/ProductUtil.class -------------------------------------------------------------------------------- /target/test-classes/utils/UserUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaelreis/test-api-serverest/2fe38ade79c330428b7c7f7d272f4d9f99119f5e/target/test-classes/utils/UserUtil.class --------------------------------------------------------------------------------